tldm-universe/Ardent/UV/gcidir/include/uvsica.h

385 lines
14 KiB
C
Raw Permalink Normal View History

2024-09-09 21:51:08 +00:00
/******************************************************************************
*
* Declarations for UniVerse Database SICA routines
*
* 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.........................................
* 10/14/98 23801 SAP Change copyrights.
* 05/02/97 20453 CSM Add trigger definitions
* 02/17/97 20038 LAG VARCHAR(n) enhancements
* 08/07/96 18144 CSM don't allow non-numeric val in numeric refd column
* 06/13/96 18582 CSM Add on update/delete fields to SICAREFER
* 07/28/94 14372 JBG Add define BASEKEYS
* 06/08/94 13825 MGM Add foriegn column list
* 05/20/94 13825 MGM Distinguish between column list and itype for RI
* 05/27/94 13825 MGM add referential constraints template
* 04/26/94 13806 MGM Add key ERR_CONS_TABUNIQUE
* 01/06/94 12807 CSM Rev 0 & 1 sica region structs, assoc/uniq constr regn
* 11/20/92 10590 RM added new data types
* 09/29/92 10102 JKW add error for too many key components
* 08/26/92 10113 RM split sicaperm.h off
* 07/13/92 10102 JKW add integrity constraints
* 07/13/92 9852 JKW add sica checking
* 08/03/92 9852 JKW add macro for fdesc pointer
******************************************************************************/
#ifndef UVSICA_H
#define UVSICA_H
#include "sicaperm.h"
#define BASEKEYS 30000
#ifdef CVTSICA
/* The following definitions are used by the convert_sica utility */
struct uvsicacolumn00
{ BITMAP set_flag:1, /* single or multi valued */
not_null:1, /* is field NOT NULL */
not_empty:1, /* is field NOT EMPTY */
unique_in_table:1, /* UNIQUE constraint */
unique_in_set:1, /* ASSOC_UNIQUE constraint */
is_key:1, /* is the part of the key */
default_type:2, /* default value type code */
/* 0 = EMPTY, 1 = NULL */
/* 2 = USER, 3 = <literal> */
spares:(8*sizeof(BITMAP)-8);
short position, /* amc in file record */
key_pos, /* position in the key */
name_length, /* length of column name/heading */
conv_length, /* length of default conversion mask */
format_length, /* length of default format mask */
default_length, /* length of literal default */
assoc_length, /* length of association name */
export_type, /* data type for export to NF1 model */
export_size; /* field size for export */
unsigned char column_data[1]; /* text data region */
};
typedef struct uvsicacolumn00 UVSICACOLUMN00;
#endif
struct uvsicacolumn
{ BITMAP set_flag:1, /* single or multi valued */
not_null:1, /* is field NOT NULL */
not_empty:1, /* is field NOT EMPTY */
unique_in_table:1, /* UNIQUE constraint */
unique_in_set:1, /* ASSOC_UNIQUE constraint */
is_key:1, /* is the part of the key */
default_type:2, /* default value type code */
/* 0 = EMPTY, 1 = NULL */
/* 2 = USER, 3 = <literal> */
spares:(8*sizeof(BITMAP)-8);
short position, /* amc in file record */
key_pos, /* position in the key */
name_length, /* length of column name/heading */
conv_length, /* length of default conversion mask */
format_length, /* length of default format mask */
default_length, /* length of literal default */
assoc_length, /* length of association name */
nullc_length, /* length of null constraint name */
emptyc_length, /* length of empty constraint name */
export_type, /* data type for export to NF1 model */
export_size; /* field size for export */
unsigned char column_data[1]; /* text data region */
};
#define UVSICACOLUMN struct uvsicacolumn
struct sica_column
{
char *name, /* column name */
*conversion, /* conversion string */
*format, /* format string */
*defalt, /* default value */
*association, /* association name */
*nullc_name, /* null constraint name */
*emptyc_name; /* empty constrant name */
BITMAP singmult:1, /* single or multi value*/
not_null:1, /* not null */
not_empty:1, /* not empty */
unique_in_table:1, /* unique in table */
unique_in_set:1, /* unique in set */
is_key:1, /* part of primary key? */
default_type:2, /* default type */
spares:(8*sizeof(BITMAP)-8);
short position, /* field number */
key_pos, /* key position */
export_type, /* export type */
export_len; /* export length */
};
#define SICACOLUMN struct sica_column
/* defines for column export type */
#define EXP_INT 0 /* Export of INTEGER */
#define EXP_SMALLINT 1 /* Export of SMALLINT */
#define EXP_CHAR 2 /* Export of CHAR; export_len is length */
#define EXP_FLOAT 3 /* Export of FLOAT; export_len is precision */
#define EXP_REAL 4 /* Export of REAL */
#define EXP_DOUBLE 5 /* Export of DOUBLE */
#define EXP_VARCHAR 6 /* Export character varying */
#define EXP_DECIMAL 7 /* Export of DECIMAL */
#define EXP_NUMERIC 8 /* Export of NUMERIC */
#define EXP_DATE 9 /* Export of DATE */
#define EXP_TIME 10 /* Export of TIME */
/* defines for column export length */
#define EXP_CHAR_DEFLEN 1 /* default length */
#define EXP_CHAR_MAXLEN 254 /* maximum length */
#define EXP_VARCHAR_DEFLEN 254 /* default length */
#define EXP_VARCHAR_MAXLEN 65535 /* maximum length */
/* defines for single or multi valued field */
#define COL_SINGLE 0 /* Single valued column */
#define COL_MULTI 1 /* Multi valued Column */
/* defines for not_null */
#define IS_NULL 0 /* may contain null value */
#define NOT_NULL 1 /* is defined as NOT NULL */
/* defines for not_empty */
#define IS_EMPTY 0 /* may be empty */
#define NOT_EMPTY 1 /* is defined to be NOT EMPTY */
/* defines for unique_in_table and unique_in_set */
#define NUNIQUE 0 /* not unique */
#define UNIQUE 1 /* is unique */
/* defines for is_key */
#define NOT_KEY 0 /* not a part of the primary key */
#define IS_KEY 1 /* part of the primary key */
/* defines for default_type */
#define NODEFAULT 0 /* no default specified */
#define NULLDEF 1 /* a default of NULL */
#define USERDEF 2 /* a default of USER */
#define LITDEF 3 /* a default of a literal is specified */
struct uvsicaassoc
{ BITMAP order:2, /* unordered 0, implict 1, explict 2 */
order_type:2, /* if implicit ASC 0, DESC 1 */
/* if explicit AL 0, AR 1, DL 2, DR 3 */
empty_row:1, /* Empty row exists 1 or not 0 */
delete:1, /* Restrict 0 or cascade 1 */
check_rowu:1, /* check row-uniqueness 1 */
spares:(8*sizeof(BITMAP)-8);
short order_col; /* ordering column if explicit order */
short name_length, /* length of association name */
collst_length, /* length of list of cols in assoc */
keylst_length; /* length of list of key columns */
unsigned char assoc_data[1]; /* text data region */
};
#define UVSICAASSOC struct uvsicaassoc
struct sica_assoc
{
char *name, /* assoc name */
*collst, /* column list */
*keylst; /* key list */
BITMAP order:2, /* unordered, implicit, explicit */
order_type:2, /* ASC, DESC, AL, AR, DL, DR */
empty_row:1, /* Empty row exists or not */
delete:1, /* Restrict or cascade */
check_rowu:1, /* check row-uniqueness */
spares:(8*sizeof(BITMAP)-8);
short order_column; /* ordering column */
};
#define SICAASSOC struct sica_assoc
struct sica_constraint
{
char *name, /* constraint name, (char *)0 if none */
*collst,/* List of cols present in constraint */
*text, /* This is the text of the constraint */
*code; /* This is the code of the constraint */
int len; /* This is the length of the code */
};
#define SICACONSTRAINT struct sica_constraint
struct sica_uniquec
{
char *name, /* unique constraint name */
*collst, /* list of cols in constraint */
*index_file; /* index file name */
};
typedef struct sica_uniquec SICAUNIQUEC;
struct sica_refer
{
char *name, /* refer constraint name */
*tabnam, /* referencing or referenced table name */
*schnam, /* referencing or referenced schema name */
*colst, /* list of referenced column(s) */
*forcolst, /* list of referencing column(s) */
*itype; /* itype name */
BITMAP referenced:1, /* TRUE tab/sch points to referencing table */
/* FALSE tab/sch points to referenced table */
coltype:2, /* column(s) type */
/* 0 = PRIMARY, 1 = UNIQUE, 2 = OTHER */
on_delete:2, /* 0 no action, 1 set default */
on_update:2, /* 2 set null, 3 cascade */
refd_mv:1, /* 1 referenced col is multivalued */
refg_mv:1, /* 1 referencing col is multivalued */
refd_ntype:1, /* 1 referenced col is numeric */
spares:(8*sizeof(BITMAP)-10);
};
typedef struct sica_refer SICAREFER;
/*
* This is a description of the uvsicapermission structure. The uvsica
* structure is basically the same except for one small detail. In the
* uvsicapermissions structure, the columns which may be referenced, updated
* reference granted, and update granted are kept in the sica_data region,
* and their counts are kept in the update_count...reference_grant_count
* variables. In the uvsica structure these values are kept in the
* update_fields...reference_grant_fields variables. The first values in these
* variables are the counts, with the rest of the data following.
*
* user User id for which this record is being kept.
* select_ok The user may select this table.
* insert_ok The user may insert rows into this table.
* delete_ok The user may delete rows from this table.
* update_ok The user may update data in this table.
* alter_ok The user may alter this table definition.
* reference_ok The user may reference this table.
* select_grant_ok The user may grant select permission.
* insert_grant_ok The user may grant insert permission.
* delete_grant_ok The user may grant delete permission.
* update_grant_ok The user may grant update permission.
* alter_grant_ok The user may grant alter permission.
* reference_grant_ok The user may grant reference permission.
* spares In case we need to expand the definition.
* update_count Number of columns updatable
* reference_count Number of columns referencable
* update_grant_count Number of columns update grantable.
* reference_grant_count Number of columns reference grantable.
* sica_data List of all columns update, reference
* update grantable, reference grantable.
*/
struct uvsicapermissions
{
int user;
BITMAP select_ok:1,
insert_ok:1,
delete_ok:1,
update_ok:1,
alter_ok:1,
reference_ok:1,
select_grant_ok:1,
insert_grant_ok:1,
delete_grant_ok:1,
update_grant_ok:1,
alter_grant_ok:1,
reference_grant_ok:1,
spares:(8*sizeof(BITMAP)-12);
unsigned short update_count,
reference_count,
update_grant_count,
reference_grant_count;
unsigned short sica_data[1];
};
#define UVSICAPERM struct uvsicapermissions
/*
* if the user value is -1 the record is for the PUBLIC user
*/
#define USERPUBLIC -1
/*
* For both the uvsicahistory and the sica_history structures, the following
* are the possible values of grant:
* 1 select permission was granted.
* 2 insert permission was granted.
* 3 delete permission was granted.
* 4 update permission was granted.
* 5 alter permission was granted.
* 6 reference permission was granted.
* 7 grant select permission was granted.
* 8 grant insert permission was granted.
* 9 grant delete permission was granted.
* 10 grant update permission was granted.
* 11 grant alter permission was granted.
* 12 grant references permission was granted.
*
* For the grant types of 4,6,10, and 12 both the uvsicahistory element
* col_data, and the sica_history element columns will be a list of the columns
* for which this permission was granted. The first value of this list will be
* the number of elements remaining in the list. This value will be 0 for all
* other permissions.
*/
struct uvsicahistory
{
int grantor, /* id of user granting */
grantee, /* if of user receiving */
grant; /* type of access granted */
unsigned short col_data[1]; /* list of columns granted */
};
#define UVSICAHIST struct uvsicahistory
struct sica_history
{
int grantor, /* id of user granting */
grantee, /* id of user receiving */
grant; /* type of access granted */
unsigned short *columns; /* list of columns granted */
};
#define SICAHISTORY struct sica_history
#define ERR_CONS_SINGLE 1
#define ERR_CONS_NULL 2
#define ERR_CONS_EMPTY 3
#define ERR_CONS_ROWUNIQUE 4
#define ERR_CONS_UNIQUE 5
#define ERR_CONS_TABUNIQUE 6
#define ERR_CONS_ASSOCKEY 7
#define ERR_CONS_CHECK 8
#define ERR_CONS_BADKEY 9
#define ERR_CONS_REFER 10
#define ERR_CONS_REFIV 11
/* The following flags are for trig_casc_flags (in sicaregion) and events (in sicatrig) fields */
/* flags for trigger operations */
#define TRROBEINS 0x1 /* Trigger Row Before Insert */
#define TRROBEUPD 0x2 /* Trigger Row Before Update */
#define TRROBEDEL 0x4 /* Trigger Row Before Delete */
#define TRROAFINS 0x8 /* Trigger Row After Insert */
#define TRROAFUPD 0x10 /* Trigger Row After Update */
#define TRROAFDEL 0x20 /* Trigger Row After Delete */
#define ALLTRIGS 0xfff /* bits for all trigger events */
#define TRROINSUPD 0x1b /* Trigger Row Insert/Update */
/* values in between will be used for statement triggers */
/* flags for cascade operations */
#define CAONUPSDEF 0x1000 /* Cascade On Update Set Default */
#define CAONUPSNUL 0x2000 /* Cascade On Update Set Null */
#define CAONUPCASC 0x4000 /* Cascade On Update Cascade */
#define CAONDLSDEF 0x8000 /* Cascade On Delete Set Default */
#define CAONDLSNUL 0x10000 /* Cascade On Delete Set Null */
#define CAONDLCASC 0x20000 /* Cascade On Delete Cascade */
#define CAONUPDATE 0x7000 /* Cascade On Update Actions */
#define CAONDELETE 0x38000 /* Cascade On Delete Actions */
#endif