1
//____________________________________________________________
3
// PROGRAM: JRD Access Method
5
// DESCRIPTION: Non-database meta data for internal JRD stuff
7
// The contents of this file are subject to the Interbase Public
8
// License Version 1.0 (the "License"); you may not use this file
9
// except in compliance with the License. You may obtain a copy
10
// of the License at http://www.Inprise.com/IPL.html
12
// Software distributed under the License is distributed on an
13
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
14
// or implied. See the License for the specific language governing
15
// rights and limitations under the License.
17
// The Original Code was created by Inprise Corporation
18
// and its predecessors. Portions created by Inprise Corporation are
19
// Copyright (C) Inprise Corporation.
21
// All Rights Reserved.
22
// Contributor(s): ______________________________________.
23
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
24
// There however is still a bunch of constness errors in this file
30
#include "../jrd/ibase.h"
31
#include "../jrd/common.h"
32
#include "../jrd/constants.h"
33
#include "../jrd/ods.h"
35
#include "../gpre/gpre.h"
37
#include "../jrd/ini.h"
39
#include "../gpre/hsh_proto.h"
40
#include "../gpre/jrdme_proto.h"
41
#include "../gpre/msc_proto.h"
44
//____________________________________________________________
46
// Initialize in memory meta data.
49
void JRDMET_init( DBB db)
51
const int* relfld = relfields;
53
while (relfld[RFLD_R_NAME]) {
54
gpre_rel* relation = (gpre_rel*) MSC_alloc(REL_LEN);
55
relation->rel_database = db;
56
relation->rel_next = db->dbb_relations;
57
relation->rel_id = relfld[RFLD_R_ID];
58
db->dbb_relations = relation;
59
gpre_sym* symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
60
relation->rel_symbol = symbol;
61
symbol->sym_type = SYM_relation;
62
symbol->sym_object = (gpre_ctx*) relation;
64
symbol->sym_string = names[relfld[RFLD_R_NAME]];
67
const int* fld = relfld + RFLD_RPT;
68
for (int n = 0; fld[RFLD_F_NAME]; ++n, fld += RFLD_F_LENGTH)
70
const gfld* gfield = (fld[RFLD_F_UPD_MINOR]) ?
71
&gfields[fld[RFLD_F_UPD_ID]] :
72
&gfields[fld[RFLD_F_ID]];
73
gpre_fld* field = (gpre_fld*) MSC_alloc(FLD_LEN);
74
relation->rel_fields = field;
75
field->fld_relation = relation;
76
field->fld_next = relation->rel_fields;
78
field->fld_length = gfield->gfld_length;
79
field->fld_dtype = gfield->gfld_dtype;
80
field->fld_sub_type = gfield->gfld_sub_type;
81
if (field->fld_dtype == dtype_varying ||
82
field->fld_dtype == dtype_text)
84
field->fld_dtype = dtype_cstring;
85
field->fld_flags |= FLD_text;
87
if (gfield->gfld_sub_type == dsc_text_type_metadata) {
88
field->fld_flags |= FLD_charset;
89
field->fld_charset_id = CS_METADATA;
90
field->fld_collate_id = COLLATE_NONE;
91
field->fld_ttype = ttype_metadata;
94
field->fld_flags |= FLD_charset;
95
field->fld_charset_id = CS_NONE;
96
field->fld_collate_id = COLLATE_NONE;
97
field->fld_ttype = ttype_none;
100
else if (field->fld_dtype == dtype_blob) {
101
field->fld_dtype = dtype_blob;
102
field->fld_flags |= FLD_blob;
103
if (gfield->gfld_sub_type == isc_blob_text)
104
field->fld_charset_id = CS_METADATA;
107
field->fld_symbol = symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
108
symbol->sym_type = SYM_field;
109
symbol->sym_object = (gpre_ctx*) field;
110
symbol->sym_string = names[fld[RFLD_F_NAME]];
113
field->fld_global = symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
114
symbol->sym_type = SYM_field;
115
symbol->sym_object = (gpre_ctx*) field;
116
symbol->sym_string = names[gfield->gfld_name];
121
for (const rtyp* rtype = types; rtype->rtyp_name; rtype++) {
122
field_type* type = (field_type*) MSC_alloc(TYP_LEN);
123
gpre_sym* symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
124
type->typ_symbol = symbol;
125
type->typ_value = rtype->rtyp_value;
126
symbol->sym_type = SYM_type;
127
symbol->sym_object = (gpre_ctx*) type;
128
symbol->sym_string = rtype->rtyp_name;