303 lines
8.4 KiB
C
303 lines
8.4 KiB
C
|
/******************************************************************************
|
||
|
*
|
||
|
* Tree variables for Schema Definition Language.
|
||
|
*
|
||
|
* Module %M% Version %I% Date %H%
|
||
|
*
|
||
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
||
|
* This is unpublished proprietary source code of Ardent Software Inc.
|
||
|
* The copyright notice above does not evidence any actual or intented
|
||
|
* publication of such source code.
|
||
|
*
|
||
|
*******************************************************************************
|
||
|
*
|
||
|
* Maintenence log - insert most recent change descriptions at top
|
||
|
*
|
||
|
* Date.... GTAR# WHO Description.........................................
|
||
|
* 03/08/99 24480 LPC Change datatype for mod, large to DBDADDR
|
||
|
* 10/14/98 23801 SAP Change copyrights.
|
||
|
* 09/12/97 21444 JBG Add flag field in BASECOLIST
|
||
|
* 05/28/97 20603 HSB Add a 'next' field to IDXDEF and FORUINDEX consdef flag.
|
||
|
* 05/02/97 20453 CSM Add support for triggers
|
||
|
* 04/04/97 20201 MGM Add datapath and dictpath
|
||
|
* 02/13/97 19986 JBG Add separator to TABLEDEF
|
||
|
* 08/07/96 18144 CSM don't allow non-numeric val in numeric refd column
|
||
|
* 06/13/96 18582 CSM Add referential on delete/update
|
||
|
* 04/19/96 18237 HSB Add #defines for MVUNIQUE, SVUNIQUE
|
||
|
* 04/12/96 17832 HSB No need for 'next' field in IDXDEF structure.
|
||
|
* 01/25/96 17832 HSB Add support for CREATE/DROP INDEX. (IDXDEF).
|
||
|
* 09/28/95 17393 JBG Add corr name
|
||
|
* 09/20/95 17337 JBG Updatable VIEWs, sdml
|
||
|
* 07/15/94 14451 MGM Automatic generation of constraints names
|
||
|
* 06/29/94 14355 MGM Add support for CREATE EXISTING TABLE
|
||
|
* 06/03/94 12228 DPB Added MUV_ROOT macro to return malloced space.
|
||
|
* 05/24/94 13825 MGM add full path for referenced tables
|
||
|
* 05/20/94 13825 MGM Add inschema
|
||
|
* 05/12/94 13825 MGM Added keys.
|
||
|
* 05/11/94 13825 MGM Added Referential support
|
||
|
* 04/19/94 13726 MGM Added ALTER TABLE KEYS
|
||
|
* 03/08/94 12831 JBG Added struct BASECOLIST for CREATE VIEW
|
||
|
* 01/17/94 12831 JBG Added fields to support CREATE VIEW, DROP VIEW
|
||
|
* 01/06/94 12807 CSM added various fields to support sica struct Revs 1,2
|
||
|
*
|
||
|
*****************************************************************************/
|
||
|
struct dyn_clause {
|
||
|
int general,
|
||
|
group_size,
|
||
|
min_mod,
|
||
|
split_load,
|
||
|
merge_load;
|
||
|
DBDADDR large_rec;
|
||
|
int rec_size,
|
||
|
min_space;
|
||
|
};
|
||
|
#define DYNCLAUSE struct dyn_clause
|
||
|
|
||
|
|
||
|
#define COLIST struct col_list
|
||
|
struct col_list {
|
||
|
COLIST *next;
|
||
|
char *name;
|
||
|
int indicator; /* use varies by each chain */
|
||
|
};
|
||
|
|
||
|
#define BASECOLIST struct basecol_list
|
||
|
struct basecol_list {
|
||
|
BASECOLIST *next;
|
||
|
char *basename;
|
||
|
char *corrname;
|
||
|
COLIST *colist;
|
||
|
short indicator; /* use varies by each chain */
|
||
|
};
|
||
|
|
||
|
#define UNIQUEDEF struct unique_define
|
||
|
struct unique_define {
|
||
|
COLIST *unique_cols;
|
||
|
int unique,
|
||
|
primary,
|
||
|
rowunique;
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
struct ref_define {
|
||
|
char *table;
|
||
|
char *inschema;
|
||
|
int ref_type;
|
||
|
char *ref_itype;
|
||
|
char *tablepath;
|
||
|
char *dictpath;
|
||
|
char *vocpath;
|
||
|
COLIST *ptr;
|
||
|
unsigned int on_delete:2, /* 0 No action, 1 set default */
|
||
|
on_update:2, /* 2 set null, 3 cascade */
|
||
|
refd_mv:1, /* 1 Referenced col is Multiv */
|
||
|
refg_mv:1, /* 1 Referencng col is Multiv */
|
||
|
refd_ntype:1; /* 1 Referenced col is Numerc */
|
||
|
};
|
||
|
#define REFERDEF struct ref_define
|
||
|
|
||
|
|
||
|
#define NOTNULLFLD 0x01 /* used in flags for On del/upd */
|
||
|
#define MVREFGCOL 0x02 /* Referencing column is multivalued */
|
||
|
#define FORUINDEX 0x04 /* Consdef appropriated for Unique Indices */
|
||
|
|
||
|
#define CONSDEF struct cons_define
|
||
|
struct cons_define {
|
||
|
CONSDEF *next;
|
||
|
char *name,
|
||
|
*check;
|
||
|
COLIST *chk_colnams; /* List of col names in check constr */
|
||
|
REFERDEF *ref_spec;
|
||
|
COLIST *for_key;
|
||
|
int for_type;
|
||
|
char *for_itype;
|
||
|
UNIQUEDEF *unique_spec;
|
||
|
int flags;
|
||
|
};
|
||
|
|
||
|
#define IDXDEF struct idx_define
|
||
|
struct idx_define {
|
||
|
IDXDEF *next;
|
||
|
char *name;
|
||
|
COLIST *idx_colnams;
|
||
|
int unique;
|
||
|
int sing_mult;
|
||
|
};
|
||
|
|
||
|
|
||
|
#define COLUMNDEF struct col_define
|
||
|
struct col_define {
|
||
|
COLUMNDEF *next;
|
||
|
char *name,
|
||
|
*synname,
|
||
|
*display,
|
||
|
*conv,
|
||
|
*format,
|
||
|
*assoc,
|
||
|
*nullc_name,
|
||
|
*emptyc_name,
|
||
|
*sqltype,
|
||
|
*defalt;
|
||
|
CONSDEF *consptr;
|
||
|
int synonym,
|
||
|
def_type,
|
||
|
data_type,
|
||
|
data_len,
|
||
|
sing_mult,
|
||
|
not_null,
|
||
|
not_empty,
|
||
|
prim_key,
|
||
|
unique,
|
||
|
in_unique_tblc, /* Col in Table Unique Constraint */
|
||
|
rowunique;
|
||
|
};
|
||
|
|
||
|
#define ASSOC_COLS struct assoc_cols
|
||
|
struct assoc_cols {
|
||
|
char *name;
|
||
|
ASSOC_COLS *next;
|
||
|
int key;
|
||
|
};
|
||
|
|
||
|
#define ASSOCDEF struct assoc_define
|
||
|
struct assoc_define {
|
||
|
char *name,
|
||
|
*order,
|
||
|
*order_col,
|
||
|
*order_type;
|
||
|
ASSOC_COLS *cols;
|
||
|
ASSOCDEF *next;
|
||
|
int empty_row,
|
||
|
check_rowu,
|
||
|
delete;
|
||
|
};
|
||
|
|
||
|
#define TRIGDEF struct trig_define
|
||
|
struct trig_define {
|
||
|
char *name,
|
||
|
*creator, /* trigger creator's name */
|
||
|
*action,
|
||
|
*table; /* table name */
|
||
|
TRIGDEF *next;
|
||
|
int time, /* 0 - Before, 1 - After */
|
||
|
granularity, /* 0 - Row, 1 - Statement */
|
||
|
events, /* Row Bef - bit 1 Ins, 2 Upd, 3 Del */
|
||
|
/* Row Aft - bit 4 Ins, 5 Upd, 6 Del */
|
||
|
chksum; /* checksum of trigger object code */
|
||
|
};
|
||
|
|
||
|
#define TABLEDEF struct table_define
|
||
|
struct table_define {
|
||
|
char *name;
|
||
|
TABLEDEF *next;
|
||
|
DYNCLAUSE *dyn;
|
||
|
CONSDEF *consptr;
|
||
|
IDXDEF *idxptr;
|
||
|
ASSOCDEF *assocs; /* pointer to association defines */
|
||
|
COLUMNDEF *colptr;
|
||
|
TRIGDEF *trigs; /* pointer to triggers defined */
|
||
|
int type;
|
||
|
DBDADDR modulo;
|
||
|
int separation;
|
||
|
int tabletype; /* 'T' = Table, 'V' = View */
|
||
|
COLIST *expcolnames; /* explicit column names */
|
||
|
char *queryspec; /* <query specification> */
|
||
|
BASECOLIST *basetabnms; /* list of VIEW base tables & column names */
|
||
|
int withcheckoption; /* WITH CHECK OPTION found in view */
|
||
|
int existingfile;
|
||
|
int nextconnum;
|
||
|
int local_cascaded; /* true if LOCAL (& 0X01) */
|
||
|
int updatable; /* true if Updatable VIEW */
|
||
|
int symmetric; /* SYMMETRIC Updatable VIEW */
|
||
|
char *columnsequence; /* Updatable VIEW column sequence */
|
||
|
uchar separator; /* user separator <<< JBG 19986 <<< */
|
||
|
char *datapath;
|
||
|
char *dictpath;
|
||
|
};
|
||
|
|
||
|
#define GRANTDEF struct grant_define
|
||
|
struct grant_define {
|
||
|
char *table;
|
||
|
GRANTDEF *next;
|
||
|
COLIST *users,
|
||
|
*ref_list,
|
||
|
*update_list;
|
||
|
int public,
|
||
|
all_priv,
|
||
|
select,
|
||
|
delete,
|
||
|
insert,
|
||
|
alter,
|
||
|
update,
|
||
|
update_all,
|
||
|
reference,
|
||
|
reference_all,
|
||
|
with_grant;
|
||
|
};
|
||
|
|
||
|
|
||
|
struct connect_define {
|
||
|
COLIST *users;
|
||
|
int type;
|
||
|
};
|
||
|
#define CONDEF struct connect_define
|
||
|
|
||
|
|
||
|
struct schema_define {
|
||
|
char *name, /* name for schema in catalog */
|
||
|
*path, /* path for the schema */
|
||
|
*authident; /* name of user who owns schema */
|
||
|
TABLEDEF *tables; /* pointer to tables in schema */
|
||
|
COLIST *drop; /* pointer to drop tables */
|
||
|
GRANTDEF *privs; /* pointer to privilege defines */
|
||
|
GRANTDEF *rev_privs; /* pointer to revoke privs */
|
||
|
CONDEF *cons; /* user definitions */
|
||
|
CONDEF *revoke; /* revoke user definitions */
|
||
|
int dropping, /* are we dropping the schema */
|
||
|
cascade; /* are we cascading */
|
||
|
};
|
||
|
#define SCHEMADEF struct schema_define
|
||
|
|
||
|
#define ATB_AC 1 /* Add a column */
|
||
|
#define ATB_ATC 2 /* add a table constraint */
|
||
|
#define ATB_AA 3 /* add a association */
|
||
|
#define ATB_DTC 4 /* drop a table constraint */
|
||
|
#define ATB_DA 5 /* drop a association */
|
||
|
#define ATB_AS 6 /* alter set default */
|
||
|
#define ATB_AD 7 /* alter drop default */
|
||
|
#define ATB_AI 8 /* add an index */
|
||
|
#define ATB_AUI 9 /* add a unique index */
|
||
|
#define ATB_TRIG_EN 10 /* Enable a trigger */
|
||
|
#define ATB_TRIG_DI 11 /* Disable a trigger */
|
||
|
#define CR_TRIG 12 /* Create a trigger */
|
||
|
#define ATB_INATB -1 /* Some ATB command */
|
||
|
|
||
|
/* keys for referential integrity */
|
||
|
#define RIUNKNW 4 /* unknown type */
|
||
|
#define RIPRIMY 0 /* PRIMARY KEY access */
|
||
|
#define RICOLUN 1 /* UNIQUE KEY access */
|
||
|
#define RITBLUN 2 /* TABLE UNIQUE access */
|
||
|
#define RIOTHER 3 /* For foreign keys only */
|
||
|
|
||
|
#define SVUNIQUE 1 /* unique constraint on single value columns */
|
||
|
#define MVUNIQUE 2 /* unique constraint on multivalue column */
|
||
|
|
||
|
#define MUV_ROOT(x)\
|
||
|
strcpy(Rmalloc(strlen(UV_ROOT(x))+1),UV_ROOT(x));
|
||
|
|
||
|
/* bits used for table drop indicator
|
||
|
0x0 table
|
||
|
0x1 table cascade
|
||
|
0x2 DROP SCHEMA,
|
||
|
0x4 view
|
||
|
0x8 ASSOC, else BASE TABLE
|
||
|
0x10 CASCADED drop
|
||
|
0x20 index
|
||
|
0x40 drop RESTORE
|
||
|
0x80 drop table trigger
|
||
|
*/
|
||
|
#define existing_restore 0x40
|
||
|
#define existing_restore_cascade 0x41
|
||
|
#define DROP_TABLE_TRIG 0x80 /* Drop table trigger */
|