2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Data Definition Utility
|
|
|
|
* MODULE: ddl.h
|
|
|
|
* DESCRIPTION: Common header modules
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
#ifndef DUDLEY_DDL_H
|
|
|
|
#define DUDLEY_DDL_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#include "../jrd/common.h"
|
2004-05-03 01:06:37 +02:00
|
|
|
#include "../jrd/ibase.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
const int BLOCK_SIZE = 1024;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
const int MAXSYMLEN = 257; // max length of symbol + terminator
|
|
|
|
const int MAX_PAGE_LEN = 16384; // max allowable length for a database page
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
const int DDL_MSG_FAC = 2;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Action block. Do something. */
|
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
|
|
|
enum act_t {
|
|
|
|
act_c_database, /* create database */
|
|
|
|
act_m_database, /* modify database */
|
|
|
|
act_d_database, /* drop a database */
|
|
|
|
act_a_relation, /* add relation */
|
|
|
|
act_m_relation, /* modify existing relation */
|
|
|
|
act_d_relation, /* drop existing relations */
|
|
|
|
act_a_gfield, /* add global field */
|
|
|
|
act_m_gfield, /* modify existing global fields */
|
|
|
|
act_d_gfield, /* drop global field */
|
|
|
|
act_a_field, /* add field to relation */
|
|
|
|
act_m_field, /* modify relation specific fields */
|
|
|
|
act_d_field, /* drop field from relation */
|
|
|
|
act_a_index, /* add index */
|
|
|
|
act_m_index, /* modify index */
|
|
|
|
act_d_index, /* delete index */
|
|
|
|
act_a_security, /* add security class */
|
|
|
|
act_d_security, /* delete security class */
|
|
|
|
act_m_security, /* modify security class */
|
|
|
|
act_a_trigger, /* add new trigger */
|
|
|
|
act_m_trigger, /* modify (replace) trigger */
|
|
|
|
act_d_trigger, /* delete trigger */
|
|
|
|
act_a_file, /* add file */
|
|
|
|
act_a_function, /* add function */
|
|
|
|
act_d_function, /* drop function */
|
|
|
|
act_a_function_arg, /* add function */
|
|
|
|
act_d_function_arg, /* drop function */
|
|
|
|
act_a_trigger_msg, /* add trigger message */
|
|
|
|
act_m_trigger_msg, /* modify trigger message */
|
|
|
|
act_d_trigger_msg, /* drop trigger message */
|
|
|
|
act_a_type, /* add type for field */
|
|
|
|
act_m_type, /* modify type for field */
|
|
|
|
act_d_type, /* drop type for field */
|
|
|
|
act_a_filter, /* add filter */
|
|
|
|
act_d_filter, /* drop filter */
|
|
|
|
act_grant, /* grant user privilege */
|
|
|
|
act_revoke, /* revoke user privilege */
|
|
|
|
act_a_shadow, /* add shadow */
|
|
|
|
act_d_shadow, /* drop shadow */
|
|
|
|
act_a_generator, /* add generator */
|
|
|
|
act_s_generator /* reset generator value */
|
|
|
|
};
|
|
|
|
|
2004-03-11 06:04:26 +01:00
|
|
|
struct dbb;
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct act {
|
2003-10-03 04:00:40 +02:00
|
|
|
enum act_t act_type; // what to do
|
|
|
|
act* act_next; // next action in system
|
2004-03-11 06:04:26 +01:00
|
|
|
dbb* act_object; // object in question (dudley_rel, dudley_fld, idx, etc.)
|
2003-10-03 04:00:40 +02:00
|
|
|
USHORT act_line; // line the action started on
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT act_flags;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *ACT;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
const int ACT_ignore = 1; // Ignore the action
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Context block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dudley_ctx {
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* ctx_name;
|
|
|
|
struct dudley_rel* ctx_relation;
|
|
|
|
struct dudley_fld* ctx_field;
|
2009-01-05 09:22:58 +01:00
|
|
|
bool ctx_view_rse;
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT ctx_context_id;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *DUDLEY_CTX;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Database Definition Block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dbb {
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* dbb_name;
|
|
|
|
struct dudley_rel* dbb_relations;
|
|
|
|
struct gfl* dbb_fields;
|
2003-09-30 12:39:11 +02:00
|
|
|
dbb* dbb_next;
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* dbb_security_class;
|
2004-05-03 01:06:37 +02:00
|
|
|
isc_db_handle dbb_handle;
|
|
|
|
isc_tr_handle dbb_transaction;
|
2003-10-05 08:37:26 +02:00
|
|
|
struct txt* dbb_description;
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT dbb_flags;
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* dbb_file_name;
|
|
|
|
struct fil* dbb_files;
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT dbb_page_size;
|
|
|
|
ULONG dbb_length; /* Length of database in pages, if known */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct fil* dbb_logfiles;
|
|
|
|
struct fil* dbb_overflow;
|
2001-05-23 15:26:42 +02:00
|
|
|
SLONG dbb_chkptlen;
|
|
|
|
SSHORT dbb_numbufs;
|
|
|
|
SSHORT dbb_bufsize;
|
|
|
|
SLONG dbb_grp_cmt_wait;
|
2004-06-09 20:11:27 +02:00
|
|
|
struct fil* dbb_cache_file;
|
|
|
|
} *DBB;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum dbb_flags_vals {
|
|
|
|
DBB_null_description = 1,
|
|
|
|
DBB_null_security_class = 2,
|
2004-10-27 12:54:25 +02:00
|
|
|
DBB_create_database = 4
|
2004-10-03 06:49:04 +02:00
|
|
|
// DBB_drop_log = 8,
|
|
|
|
// DBB_log_serial = 16,
|
|
|
|
// DBB_log_preallocated = 32,
|
|
|
|
// DBB_log_default = 64,
|
|
|
|
// DBB_cascade = 128,
|
|
|
|
// DBB_drop_cache = 256
|
2003-10-03 04:00:40 +02:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum ods_versions {
|
|
|
|
DB_VERSION_DDL4 = 4, // ods4 db
|
|
|
|
DB_VERSION_DDL6 = 6, // ods6 db
|
|
|
|
DB_VERSION_DDL8 = 8 // ods8 db
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Field block. Fields are what farms and databases are all about */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dudley_fld {
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT fld_dtype; /* data type of field */
|
|
|
|
SSHORT fld_length; /* field length in bytes */
|
|
|
|
SSHORT fld_scale; /* scale factor */
|
|
|
|
SSHORT fld_position; /* field position */
|
|
|
|
SSHORT fld_segment_length;
|
|
|
|
SSHORT fld_sub_type;
|
2009-01-05 09:22:58 +01:00
|
|
|
bool fld_has_sub_type;
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT fld_dimension; /* size of multi-dim. array */
|
|
|
|
SSHORT fld_system; /* 0 if field is user defined */
|
|
|
|
USHORT fld_flags; /* misc trash */
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_fld* fld_next; /* next field in relation */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct dudley_rel* fld_relation; /* relation */
|
|
|
|
struct sym* fld_security_class;
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_ctx* fld_context; /* context for view */
|
|
|
|
dbb* fld_database; /* database for global fields */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* fld_name; /* field name */
|
|
|
|
struct sym* fld_source; /* name of global field */
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_fld* fld_source_field; /* global field for computed field */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* fld_base; /* base field for views */
|
|
|
|
struct sym* fld_query_name; /* query name */
|
|
|
|
struct dudley_nod* fld_query_header; /* query header */
|
|
|
|
struct sym* fld_edit_string; /* edit string */
|
|
|
|
struct dudley_nod* fld_computed; /* computed by expression */
|
|
|
|
struct dudley_nod* fld_missing; /* missing value */
|
|
|
|
struct dudley_nod* fld_default; /* default value */
|
|
|
|
struct dudley_nod* fld_validation; /* valid if value */
|
|
|
|
struct txt* fld_description; /* description of field */
|
|
|
|
struct txt* fld_compute_src; /* computed_by source */
|
|
|
|
struct txt* fld_valid_src; /* validation source */
|
|
|
|
SLONG* fld_ranges; /* ranges for multi-dim. array */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *DUDLEY_FLD;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum fld_flags_vals {
|
|
|
|
fld_explicit_position = 1,
|
|
|
|
fld_modify = 2,
|
|
|
|
fld_local = 4,
|
|
|
|
fld_null_description = 8,
|
|
|
|
fld_null_security_class = 16,
|
|
|
|
fld_null_validation = 32,
|
|
|
|
fld_explicit_system = 64,
|
|
|
|
fld_null_missing_value = 128,
|
|
|
|
fld_null_edit_string = 256,
|
|
|
|
fld_null_query_name = 512,
|
|
|
|
fld_null_query_header = 1024
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* File description block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct fil {
|
2001-05-23 15:26:42 +02:00
|
|
|
SLONG fil_length; /* File length in pages */
|
|
|
|
SLONG fil_start; /* Starting page */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* fil_name; /* File name */
|
2003-09-30 12:39:11 +02:00
|
|
|
fil* fil_next; /* next file */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT fil_shadow_number; /* shadow number if part of shadow */
|
|
|
|
SSHORT fil_manual; /* flag to indicate manual shadow */
|
|
|
|
SSHORT fil_partitions; /* number of log file partitions */
|
|
|
|
SSHORT fil_raw; /* on raw device? */
|
|
|
|
SSHORT fil_conditional; /* flag to indicate conditional shadow */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *FIL;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Filter block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct filter {
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* filter_name; /* symbol for filter name */
|
|
|
|
struct txt* filter_description; /* description of filter */
|
|
|
|
struct sym* filter_module_name; /* symbol for module name */
|
|
|
|
struct sym* filter_entry_point; /* symbol for entrypoint */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT filter_input_sub_type;
|
|
|
|
SSHORT filter_output_sub_type;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *FILTER;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Function argument block. */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct funcarg {
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* funcarg_funcname; /* symbol for function name */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT funcarg_position; /* argument position */
|
|
|
|
SSHORT funcarg_mechanism; /* argument passed by value, or by reference */
|
|
|
|
SSHORT funcarg_dtype; /* data type of argument */
|
|
|
|
SSHORT funcarg_scale; /* scale factor */
|
|
|
|
SSHORT funcarg_length; /* argument length in bytes */
|
|
|
|
SSHORT funcarg_return_arg; /* argument is the designated return arg */
|
|
|
|
SSHORT funcarg_sub_type; /* sub_type of text */
|
2009-01-05 09:22:58 +01:00
|
|
|
bool funcarg_has_sub_type; /* null field for sub_type field */
|
2003-09-30 12:39:11 +02:00
|
|
|
funcarg* funcarg_next; /* next field in function */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *FUNCARG;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum funcarg_mechanism_vals {
|
|
|
|
FUNCARG_mechanism_value = 0,
|
|
|
|
FUNCARG_mechanism_reference,
|
|
|
|
FUNCARG_mechanism_descriptor,
|
|
|
|
FUNCARG_mechanism_blob_struc,
|
|
|
|
FUNCARG_mechanism_sc_array_desc
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-09-30 12:39:11 +02:00
|
|
|
|
|
|
|
/* Function description block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct func {
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* func_name; /* symbol for function name */
|
|
|
|
struct sym* func_query_name; /* symbol for query name */
|
|
|
|
struct sym* func_module_name; /* symbol for module name */
|
|
|
|
struct sym* func_entry_point; /* symbol for entrypoint */
|
2003-09-30 12:39:11 +02:00
|
|
|
SSHORT func_return_arg; /* return argument position */
|
|
|
|
func* func_next; /* next function in database */
|
|
|
|
dbb* func_database; /* database for function */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct txt* func_description; /* description of function */
|
2003-09-30 12:39:11 +02:00
|
|
|
funcarg* func_args; /* Known function arguments */
|
|
|
|
funcarg* func_return; /* Return argument */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *FUNC;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Index description block */
|
|
|
|
|
2003-09-12 18:32:19 +02:00
|
|
|
enum idx_direction
|
|
|
|
{
|
2003-09-15 04:15:27 +02:00
|
|
|
IDX_type_none = 0,
|
|
|
|
IDX_type_descend = 1
|
2003-09-12 18:32:19 +02:00
|
|
|
};
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dudley_idx {
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT idx_count; /* Number of fields */
|
2003-09-10 19:52:12 +02:00
|
|
|
bool idx_unique; /* true if unique index */
|
|
|
|
bool idx_inactive; /* false if index is active */
|
2003-09-12 18:32:19 +02:00
|
|
|
idx_direction idx_type; /* true descending */
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT idx_flags; /* Indicate which attributes have changed */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* idx_name; /* Index name */
|
|
|
|
struct sym* idx_relation; /* Relation in question */
|
|
|
|
struct txt* idx_description; /* Description pointer */
|
|
|
|
struct sym* idx_field[1]; /* Fields */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *DUDLEY_IDX;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum idx_flags_vals {
|
|
|
|
IDX_active_flag = 1,
|
|
|
|
IDX_unique_flag = 2,
|
|
|
|
IDX_null_description = 4,
|
|
|
|
IDX_type_flag = 8,
|
|
|
|
IDX_statistics_flag = 16
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-05 08:37:26 +02:00
|
|
|
static inline size_t IDX_LEN(const size_t cnt)
|
|
|
|
{
|
2003-10-29 11:53:47 +01:00
|
|
|
return sizeof (struct dudley_idx) +
|
|
|
|
(cnt ? cnt - 1 : 0) * sizeof (((DUDLEY_IDX) NULL)->idx_field[0]);
|
2003-10-03 04:00:40 +02:00
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Linked list stack stuff */
|
|
|
|
|
2004-02-02 12:02:12 +01:00
|
|
|
struct dudley_lls {
|
|
|
|
struct dudley_nod *lls_object; // object on stack
|
|
|
|
dudley_lls* lls_next; // next item on stack
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* General Syntax node, produced by parser */
|
|
|
|
|
|
|
|
enum nod_t {
|
|
|
|
nod_field = 1, nod_literal, nod_value,
|
|
|
|
nod_and, nod_or, nod_not,
|
|
|
|
nod_eql, nod_neq, nod_geq,
|
|
|
|
nod_leq, nod_gtr, nod_lss,
|
|
|
|
nod_containing, nod_matches, nod_any,
|
|
|
|
nod_unique, nod_add, nod_multiply,
|
|
|
|
nod_divide, nod_subtract, nod_negate,
|
|
|
|
nod_msg, nod_for, nod_send,
|
|
|
|
nod_receive, nod_block, nod_select,
|
|
|
|
nod_boolean, nod_projection, nod_sort,
|
|
|
|
nod_store, nod_modify, nod_erase,
|
|
|
|
nod_if, nod_assignment, nod_rse,
|
|
|
|
nod_first, nod_context, nod_end,
|
|
|
|
nod_label, nod_leave, nod_loop,
|
|
|
|
nod_max, nod_min, nod_count,
|
|
|
|
nod_total, nod_average, nod_list,
|
2006-05-02 02:04:12 +02:00
|
|
|
nod_deferred, nod_between, nod_missing,
|
2001-05-23 15:26:42 +02:00
|
|
|
nod_field_name, nod_name, nod_starts,
|
|
|
|
nod_from, nod_fid, nod_concatenate,
|
|
|
|
nod_abort, nod_null, nod_user_name,
|
|
|
|
nod_post, nod_function, nod_gen_id,
|
|
|
|
nod_uppercase, nod_sleuth, nod_over,
|
2005-05-28 00:45:31 +02:00
|
|
|
nod_set_generator, nod_index,
|
|
|
|
nod_lowercase
|
2001-05-23 15:26:42 +02:00
|
|
|
};
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dudley_nod {
|
2001-05-23 15:26:42 +02:00
|
|
|
enum nod_t nod_type; /* node type */
|
2003-10-05 08:37:26 +02:00
|
|
|
UCHAR* nod_blr; /* symbolic blr string */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT nod_count; /* number of sub-items */
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_nod* nod_arg[1]; /* argument */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *DUDLEY_NOD;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-05 08:37:26 +02:00
|
|
|
static inline size_t NOD_LEN(const size_t cnt)
|
|
|
|
{
|
2003-10-29 11:53:47 +01:00
|
|
|
return sizeof(dudley_nod) +
|
|
|
|
(cnt ? cnt - 1 : 0) * sizeof (((DUDLEY_NOD) NULL)->nod_arg[0]);
|
2003-10-03 04:00:40 +02:00
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Relation block, not to be confused with siblings or in-laws */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dudley_rel {
|
2003-09-30 12:39:11 +02:00
|
|
|
dbb* rel_database; /* parent database */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* rel_filename; /* external filename */
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_fld* rel_fields; /* linked list of known fields */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* rel_name; /* symbol for relation */
|
|
|
|
struct sym* rel_security_class; /* name of security class */
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_rel* rel_next; /* next relation in database */
|
|
|
|
dudley_nod* rel_rse; /* view rse */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct txt* rel_description; /* description of relation */
|
|
|
|
struct txt* rel_view_source; /* source dml for view definition */
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT rel_field_position; /* highest used field position */
|
|
|
|
SSHORT rel_system; /* 0 if relation is user defined */
|
|
|
|
USHORT rel_flags;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *DUDLEY_REL;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum rel_flags_values {
|
|
|
|
rel_null_description = 1,
|
|
|
|
rel_null_security_class = 2,
|
|
|
|
rel_explicit_system = 4,
|
|
|
|
rel_marked_for_delete = 8,
|
|
|
|
rel_null_ext_file = 16,
|
|
|
|
rel_marked_for_modify = 32,
|
|
|
|
rel_marked_for_creation = 64
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Security class handling */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct scl {
|
2003-10-05 08:37:26 +02:00
|
|
|
struct sym* scl_name; /* name of security class */
|
|
|
|
struct txt* scl_description; /* description of security class */
|
|
|
|
struct sce* scl_entries; /* list of entries */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *SCL;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
const int SCL_write = 2;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Security entry */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct sce {
|
2003-09-30 12:39:11 +02:00
|
|
|
sce* sce_next; /* next security item in list */
|
2001-05-23 15:26:42 +02:00
|
|
|
SLONG sce_privileges; /* bitmask of privileges */
|
2003-10-05 08:37:26 +02:00
|
|
|
UCHAR* sce_idents[20]; /* misc identification stuff */
|
2001-05-23 15:26:42 +02:00
|
|
|
UCHAR sce_strings[1];
|
2004-06-09 20:11:27 +02:00
|
|
|
} *SCE;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* String block for build DYN & BLR strings */
|
|
|
|
|
2004-05-24 13:03:54 +02:00
|
|
|
class str {
|
|
|
|
public:
|
2003-10-05 08:37:26 +02:00
|
|
|
UCHAR* str_start; /* start of string buffer */
|
|
|
|
UCHAR* str_current; /* current position in string being built */
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT str_length; /* length of buffer */
|
2004-05-29 06:55:23 +02:00
|
|
|
inline void add_byte(const int byte) {
|
2004-05-24 13:03:54 +02:00
|
|
|
*str_current++ = byte;
|
|
|
|
}
|
2004-05-29 06:55:23 +02:00
|
|
|
inline void add_word(const int word) {
|
2004-05-24 13:03:54 +02:00
|
|
|
add_byte(word);
|
|
|
|
add_byte(word >> 8);
|
|
|
|
}
|
2004-11-10 05:26:45 +01:00
|
|
|
};
|
2004-05-24 13:03:54 +02:00
|
|
|
|
|
|
|
typedef str* STR;
|
2001-05-23 15:26:42 +02:00
|
|
|
/* Symbol block, also used for hash table */
|
|
|
|
|
|
|
|
enum sym_t {
|
|
|
|
SYM_keyword, /* unspecified */
|
|
|
|
SYM_context, /* context variable */
|
|
|
|
SYM_database, /* seems like a good idea */
|
|
|
|
SYM_relation, /* if you don't know your relations, how do you know your friends? */
|
|
|
|
SYM_global, /* Global field */
|
|
|
|
SYM_field, /* Local field */
|
|
|
|
SYM_function, /* UDF */
|
|
|
|
SYM_trigger /* any named element deserves to be hashed */
|
|
|
|
};
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct sym {
|
2004-11-08 04:19:22 +01:00
|
|
|
const char* sym_string; /* address of asciz string */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT sym_length; /* length of string (exc. term.) */
|
|
|
|
enum sym_t sym_type; /* symbol type */
|
|
|
|
SSHORT sym_keyword; /* keyword number, if keyword */
|
2003-09-30 12:39:11 +02:00
|
|
|
dudley_ctx* sym_object; /* general pointer to object */
|
|
|
|
sym* sym_collision; /* collision pointer */
|
|
|
|
sym* sym_homonym; /* homonym pointer */
|
2001-05-23 15:26:42 +02:00
|
|
|
TEXT sym_name[1]; /* space for name, if necessary */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *SYM;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
const size_t SYM_LEN = sizeof(sym);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Trigger block */
|
|
|
|
|
|
|
|
/* these are the externally visible trigger types */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef enum {
|
2001-05-23 15:26:42 +02:00
|
|
|
trg_type_none = 0, /* pre store */
|
|
|
|
trg_store = 1, /* pre store */
|
|
|
|
trg_post_store = 2,
|
|
|
|
trg_modify = 3, /* pre modify */
|
|
|
|
trg_post_modify = 4,
|
|
|
|
trg_pre_erase = 5,
|
|
|
|
trg_erase = 6 /* post erase */
|
2004-06-09 20:11:27 +02:00
|
|
|
} TRG_T;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* these types are used in parsing */
|
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum parse_trig_types {
|
|
|
|
trig_pre = 0,
|
|
|
|
trig_post = 1,
|
|
|
|
trig_sto = 2,
|
|
|
|
trig_mod = 4,
|
|
|
|
trig_era = 8, // erase defaults to post
|
|
|
|
trig_inact = 16
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct dudley_trg {
|
2001-05-23 15:26:42 +02:00
|
|
|
TRG_T trg_type;
|
2002-11-17 01:04:19 +01:00
|
|
|
DUDLEY_REL trg_relation;
|
2002-11-11 20:11:52 +01:00
|
|
|
DUDLEY_NOD trg_statement; /* blr */
|
2003-09-30 12:39:11 +02:00
|
|
|
sym* trg_name; /* symbol for trigger */
|
2003-10-05 08:37:26 +02:00
|
|
|
struct txt* trg_description; /* description of relation */
|
|
|
|
struct txt* trg_source; /* source of trigger */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT trg_sequence;
|
|
|
|
SSHORT trg_inactive; /* 0 = on, 1 = off */
|
|
|
|
USHORT trg_mflag; /* modify attributes */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *DUDLEY_TRG;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* trg_modify_flag */
|
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum trg_modify_flag_vals {
|
|
|
|
trg_mflag_onoff = 1,
|
|
|
|
trg_mflag_type = 2,
|
|
|
|
trg_mflag_seqnum = 4,
|
|
|
|
trg_mflag_order = 8
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Trigger message block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct trgmsg {
|
2003-09-30 12:39:11 +02:00
|
|
|
sym* trgmsg_trg_name; /* symbol for trigger */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT trgmsg_number; /* abort code */
|
2003-09-30 12:39:11 +02:00
|
|
|
sym* trgmsg_text;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *TRGMSG;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef enum {
|
2001-05-23 15:26:42 +02:00
|
|
|
trgmsg_none = 0,
|
|
|
|
trgmsg_add = 1,
|
|
|
|
trgmsg_modify = 2,
|
|
|
|
trgmsg_drop = 3
|
2004-06-09 20:11:27 +02:00
|
|
|
} TRGMSG_T;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Text block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct txt {
|
2003-10-05 08:37:26 +02:00
|
|
|
TEXT* txt_file;
|
2001-05-23 15:26:42 +02:00
|
|
|
ULONG txt_position;
|
|
|
|
USHORT txt_length;
|
|
|
|
USHORT txt_start_line;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *TXT;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Type block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct typ {
|
2003-09-30 12:39:11 +02:00
|
|
|
sym* typ_field_name; /* field name */
|
|
|
|
sym* typ_name; /* type name */
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT typ_type; /* type value */
|
2003-09-30 12:39:11 +02:00
|
|
|
txt* typ_description; /* description of relation */
|
2004-06-09 20:11:27 +02:00
|
|
|
} *TYP;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* User privilege block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct userpriv {
|
2003-09-30 12:39:11 +02:00
|
|
|
sym* userpriv_relation;
|
2003-10-05 08:37:26 +02:00
|
|
|
struct usre* userpriv_userlist;
|
|
|
|
struct upfe* userpriv_upflist;
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT userpriv_flags;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *USERPRIV;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* user privilege flags */
|
2003-10-03 04:00:40 +02:00
|
|
|
enum userpriv_flags_vals {
|
|
|
|
USERPRIV_select = 1,
|
|
|
|
USERPRIV_delete = 2,
|
|
|
|
USERPRIV_insert = 4,
|
|
|
|
USERPRIV_update = 8,
|
|
|
|
USERPRIV_grant = 16
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* rdb$user_privilege.rdb$privilege */
|
|
|
|
|
2003-10-05 08:37:26 +02:00
|
|
|
static const char* const UPRIV_SELECT = "SELECT";
|
|
|
|
static const char* const UPRIV_DELETE = "DELETE";
|
|
|
|
static const char* const UPRIV_INSERT = "INSERT";
|
|
|
|
static const char* const UPRIV_UPDATE = "UPDATE";
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* user name entry */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct usre {
|
2003-09-30 12:39:11 +02:00
|
|
|
usre* usre_next;
|
|
|
|
sym* usre_name;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *USRE;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* update field entry */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct upfe {
|
2003-09-30 12:39:11 +02:00
|
|
|
upfe* upfe_next;
|
|
|
|
sym* upfe_fldname;
|
2004-06-09 20:11:27 +02:00
|
|
|
} *UPFE;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Data types */
|
|
|
|
|
|
|
|
#include "../jrd/dsc.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Constant block */
|
|
|
|
|
2004-06-09 20:11:27 +02:00
|
|
|
typedef struct con {
|
2003-09-30 12:39:11 +02:00
|
|
|
dsc con_desc;
|
2001-05-23 15:26:42 +02:00
|
|
|
UCHAR con_data[1];
|
2004-06-09 20:11:27 +02:00
|
|
|
} *CON;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Program globals */
|
|
|
|
|
|
|
|
typedef enum lan_t {
|
|
|
|
lan_undef,
|
|
|
|
lan_pascal,
|
|
|
|
lan_fortran,
|
|
|
|
lan_cobol,
|
|
|
|
lan_ansi_cobol,
|
|
|
|
lan_c,
|
|
|
|
lan_ada,
|
|
|
|
lan_cxx
|
|
|
|
} LAN_T;
|
|
|
|
|
2004-05-24 19:14:51 +02:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
struct DudleyGlobals {
|
|
|
|
enum lan_t language;
|
|
|
|
bool DDL_eof;
|
|
|
|
USHORT DDL_errors;
|
|
|
|
USHORT DDL_line;
|
|
|
|
bool DDL_interactive;
|
|
|
|
bool DDL_quit;
|
|
|
|
bool DDL_dynamic;
|
|
|
|
bool DDL_drop_database;
|
|
|
|
bool DDL_service;
|
|
|
|
bool DDL_replace;
|
|
|
|
bool DDL_description;
|
|
|
|
bool DDL_extract;
|
|
|
|
bool DDL_trace;
|
|
|
|
bool DDL_version;
|
2008-01-16 07:52:43 +01:00
|
|
|
#ifdef TRUSTED_AUTH
|
2007-04-07 10:47:58 +02:00
|
|
|
bool DDL_trusted;
|
2008-01-16 07:52:43 +01:00
|
|
|
#endif
|
2004-05-24 19:14:51 +02:00
|
|
|
const TEXT* DDL_prompt;
|
2004-06-05 11:37:18 +02:00
|
|
|
const TEXT* DDL_file_name;
|
2004-05-24 19:14:51 +02:00
|
|
|
TEXT DYN_file_name[256];
|
2004-11-08 04:19:22 +01:00
|
|
|
const TEXT* DB_file_name;
|
2004-05-24 19:14:51 +02:00
|
|
|
TEXT DDL_file_string[256];
|
|
|
|
TEXT DB_file_string[256];
|
2004-11-08 04:19:22 +01:00
|
|
|
const TEXT* DDL_default_user;
|
|
|
|
const TEXT* DDL_default_password;
|
2004-05-24 19:14:51 +02:00
|
|
|
ACT DDL_actions;
|
|
|
|
DBB database;
|
|
|
|
// from parse.h
|
|
|
|
tok DDL_token;
|
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-24 19:14:51 +02:00
|
|
|
extern DudleyGlobals dudleyGlob;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#include "../dudley/ddl_proto.h"
|
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
enum nod_val_pos {
|
|
|
|
s_rse_first = 0, // FIRST clause, if any
|
|
|
|
s_rse_boolean, // Boolean clause, if any
|
|
|
|
s_rse_sort, // Sort clause, if any
|
|
|
|
s_rse_reduced, // Reduced clause, if any
|
|
|
|
s_rse_contexts, // Relation block
|
|
|
|
s_rse_count,
|
|
|
|
|
|
|
|
s_stt_rse = 0,
|
|
|
|
s_stt_value,
|
|
|
|
s_stt_default,
|
|
|
|
s_stt_count,
|
|
|
|
|
|
|
|
s_fld_field = 0, // Field block
|
|
|
|
s_fld_context, // Context block
|
|
|
|
s_fld_name,
|
|
|
|
s_fld_subs,
|
|
|
|
s_fld_count,
|
|
|
|
|
|
|
|
s_if_boolean = 0,
|
|
|
|
s_if_true,
|
|
|
|
s_if_false,
|
|
|
|
|
|
|
|
s_for_rse = 0,
|
|
|
|
s_for_action,
|
|
|
|
|
|
|
|
s_store_rel = 0,
|
|
|
|
s_store_action,
|
|
|
|
|
|
|
|
s_mod_old_ctx = 0,
|
|
|
|
s_mod_new_ctx,
|
2004-05-13 11:25:24 +02:00
|
|
|
s_mod_action
|
2003-10-03 04:00:40 +02:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-03 04:00:40 +02:00
|
|
|
#endif // DUDLEY_DDL_H
|
2003-10-05 08:37:26 +02:00
|
|
|
|