/*
 * 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): ______________________________________.
 */
/*
 *	This file documents InterBase Version 5.5, ODS 9.1 metadata structure.
 *
 *	See also ODS80.gdl, ODS81.gdl for respective ODS structures.  There is 
 *	specific note of the new features in this document.
 *
 *	Summary of ODS 9.1 modification:
 *		New System index RDB$INDEX_40 
 *
 *	If an ODS 9.0 DB is upgraded to ODS 9.1, INDEX RDB$INDEX_40 is created.
 *
 *	See jrd/idx.h for description of RDB$INDEX_40 in ODS 9.1
 *
 *	This file was made with hacked version of GDEF -extract, which
 *	extracted system information only.
 *	This was done by substituting all checks (DUDLEY/extract.e) for 
 *	(SYSTEM_FLAG NE 1) with (SYSTEM_FLAG EQ 1)
 *	This enabled GDEF to extract only system metadata.
 *
 *	Sorting is as follows:
 *		Global fields:		Name
 *		Relations:		Name
 *		Indices:		(RELATION_NAME, INDEX_NAME)
 *		Security Classes:	Relation created order
 *		Generators:		Name
 *		Triggers:		Name
 *
 *	Note: Sources for system triggers are missing, but many
 *	      can be found in jrd/grant.gdl.  The compiled
 *	      blr versions are in jrd/trig.h.  Note that the compiled
 *	      blr has been hand-edited in a few places.
 *
 *	Note: You can run this script by globally replacing 
 *	      "RDB$" with "XRDB$", and "SQL$" with "XSQL$" 
 *	      it will then make user relations with the specified system structure.
 *	      # gdef -r ods91.gdl
 *
 *	Note: In metadata, most, but not all, of these items have the
 *	      RDB$SYSTEM flag set to 1.
 *
 */

define database "ods_91.fdb"
	page_size 1024;


/*	Global Field Definitions	*/

define field RDB$ACL blob segment_length 80 sub_type ACL;
define field RDB$BOUND long;
define field RDB$CHARACTER_SET_ID short;
define field RDB$CHARACTER_SET_NAME char [31] sub_type 3;
define field RDB$COLLATION_ID short;
define field RDB$COLLATION_NAME char [31] sub_type 3;
define field RDB$CONSTRAINT_NAME char [31] sub_type 3;
define field RDB$CONSTRAINT_TYPE char [11];
define field RDB$CONTEXT_NAME char [31] sub_type 3;
define field RDB$DBKEY_LENGTH short;
define field RDB$DEFERRABLE char [3];
define field RDB$DESCRIPTION blob segment_length 80 sub_type text;
define field RDB$DESCRIPTOR blob segment_length 80 sub_type 6;
define field RDB$DIMENSION short;
define field RDB$DIMENSIONS short;
define field RDB$EDIT_STRING varying [125];
define field RDB$EXCEPTION_NAME char [31] sub_type 3;
define field RDB$EXCEPTION_NUMBER long;
define field RDB$EXTERNAL_DESCRIPTION blob segment_length 80 sub_type 8;
define field RDB$EXTERNAL_NAME char [31];
define field RDB$FIELD_ID short;
define field RDB$FIELD_LENGTH short;
define field RDB$FIELD_NAME char [31] sub_type 3;
define field RDB$FIELD_POSITION short;
define field RDB$FIELD_SCALE short;
define field RDB$FIELD_SUB_TYPE short;
define field RDB$FIELD_TYPE short;
define field RDB$FILE_FLAGS short;
define field RDB$FILE_LENGTH long;
define field RDB$FILE_NAME varying [253];
define field RDB$FILE_PARTITIONS short;
define field RDB$FILE_P_OFFSET long;
define field RDB$FILE_SEQUENCE short;
define field RDB$FILE_START long;
define field RDB$FORMAT short;
define field RDB$FUNCTION_NAME char [31] sub_type 3;
define field RDB$FUNCTION_TYPE short;
define field RDB$GENERATOR_ID short;
define field RDB$GENERATOR_NAME char [31] sub_type 3;
define field RDB$GENERIC_NAME char [31] sub_type 3;
define field RDB$GENERIC_TYPE short;
define field RDB$INDEX_ID short;
define field RDB$INDEX_NAME char [31] sub_type 3;
define field RDB$MATCH_OPTION char [7];
define field RDB$MECHANISM short;
define field RDB$MESSAGE varying [78];
define field RDB$MESSAGE_NUMBER short;
define field RDB$NULL_FLAG short;
define field RDB$NUMBER_OF_CHARACTERS long;
define field RDB$OBJECT_TYPE short;
define field RDB$PAGE_NUMBER long;
define field RDB$PAGE_SEQUENCE long;
define field RDB$PAGE_TYPE short;
define field RDB$PARAMETER_NAME char [31] sub_type 3;
define field RDB$PARAMETER_NUMBER short;
define field RDB$PARAMETER_TYPE short;
define field RDB$PRIVILEGE char [6];
define field RDB$PROCEDURE_BLR blob segment_length 80 sub_type BLR;
define field RDB$PROCEDURE_ID short;
define field RDB$PROCEDURE_NAME char [31] sub_type 3;
define field RDB$PROCEDURE_PARAMETERS short;
define field RDB$QUERY_HEADER blob segment_length 80 sub_type text;
define field RDB$RELATION_ID short;
define field RDB$RELATION_NAME char [31] sub_type 3;
define field RDB$RULE char [11];
define field RDB$RUNTIME blob segment_length 80 sub_type 5;
define field RDB$SECURITY_CLASS char [31] sub_type 3;
define field RDB$SEGMENT_COUNT short;
define field RDB$SEGMENT_LENGTH short;
define field RDB$SHADOW_NUMBER short;
define field RDB$SOURCE blob segment_length 80 sub_type text;
define field RDB$STATISTICS double;
define field RDB$SYSTEM_FLAG short;
define field RDB$TIMESTAMP date;
define field RDB$TRANSACTION_DESCRIPTION blob segment_length 80 sub_type 7;
define field RDB$TRANSACTION_ID long;
define field RDB$TRANSACTION_STATE short;
define field RDB$TRIGGER_BLR blob segment_length 80 sub_type BLR;
define field RDB$TRIGGER_NAME char [31] sub_type 3;
define field RDB$TRIGGER_SEQUENCE short;
define field RDB$TRIGGER_TYPE short;
define field RDB$TYPE_NAME char [31] sub_type 3;
define field RDB$USER char [31] sub_type 3;
define field RDB$VALIDATION_BLR blob segment_length 80 sub_type BLR;
define field RDB$VALUE blob segment_length 80 sub_type BLR;
define field RDB$VIEW_BLR blob segment_length 80 sub_type BLR;
define field RDB$VIEW_CONTEXT short;


/*	Relation Definitions	*/


define relation RDB$CHARACTER_SETS
    RDB$CHARACTER_SET_NAME	position 0,
    RDB$FORM_OF_USE based on RDB$GENERIC_NAME	position 1,
    RDB$NUMBER_OF_CHARACTERS	position 2,
    RDB$DEFAULT_COLLATE_NAME based on RDB$COLLATION_NAME	position 3,
    RDB$CHARACTER_SET_ID	position 4,
    RDB$SYSTEM_FLAG	position 5,
    RDB$DESCRIPTION	position 6,
    RDB$FUNCTION_NAME	position 7,
    RDB$BYTES_PER_CHARACTER based on RDB$FIELD_LENGTH	position 8;

define relation RDB$CHECK_CONSTRAINTS
    RDB$CONSTRAINT_NAME	position 0,
    RDB$TRIGGER_NAME	position 1;

define relation RDB$COLLATIONS
    RDB$COLLATION_NAME	position 0,
    RDB$COLLATION_ID	position 1,
    RDB$CHARACTER_SET_ID	position 2,
    RDB$COLLATION_ATTRIBUTES based on RDB$GENERIC_TYPE	position 3,
    RDB$SYSTEM_FLAG	position 4,
    RDB$DESCRIPTION	position 5,
    RDB$FUNCTION_NAME	position 6;

define relation RDB$DATABASE
    RDB$DESCRIPTION	position 0,
    RDB$RELATION_ID	position 1,
    RDB$SECURITY_CLASS	position 2,
    RDB$CHARACTER_SET_NAME	position 3;

define relation RDB$DEPENDENCIES
    RDB$DEPENDENT_NAME based on RDB$GENERIC_NAME	position 0,
    RDB$DEPENDED_ON_NAME based on RDB$GENERIC_NAME	position 1,
    RDB$FIELD_NAME	position 2,
    RDB$DEPENDENT_TYPE based on RDB$OBJECT_TYPE	position 3,
    RDB$DEPENDED_ON_TYPE based on RDB$OBJECT_TYPE	position 4;

define relation RDB$EXCEPTIONS
    RDB$EXCEPTION_NAME	position 0,
    RDB$EXCEPTION_NUMBER	position 1,
    RDB$MESSAGE	position 2,
    RDB$DESCRIPTION	position 3,
    RDB$SYSTEM_FLAG	position 4;

define relation RDB$FIELDS
    RDB$FIELD_NAME	position 0,
    RDB$QUERY_NAME based on RDB$FIELD_NAME	position 1,
    RDB$VALIDATION_BLR	position 2,
    RDB$VALIDATION_SOURCE based on RDB$SOURCE	position 3,
    RDB$COMPUTED_BLR based on RDB$VALUE	position 4,
    RDB$COMPUTED_SOURCE based on RDB$SOURCE	position 5,
    RDB$DEFAULT_VALUE based on RDB$VALUE	position 6,
    RDB$DEFAULT_SOURCE based on RDB$SOURCE	position 7,
    RDB$FIELD_LENGTH	position 8,
    RDB$FIELD_SCALE	position 9,
    RDB$FIELD_TYPE	position 10,
    RDB$FIELD_SUB_TYPE	position 11,
    RDB$MISSING_VALUE based on RDB$VALUE	position 12,
    RDB$MISSING_SOURCE based on RDB$SOURCE	position 13,
    RDB$DESCRIPTION	position 14,
    RDB$SYSTEM_FLAG	position 15,
    RDB$QUERY_HEADER	position 16,
    RDB$SEGMENT_LENGTH	position 17,
    RDB$EDIT_STRING	position 18,
    RDB$EXTERNAL_LENGTH based on RDB$FIELD_LENGTH	position 19,
    RDB$EXTERNAL_SCALE based on RDB$FIELD_SCALE	position 20,
    RDB$EXTERNAL_TYPE based on RDB$FIELD_TYPE	position 21,
    RDB$DIMENSIONS	position 22,
    RDB$NULL_FLAG	position 23,
    RDB$CHARACTER_LENGTH based on RDB$FIELD_LENGTH	position 24,
    RDB$COLLATION_ID	position 25,
    RDB$CHARACTER_SET_ID	position 26;

define relation RDB$FIELD_DIMENSIONS
    RDB$FIELD_NAME	position 0,
    RDB$DIMENSION	position 1,
    RDB$LOWER_BOUND based on RDB$BOUND	position 2,
    RDB$UPPER_BOUND based on RDB$BOUND	position 3;

define relation RDB$FILES
    RDB$FILE_NAME	position 0,
    RDB$FILE_SEQUENCE	position 1,
    RDB$FILE_START	position 2,
    RDB$FILE_LENGTH	position 3,
    RDB$FILE_FLAGS	position 4,
    RDB$SHADOW_NUMBER	position 5;

define relation RDB$FILTERS
    RDB$FUNCTION_NAME	position 0,
    RDB$DESCRIPTION	position 1,
    RDB$MODULE_NAME based on RDB$FILE_NAME	position 2,
    RDB$ENTRYPOINT based on RDB$EXTERNAL_NAME	position 3,
    RDB$INPUT_SUB_TYPE based on RDB$FIELD_SUB_TYPE	position 4,
    RDB$OUTPUT_SUB_TYPE based on RDB$FIELD_SUB_TYPE	position 5,
    RDB$SYSTEM_FLAG	position 6;

define relation RDB$FORMATS
    RDB$RELATION_ID	position 0,
    RDB$FORMAT	position 1,
    RDB$DESCRIPTOR	position 2;

define relation RDB$FUNCTIONS
    RDB$FUNCTION_NAME	position 0,
    RDB$FUNCTION_TYPE	position 1,
    RDB$QUERY_NAME based on RDB$FIELD_NAME	position 2,
    RDB$DESCRIPTION	position 3,
    RDB$MODULE_NAME based on RDB$FILE_NAME	position 4,
    RDB$ENTRYPOINT based on RDB$EXTERNAL_NAME	position 5,
    RDB$RETURN_ARGUMENT based on RDB$FIELD_POSITION	position 6,
    RDB$SYSTEM_FLAG	position 7;

define relation RDB$FUNCTION_ARGUMENTS
    RDB$FUNCTION_NAME	position 0,
    RDB$ARGUMENT_POSITION based on RDB$FIELD_POSITION	position 1,
    RDB$MECHANISM	position 2,
    RDB$FIELD_TYPE	position 3,
    RDB$FIELD_SCALE	position 4,
    RDB$FIELD_LENGTH	position 5,
    RDB$FIELD_SUB_TYPE	position 6,
    RDB$CHARACTER_SET_ID	position 7;

define relation RDB$GENERATORS
    RDB$GENERATOR_NAME	position 0,
    RDB$GENERATOR_ID	position 1,
    RDB$SYSTEM_FLAG	position 2;

define relation RDB$INDEX_SEGMENTS
    RDB$INDEX_NAME	position 0,
    RDB$FIELD_NAME	position 1,
    RDB$FIELD_POSITION	position 2;

define relation RDB$INDICES
    RDB$INDEX_NAME	position 0,
    RDB$RELATION_NAME	position 1,
    RDB$INDEX_ID	position 2,
    RDB$UNIQUE_FLAG based on RDB$SYSTEM_FLAG	position 3,
    RDB$DESCRIPTION	position 4,
    RDB$SEGMENT_COUNT	position 5,
    RDB$INDEX_INACTIVE based on RDB$SYSTEM_FLAG	position 6,
    RDB$INDEX_TYPE based on RDB$SYSTEM_FLAG	position 7,
    RDB$FOREIGN_KEY based on RDB$RELATION_NAME	position 8,
    RDB$SYSTEM_FLAG	position 9,
    RDB$EXPRESSION_BLR based on RDB$VALUE	position 10,
    RDB$EXPRESSION_SOURCE based on RDB$SOURCE	position 11,
    RDB$STATISTICS	position 12;

define relation RDB$LOG_FILES
    RDB$FILE_NAME	position 0,
    RDB$FILE_SEQUENCE	position 1,
    RDB$FILE_LENGTH	position 2,
    RDB$FILE_PARTITIONS	position 3,
    RDB$FILE_P_OFFSET	position 4,
    RDB$FILE_FLAGS	position 5;

define relation RDB$PAGES
    RDB$PAGE_NUMBER	position 0,
    RDB$RELATION_ID	position 1,
    RDB$PAGE_SEQUENCE	position 2,
    RDB$PAGE_TYPE	position 3;

define relation RDB$PROCEDURES
    RDB$PROCEDURE_NAME	position 0,
    RDB$PROCEDURE_ID	position 1,
    RDB$PROCEDURE_INPUTS based on RDB$PROCEDURE_PARAMETERS	position 2,
    RDB$PROCEDURE_OUTPUTS based on RDB$PROCEDURE_PARAMETERS	position 3,
    RDB$DESCRIPTION	position 4,
    RDB$PROCEDURE_SOURCE based on RDB$SOURCE	position 5,
    RDB$PROCEDURE_BLR	position 6,
    RDB$SECURITY_CLASS	position 7,
    RDB$OWNER_NAME based on RDB$USER	position 8,
    RDB$RUNTIME	position 9,
    RDB$SYSTEM_FLAG	position 10;

define relation RDB$PROCEDURE_PARAMETERS
    RDB$PARAMETER_NAME	position 0,
    RDB$PROCEDURE_NAME	position 1,
    RDB$PARAMETER_NUMBER	position 2,
    RDB$PARAMETER_TYPE	position 3,
    RDB$FIELD_SOURCE based on RDB$FIELD_NAME	position 4,
    RDB$DESCRIPTION	position 5,
    RDB$SYSTEM_FLAG	position 6;

define relation RDB$REF_CONSTRAINTS
    RDB$CONSTRAINT_NAME	position 0,
    RDB$CONST_NAME_UQ based on RDB$CONSTRAINT_NAME	position 1,
    RDB$MATCH_OPTION	position 2,
    RDB$UPDATE_RULE based on RDB$RULE	position 3,
    RDB$DELETE_RULE based on RDB$RULE	position 4;

define relation RDB$RELATIONS
    RDB$VIEW_BLR	position 0,
    RDB$VIEW_SOURCE based on RDB$SOURCE	position 1,
    RDB$DESCRIPTION	position 2,
    RDB$RELATION_ID	position 3,
    RDB$SYSTEM_FLAG	position 4,
    RDB$DBKEY_LENGTH	position 5,
    RDB$FORMAT	position 6,
    RDB$FIELD_ID	position 7,
    RDB$RELATION_NAME	position 8,
    RDB$SECURITY_CLASS	position 9,
    RDB$EXTERNAL_FILE based on RDB$FILE_NAME	position 10,
    RDB$RUNTIME	position 11,
    RDB$EXTERNAL_DESCRIPTION	position 12,
    RDB$OWNER_NAME based on RDB$USER	position 13,
    RDB$DEFAULT_CLASS based on RDB$SECURITY_CLASS	position 14,
    RDB$FLAGS based on RDB$SYSTEM_FLAG	position 15;

define relation RDB$RELATION_CONSTRAINTS
    RDB$CONSTRAINT_NAME	position 0,
    RDB$CONSTRAINT_TYPE	position 1,
    RDB$RELATION_NAME	position 2,
    RDB$DEFERRABLE	position 3,
    RDB$INITIALLY_DEFERRED based on RDB$DEFERRABLE	position 4,
    RDB$INDEX_NAME	position 5;

define relation RDB$RELATION_FIELDS
    RDB$FIELD_NAME	position 0,
    RDB$RELATION_NAME	position 1,
    RDB$FIELD_SOURCE based on RDB$FIELD_NAME	position 2,
    RDB$QUERY_NAME based on RDB$FIELD_NAME	position 3,
    RDB$BASE_FIELD based on RDB$FIELD_NAME	position 4,
    RDB$EDIT_STRING	position 5,
    RDB$FIELD_POSITION	position 6,
    RDB$QUERY_HEADER	position 7,
    RDB$UPDATE_FLAG based on RDB$SYSTEM_FLAG	position 8,
    RDB$FIELD_ID	position 9,
    RDB$VIEW_CONTEXT	position 10,
    RDB$DESCRIPTION	position 11,
    RDB$DEFAULT_VALUE based on RDB$VALUE	position 12,
    RDB$SYSTEM_FLAG	position 13,
    RDB$SECURITY_CLASS	position 14,
    RDB$COMPLEX_NAME based on RDB$FIELD_NAME	position 15,
    RDB$NULL_FLAG	position 16,
    RDB$DEFAULT_SOURCE based on RDB$SOURCE	position 17,
    RDB$COLLATION_ID	position 18;

define relation RDB$ROLES
    RDB$ROLE_NAME based on RDB$USER	position 0,
    RDB$OWNER_NAME based on RDB$USER	position 1;

define relation RDB$SECURITY_CLASSES
    RDB$SECURITY_CLASS	position 0,
    RDB$ACL	position 1,
    RDB$DESCRIPTION	position 2;

define relation RDB$TRANSACTIONS
    RDB$TRANSACTION_ID	position 0,
    RDB$TRANSACTION_STATE	position 1,
    RDB$TIMESTAMP	position 2,
    RDB$TRANSACTION_DESCRIPTION	position 3;

define relation RDB$TRIGGERS
    RDB$TRIGGER_NAME	position 0,
    RDB$RELATION_NAME	position 1,
    RDB$TRIGGER_SEQUENCE	position 2,
    RDB$TRIGGER_TYPE	position 3,
    RDB$TRIGGER_SOURCE based on RDB$SOURCE	position 4,
    RDB$TRIGGER_BLR	position 5,
    RDB$DESCRIPTION	position 6,
    RDB$TRIGGER_INACTIVE based on RDB$SYSTEM_FLAG	position 7,
    RDB$SYSTEM_FLAG	position 8,
    RDB$FLAGS based on RDB$SYSTEM_FLAG	position 9;

define relation RDB$TRIGGER_MESSAGES
    RDB$TRIGGER_NAME	position 0,
    RDB$MESSAGE_NUMBER	position 1,
    RDB$MESSAGE	position 2;

define relation RDB$TYPES
    RDB$FIELD_NAME	position 0,
    RDB$TYPE based on RDB$GENERIC_TYPE	position 1,
    RDB$TYPE_NAME	position 2,
    RDB$DESCRIPTION	position 3,
    RDB$SYSTEM_FLAG	position 4;

define relation RDB$USER_PRIVILEGES
    RDB$USER	position 0,
    RDB$GRANTOR based on RDB$USER	position 1,
    RDB$PRIVILEGE	position 2,
    RDB$GRANT_OPTION based on RDB$SYSTEM_FLAG	position 3,
    RDB$RELATION_NAME based on RDB$GENERIC_NAME	position 4,
    RDB$FIELD_NAME	position 5,
    RDB$USER_TYPE based on RDB$OBJECT_TYPE	position 6,
    RDB$OBJECT_TYPE	position 7;

define relation RDB$VIEW_RELATIONS
    RDB$VIEW_NAME based on RDB$RELATION_NAME	position 0,
    RDB$RELATION_NAME	position 1,
    RDB$VIEW_CONTEXT	position 2,
    RDB$CONTEXT_NAME	position 3;


/*	Index Definitions	*/


define index RDB$INDEX_19 for RDB$CHARACTER_SETS unique
	RDB$CHARACTER_SET_NAME;

define index RDB$INDEX_25 for RDB$CHARACTER_SETS unique
	RDB$CHARACTER_SET_ID;

define index RDB$INDEX_14 for RDB$CHECK_CONSTRAINTS 
	RDB$CONSTRAINT_NAME;

define index RDB$INDEX_40 for RDB$CHECK_CONSTRAINTS 
	RDB$TRIGGER_NAME;

define index RDB$INDEX_20 for RDB$COLLATIONS unique
	RDB$COLLATION_NAME;

define index RDB$INDEX_26 for RDB$COLLATIONS unique
	RDB$COLLATION_ID,
	RDB$CHARACTER_SET_ID;

define index RDB$INDEX_27 for RDB$DEPENDENCIES 
	RDB$DEPENDENT_NAME;

define index RDB$INDEX_28 for RDB$DEPENDENCIES 
	RDB$DEPENDED_ON_NAME;

define index RDB$INDEX_23 for RDB$EXCEPTIONS unique
	RDB$EXCEPTION_NAME;

define index RDB$INDEX_24 for RDB$EXCEPTIONS 
	RDB$EXCEPTION_NUMBER;

define index RDB$INDEX_2 for RDB$FIELDS unique
	RDB$FIELD_NAME;

define index RDB$INDEX_36 for RDB$FIELD_DIMENSIONS 
	RDB$FIELD_NAME;

define index RDB$INDEX_17 for RDB$FILTERS 
	RDB$INPUT_SUB_TYPE,
	RDB$OUTPUT_SUB_TYPE;

define index RDB$INDEX_16 for RDB$FORMATS 
	RDB$RELATION_ID,
	RDB$FORMAT;

define index RDB$INDEX_9 for RDB$FUNCTIONS unique
	RDB$FUNCTION_NAME;

define index RDB$INDEX_10 for RDB$FUNCTION_ARGUMENTS 
	RDB$FUNCTION_NAME;

define index RDB$INDEX_11 for RDB$GENERATORS unique
	RDB$GENERATOR_NAME;

define index RDB$INDEX_6 for RDB$INDEX_SEGMENTS 
	RDB$INDEX_NAME;

define index RDB$INDEX_31 for RDB$INDICES 
	RDB$RELATION_NAME;

define index RDB$INDEX_5 for RDB$INDICES unique
	RDB$INDEX_NAME;

define index RDB$INDEX_21 for RDB$PROCEDURES unique
	RDB$PROCEDURE_NAME;

define index RDB$INDEX_22 for RDB$PROCEDURES 
	RDB$PROCEDURE_ID;

define index RDB$INDEX_18 for RDB$PROCEDURE_PARAMETERS unique
	RDB$PROCEDURE_NAME,
	RDB$PARAMETER_NAME;

define index RDB$INDEX_13 for RDB$REF_CONSTRAINTS unique
	RDB$CONSTRAINT_NAME;

define index RDB$INDEX_0 for RDB$RELATIONS unique
	RDB$RELATION_NAME;

define index RDB$INDEX_1 for RDB$RELATIONS 
	RDB$RELATION_ID;

define index RDB$INDEX_12 for RDB$RELATION_CONSTRAINTS unique
	RDB$CONSTRAINT_NAME;

define index RDB$INDEX_15 for RDB$RELATION_FIELDS unique
	RDB$FIELD_NAME,
	RDB$RELATION_NAME;

define index RDB$INDEX_3 for RDB$RELATION_FIELDS 
	RDB$FIELD_SOURCE;

define index RDB$INDEX_4 for RDB$RELATION_FIELDS 
	RDB$RELATION_NAME;

define index RDB$INDEX_39 for RDB$ROLES unique
	RDB$ROLE_NAME;

define index RDB$INDEX_7 for RDB$SECURITY_CLASSES unique
	RDB$SECURITY_CLASS;

define index RDB$INDEX_32 for RDB$TRANSACTIONS unique
	RDB$TRANSACTION_ID;

define index RDB$INDEX_38 for RDB$TRIGGERS 
	RDB$RELATION_NAME;

define index RDB$INDEX_8 for RDB$TRIGGERS unique
	RDB$TRIGGER_NAME;

define index RDB$INDEX_35 for RDB$TRIGGER_MESSAGES 
	RDB$TRIGGER_NAME;

define index RDB$INDEX_37 for RDB$TYPES 
	RDB$TYPE_NAME;

define index RDB$INDEX_29 for RDB$USER_PRIVILEGES 
	RDB$RELATION_NAME;

define index RDB$INDEX_30 for RDB$USER_PRIVILEGES 
	RDB$USER;

define index RDB$INDEX_33 for RDB$VIEW_RELATIONS 
	RDB$VIEW_NAME;

define index RDB$INDEX_34 for RDB$VIEW_RELATIONS 
	RDB$RELATION_NAME;

/*	Add Security Classes to Defined Objects	*/



modify relation RDB$ROLES
	security_class SQL$RDB$ROLES;


/*	Security Class Definitions / GRANT statements	*/


grant SELECT on RDB$ROLES to PUBLIC;

grant DELETE on RDB$ROLES to SYSDBA with grant option;

grant INSERT on RDB$ROLES to SYSDBA with grant option;

grant SELECT on RDB$ROLES to SYSDBA with grant option;

grant UPDATE on RDB$ROLES to SYSDBA with grant option;


/*	Generator Definitions	*/


define generator RDB$CONSTRAINT_NAME;
define generator RDB$EXCEPTIONS;
define generator RDB$FIELD_NAME;
define generator RDB$INDEX_NAME;
define generator RDB$PROCEDURES;
define generator RDB$SECURITY_CLASS;
define generator RDB$TRIGGER_NAME;
define generator SQL$DEFAULT;

/*	Trigger Definitions	*/



define trigger RDB$TRIGGER_1 for RDB$USER_PRIVILEGES
	pre modify 0:

	end_trigger 
	message  0:  'existing_priv_mod                                                             ';

define trigger RDB$TRIGGER_10 for RDB$RELATION_CONSTRAINTS
	pre erase 0:

	end_trigger 
	message  1:  'primary_key_ref                                                               ',
	message  2:  'primary_key_notnull                                                           ';

define trigger RDB$TRIGGER_11 for RDB$RELATION_CONSTRAINTS
	post erase 0:

	end_trigger;

define trigger RDB$TRIGGER_12 for RDB$REF_CONSTRAINTS
	pre store 0:

	end_trigger 
	message  1:  'ref_cnstrnt_notfound                                                          ',
	message  2:  'foreign_key_notfound                                                          ';

define trigger RDB$TRIGGER_13 for RDB$REF_CONSTRAINTS
	pre modify 0:

	end_trigger 
	message  1:  'ref_cnstrnt_update                                                            ';

define trigger RDB$TRIGGER_14 for RDB$CHECK_CONSTRAINTS
	pre modify 0:

	end_trigger 
	message  1:  'check_cnstrnt_update                                                          ';

define trigger RDB$TRIGGER_15 for RDB$CHECK_CONSTRAINTS
	pre erase 0:

	end_trigger 
	message  1:  'check_cnstrnt_del                                                             ';

define trigger RDB$TRIGGER_16 for RDB$CHECK_CONSTRAINTS
	post erase 0:

	end_trigger;

define trigger RDB$TRIGGER_17 for RDB$INDEX_SEGMENTS
	pre erase 0:

	end_trigger 
	message  1:  'integ_index_seg_del                                                           ';

define trigger RDB$TRIGGER_18 for RDB$INDEX_SEGMENTS
	pre modify 0:

	end_trigger 
	message  1:  'integ_index_seg_mod                                                           ';

define trigger RDB$TRIGGER_19 for RDB$INDICES
	pre erase 0:

	end_trigger 
	message  1:  'integ_index_del                                                               ';

define trigger RDB$TRIGGER_2 for RDB$TRIGGERS
	pre modify 0:

	end_trigger 
	message  0:  'systrig_update                                                                ';

define trigger RDB$TRIGGER_20 for RDB$INDICES
	pre modify 0:

	end_trigger 
	message  1:  'integ_index_mod                                                               ',
	message  2:  'integ_index_deactivate                                                        ',
	message  3:  'integ_deactivate_primary                                                      ';

define trigger RDB$TRIGGER_21 for RDB$TRIGGERS
	pre erase 0:

	end_trigger 
	message  1:  'check_trig_del                                                                ';

define trigger RDB$TRIGGER_22 for RDB$TRIGGERS
	pre modify 0:

	end_trigger 
	message  1:  'check_trig_update                                                             ';

define trigger RDB$TRIGGER_23 for RDB$RELATION_FIELDS
	pre erase 0:

	end_trigger 
	message  1:  'cnstrnt_fld_del                                                               ';

define trigger RDB$TRIGGER_24 for RDB$RELATION_FIELDS
	pre modify 0:

	end_trigger 
	message  1:  'cnstrnt_fld_rename                                                            ';

define trigger RDB$TRIGGER_25 for RDB$RELATION_CONSTRAINTS
	pre modify 0:

	end_trigger 
	message  1:  'rel_cnstrnt_update                                                            ';

define trigger RDB$TRIGGER_26 for RDB$RELATION_CONSTRAINTS
	pre store 0:

	end_trigger 
	message  1:  'constaint_on_view                                                             ',
	message  2:  'invld_cnstrnt_type                                                            ',
	message  3:  'primary_key_exists                                                            ';

define trigger RDB$TRIGGER_27 for RDB$RELATION_FIELDS
	post erase 0:

	end_trigger;

define trigger RDB$TRIGGER_28 for RDB$PROCEDURES
	pre store 0:

	end_trigger;

define trigger RDB$TRIGGER_29 for RDB$PROCEDURES
	pre modify 0:

	end_trigger;

define trigger RDB$TRIGGER_3 for RDB$TRIGGERS
	pre erase 0:

	end_trigger 
	message  0:  'systrig_update                                                                ';

define trigger RDB$TRIGGER_30 for RDB$EXCEPTIONS
	pre store 0:

	end_trigger;

define trigger RDB$TRIGGER_31 for RDB$USER_PRIVILEGES
	pre modify 0:

	end_trigger 
	message  0:  'no_write_user_priv                                                            ';

define trigger RDB$TRIGGER_32 for RDB$USER_PRIVILEGES
	pre erase 0:

	end_trigger 
	message  0:  'no_write_user_priv                                                            ';

define trigger RDB$TRIGGER_33 for RDB$USER_PRIVILEGES
	pre store 0:

	end_trigger 
	message  0:  'no_write_user_priv                                                            ';

define trigger RDB$TRIGGER_34 for RDB$RELATION_CONSTRAINTS
	post erase 0:

	end_trigger;

define trigger RDB$TRIGGER_35 for RDB$CHECK_CONSTRAINTS
	post erase 0:

	end_trigger;

define trigger RDB$TRIGGER_4 for RDB$RELATIONS
	pre store 0:

	end_trigger;

define trigger RDB$TRIGGER_5 for RDB$RELATIONS
	pre modify 0:

	end_trigger 
	message  0:  'not_rel_owner                                                                 ';

define trigger RDB$TRIGGER_6 for RDB$GENERATORS
	pre store 0:

	end_trigger;

define trigger RDB$TRIGGER_8 for RDB$USER_PRIVILEGES
	pre erase 0:

	end_trigger;

define trigger RDB$TRIGGER_9 for RDB$USER_PRIVILEGES
	pre store 0:

	end_trigger 
	message  0:  'grant_obj_notfound                                                            ',
	message  1:  'grant_fld_notfound                                                            ',
	message  2:  'grant_nopriv                                                                  ',
	message  3:  'nonsql_security_rel                                                           ',
	message  4:  'nonsql_security_fld                                                           ',
	message  5:  'grant_nopriv_on_base                                                          ';
