tldm-universe/Ardent/UV/gcidir/include/sicaperm.h
2024-09-09 17:51:08 -04:00

306 lines
12 KiB
C
Executable File

/******************************************************************************
*
* 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.........................................
* 08/10/99 25046 JBG Rev SICA for larger schema and Table names
* 10/14/98 23801 SAP Change copyrights.
* 05/02/97 20453 CSM Add trigger definitions
* 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 UVSICAREFER
* 10/06/95 17337 JBG Fix goof on free bit map
* 09/21/95 17337 JBG Add after release 833 flag to VIEWs
* 09/20/95 17337 JBG Add updatable VIEW indicators
* 01/11/95 15733 MGM Add keys for sica offsets
* 06/08/94 13825 MGM Add foriegn column list
* 05/20/94 13825 MGM Distinguish between column list and itype for RI
* 05/04/94 12831 JBG add view templete, redefine future_offset
* 05/27/94 13825 MGM add referential constraints template
* 04/07/94 13568 JBG Support DBA in SSL_CHECK_x marcos
* 03/18/94 12535 JBG Add macros SQL_CHECK_UPDATE, DELETE, INSERT
* 01/06/94 12807 CSM Rev 0 & 1 sica region structs, uniq constr region
* 08/26/92 10113 RM Split module off from uvsica.h
******************************************************************************/
#ifndef SICAPERM_H
#define SICAPERM_H
#define SQL_FORBIDS(x) ((!fdesc->sqlperms)?0:!(fdesc->sqlperms->perms & x))
#define SQL_FORBIDS_PTR(p, x) ((!p->sqlperms)?0:!(p->sqlperms->perms & x))
#define SQL_FORBIDS_DESC(d, x) ((!d.sqlperms)?0:!(d.sqlperms->perms & x))
#define SQL_CHECK_UPDATE(p) ((!p->sqlperms)?1:(p->sqlperms->dba || p->sqlperms->uvsica->owner || p->sqlperms->uvsica->update_ok))
#define SQL_CHECK_DELETE(p) ((!p->sqlperms)?1:(p->sqlperms->dba || p->sqlperms->uvsica->owner || p->sqlperms->uvsica->delete_ok))
#define SQL_CHECK_INSERT(p) ((!p->sqlperms)?1:(p->sqlperms->dba || p->sqlperms->uvsica->owner || p->sqlperms->uvsica->insert_ok))
#define DBGET_SICA_SCHEMA(sica, sch)\
{ sch.len = strlen(sica->sica_cat_name.schema_name); \
sch.text = (char *)Rmalloc(sch.len); \
sch.text = strncpy(sch.text, sica->sica_cat_name.schema_name,sch.len); \
}
#define DBGET_SICA_TABLE(sica, tab)\
{ tab.len = strlen(sica->sica_cat_name.file_name); \
tab.text = (char *)Rmalloc(tab.len); \
tab.text = strncpy(tab.text, sica->sica_cat_name.file_name, tab.len); \
}
/* defines for sica offsets */
#define CLSICAOFF 0
#define CKSICAOFF 1
#define RISICAOFF 2
#define UQSICAOFF 3
#define ASSICAOFF 4
#define PMSICAOFF 5
#define HISICAOFF 6
#define VWSICAOFF 7
#define TRSICAOFF 8
struct uvsicacatname
{ char schema_name[55], /* the schema where the file */
/* was created. */
file_name[55]; /* name with which the file */
/* was created. */
};
#define SICACATNAME struct uvsicacatname
struct uvsicacatname03
{ char schema_name[19], /* the schema where the file */
/* was created. */
file_name[19]; /* name with which the file */
/* was created. */
};
#define SICACATNAME03 struct uvsicacatname03
#ifdef CVTSICA
/* The following definitions are used by the convert_sica utility */
struct uvsicaregion00
{ SICACATNAME03 sica_cat_name; /* table name and schema */
int checksum, /* sica validation checksum*/
size, /* sica of sica in bytes */
creator, /* table creator/owner id */
sica_column_total, /* total columns in sica ever */
sica_column_count, /* defined column count */
sica_key_count, /* defined key parts */
sica_check_count, /* check constraint count */
sica_perm_count, /* permission record count*/
sica_history_length; /* length of grant history*/
unsigned char sica_data[1]; /* binary data area */
};
typedef struct uvsicaregion00 UVSICAREGION00;
struct uvsicaconstraint00
{
short name_length, /* constraint name length, 0 if none */
text_length, /* length of constraint source text */
code_length; /* length of constraint object code */
unsigned char data[1]; /* data area for constraint */
};
typedef struct uvsicaconstraint00 UVSICACHECK00;
struct uvsicaregion02
{ uint revision; /* revision level of sica */
SICACATNAME03 sica_cat_name; /* table name and schema */
int checksum, /* sica validation checksum*/
size, /* sica of sica in bytes */
creator, /* table creator/owner id */
sica_column_total, /* total columns in sica ever */
columns_offset, /* offset to columns info */
sica_column_count, /* defined column count */
sica_key_count, /* defined key parts */
checks_offset, /* offset to check constr */
sica_check_count, /* check constraint count */
refer_offset, /* offset to refer constr */
sica_refer_count, /* refer constraint count */
uniquec_offset, /* offset to unique info */
sica_uniquec_count, /* unique constraint count*/
assoc_offset, /* offset to assoc info */
sica_assoc_count, /* associations count */
perms_offset, /* offset to permissions */
sica_perm_count, /* permission record count*/
history_offset, /* offset to grant histry */
sica_history_length, /* length of grant history*/
view_offset; /* offset to future data */
unsigned char sica_data[1]; /* binary data area */
};
#define UVSICAREGION02 struct uvsicaregion02
struct uvsicaregion03 /* 25046: change schema, table name size */
{ uint revision; /* revision level of sica */
SICACATNAME03 sica_cat_name; /* table name and schema */
int checksum, /* sica validation checksum*/
size, /* sica of sica in bytes */
creator, /* table creator/owner id */
sica_column_total, /* total columns in sica ever */
columns_offset, /* offset to columns info */
sica_column_count, /* defined column count */
sica_key_count, /* defined key parts */
checks_offset, /* offset to check constr */
sica_check_count, /* check constraint count */
refer_offset, /* offset to refer constr */
sica_refer_count, /* refer constraint count */
uniquec_offset, /* offset to unique info */
sica_uniquec_count, /* unique constraint count*/
assoc_offset, /* offset to assoc info */
sica_assoc_count, /* associations count */
perms_offset, /* offset to permissions */
sica_perm_count, /* permission record count*/
history_offset, /* offset to grant histry */
sica_history_length, /* length of grant history*/
view_offset, /* offset to future data */
view_length, /* length of view info */
trig_casc_flags, /* Trigger, Cascade flags */
trig_offset, /* offset to trigger info */
sica_trig_count, /* triggers count */
future_offset; /* future offset */
unsigned char sica_data[1]; /* binary data area */
};
#define UVSICAREGION03 struct uvsicaregion03
#endif
struct uvsicaregion
{ uint revision; /* revision level of sica */
SICACATNAME sica_cat_name; /* table name and schema */
int checksum, /* sica validation checksum*/
size, /* sica of sica in bytes */
creator, /* table creator/owner id */
sica_column_total, /* total columns in sica ever */
columns_offset, /* offset to columns info */
sica_column_count, /* defined column count */
sica_key_count, /* defined key parts */
checks_offset, /* offset to check constr */
sica_check_count, /* check constraint count */
refer_offset, /* offset to refer constr */
sica_refer_count, /* refer constraint count */
uniquec_offset, /* offset to unique info */
sica_uniquec_count, /* unique constraint count*/
assoc_offset, /* offset to assoc info */
sica_assoc_count, /* associations count */
perms_offset, /* offset to permissions */
sica_perm_count, /* permission record count*/
history_offset, /* offset to grant histry */
sica_history_length, /* length of grant history*/
view_offset, /* offset to view info */
view_length, /* length of view info */
trig_casc_flags, /* Trigger, Cascade flags */
trig_offset, /* offset to trigger info */
sica_trig_count, /* triggers count */
future_offset; /* future offset */
unsigned char sica_data[1]; /* binary data area */
};
#define UVSICAREGION struct uvsicaregion
struct uvsicaconstraint
{
short name_length, /* constraint name length, 0 if none */
collst_length, /* length of list of cols in constr */
text_length, /* length of constraint source text */
code_length; /* length of constraint object code */
unsigned char data[1]; /* data area for constraint */
};
#define UVSICACHECK struct uvsicaconstraint
struct uvuniquec
{
short name_length, /* unique constraint name length */
collst_length, /* length of list of cols in constr */
indexf_length; /* length of index file name */
unsigned char data[1]; /* data area for constraint */
};
typedef struct uvuniquec UVSICAUNIQUEC;
struct uvsicarefer
{
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);
short name_length, /* refer constraint length */
tabnam_length, /* referencing or referenced table length */
schnam_length, /* referencing or referenced schema length */
colst_length, /* length of list of referenced column(s) */
forcolst_length, /* length of list of referencing column(s) */
itype_length; /* itype name */
unsigned char data[1]; /* data area for constraint */
};
typedef struct uvsicarefer UVSICAREFER;
struct uvsicaview
{
BITMAP withcheckoption:1, /* TRUE, WITH CHECK OPTION specified */
local_cascaded:1, /* TRUE, levels clause = LOCAL */
updatable:1, /* TRUE, VIEW updatable */
symmetric:1, /* TRUE, VIEW also SYMMETRIC */
after833:1, /* TRUE, VIEW created after rel 833 */
spares:(8*sizeof(BITMAP)-5);
unsigned char query[1]; /* data area for query specification */
};
typedef struct uvsicaview UVSICAVIEW;
struct uvsica
{
short owner;
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_fields,
*reference_fields,
*update_grant_fields,
*reference_grant_fields;
};
#define UVSICA struct uvsica
struct uvsicatrig
{
BITMAP disabled:1, /* 0 Enabled, 1 disabled */
spares:(8*sizeof(BITMAP)-1);
int chksum; /* checksum of trigger object */
short events; /* trigger defined for these events */
short name_length, /* trigger name length */
creator_length, /* trigger creator's name length */
action_length; /* length of trigger action */
unsigned char data[1]; /* data area for constraint */
};
#define UVSICATRIG struct uvsicatrig
#endif