1/*
2 * Legal Notice
3 *
4 * This document and associated source code (the "Work") is a part of a
5 * benchmark specification maintained by the TPC.
6 *
7 * The TPC reserves all right, title, and interest to the Work as provided
8 * under U.S. and international laws, including without limitation all patent
9 * and trademark rights therein.
10 *
11 * No Warranty
12 *
13 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
14 * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
15 * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
16 * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
17 * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
18 * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
19 * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
20 * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
21 * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
22 * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
23 * WITH REGARD TO THE WORK.
24 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
25 * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
26 * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
27 * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
28 * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
29 * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
30 * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
31 * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * Contributors:
34 * Gradient Systems
35 */
36#ifndef TDEFS_H
37#define TDEFS_H
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#include <stdio.h>
44#include "tables.h"
45#include "columns.h"
46#include "tdef_functions.h"
47
48/*
49 * Flag field definitions used in tdefs[]
50 */
51#define FL_NONE 0x0000 /* this table is not defined */
52#define FL_NOP 0x0001 /* this table is not defined */
53#define FL_DATE_BASED 0x0002 /* this table is produced in date order */
54#define FL_CHILD 0x0004 /* this table is the child in a parent/child link */
55#define FL_OPEN 0x0008 /* this table has a valid output destination */
56#define FL_DUP_NAME 0x0010 /* to keep find_table() from complaining twice */
57#define FL_TYPE_2 \
58 0x0020 /* this dimension keeps history -- rowcount shows unique entities \
59 (not including revisions) */
60#define FL_SMALL 0x0040 /* this table has low rowcount; used by address.c */
61#define FL_SPARSE 0x0080
62/* unused 0x0100 */
63#define FL_NO_UPDATE 0x0200 /* this table is not altered by the update process */
64#define FL_SOURCE_DDL 0x0400 /* table in the souce schema */
65#define FL_JOIN_ERROR 0x0800 /* join called without an explicit rule */
66#define FL_PARENT 0x1000 /* this table has a child in nParam */
67#define FL_FACT_TABLE 0x2000
68#define FL_PASSTHRU 0x4000 /* verify routine uses warehouse without change */
69#define FL_VPRINT 0x8000 /* verify routine includes print function */
70
71/*
72 * general table descriptions.
73 * NOTE: This table contains the constant elements in the table descriptions; it
74 * must be kept in sync with the declararions of assocaited functions, found in
75 * tdef_functions.h
76 */
77typedef struct TDEF_T {
78 char *name; /* -- name of the table; */
79 char *abreviation; /* -- shorthand name of the table */
80 int flags; /* -- control table options */
81 int nFirstColumn; /* -- first column/RNG for this table */
82 int nLastColumn; /* -- last column/RNG for this table */
83 int nTableIndex; /* used for rowcount calculations */
84 int nParam; /* -- additional table param (revision count, child number,
85 etc.) */
86 FILE *outfile; /* -- output destination */
87 int nUpdateSize; /* -- percentage of base rowcount in each update set (basis
88 points) */
89 int nNewRowPct;
90 int nNullPct; /* percentage of rows with nulls (basis points) */
91 ds_key_t kNullBitMap; /* colums that should be NULL in the current row */
92 ds_key_t kNotNullBitMap; /* columns that are defined NOT NULL */
93 ds_key_t *arSparseKeys; /* sparse key set for table; used if FL_SPARSE is set */
94} tdef;
95
96/*
97extern tdef *tdefs;
98extern tdef w_tdefs[];
99extern tdef s_tdefs[];
100*/
101
102#define tdefIsFlagSet(t, f) (tdefs[t].flags & f)
103ds_key_t GetRowcountByName(char *szName);
104int GetTableNumber(char *szName);
105char *getTableNameByID(int id);
106int getTableFromColumn(int id);
107int initSpareKeys(int id);
108tdef *getSimpleTdefsByNumber(int nTable);
109tdef *getTdefsByNumber(int nTable);
110
111#ifdef __cplusplus
112};
113#endif
114#endif
115