~ubuntu-branches/ubuntu/karmic/firebird2.1/karmic

« back to all changes in this revision

Viewing changes to src/gpre/jrdmet.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2008-05-26 23:59:25 UTC
  • Revision ID: james.westby@ubuntu.com-20080526235925-2pnqj6nxpppoeaer
Tags: upstream-2.1.0.17798-0.ds2
ImportĀ upstreamĀ versionĀ 2.1.0.17798-0.ds2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//____________________________________________________________
 
2
//  
 
3
//              PROGRAM:        JRD Access Method
 
4
//              MODULE:         jrdmet.cpp
 
5
//              DESCRIPTION:    Non-database meta data for internal JRD stuff
 
6
//  
 
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
 
11
//  
 
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.
 
16
//  
 
17
//  The Original Code was created by Inprise Corporation
 
18
//  and its predecessors. Portions created by Inprise Corporation are
 
19
//  Copyright (C) Inprise Corporation.
 
20
//  
 
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
 
25
//  
 
26
//
 
27
//
 
28
 
 
29
#include "firebird.h"
 
30
#include "../jrd/ibase.h"
 
31
#include "../jrd/common.h"
 
32
#include "../jrd/constants.h"
 
33
#include "../jrd/ods.h"
 
34
 
 
35
#include "../gpre/gpre.h"
 
36
#define GPRE
 
37
#include "../jrd/ini.h"
 
38
#undef GPRE
 
39
#include "../gpre/hsh_proto.h"
 
40
#include "../gpre/jrdme_proto.h"
 
41
#include "../gpre/msc_proto.h"
 
42
 
 
43
 
 
44
//____________________________________________________________
 
45
//  
 
46
//              Initialize in memory meta data.
 
47
//  
 
48
 
 
49
void JRDMET_init( DBB db)
 
50
{
 
51
        const int* relfld = relfields;
 
52
 
 
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;
 
63
 
 
64
                symbol->sym_string = names[relfld[RFLD_R_NAME]];
 
65
                HSH_insert(symbol);
 
66
 
 
67
                const int* fld = relfld + RFLD_RPT;
 
68
                for (int n = 0; fld[RFLD_F_NAME]; ++n, fld += RFLD_F_LENGTH) 
 
69
                {
 
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;
 
77
                        field->fld_id = n;
 
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)
 
83
                        {
 
84
                                field->fld_dtype = dtype_cstring;
 
85
                                field->fld_flags |= FLD_text;
 
86
                                ++field->fld_length;
 
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;
 
92
                                }
 
93
                                else {
 
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;
 
98
                                }
 
99
                        }
 
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;
 
105
                        }
 
106
 
 
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]];
 
111
                        HSH_insert(symbol);
 
112
 
 
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];
 
117
                }
 
118
                relfld = fld + 1;
 
119
        }
 
120
 
 
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;
 
129
                HSH_insert(symbol);
 
130
        }
 
131
}
 
132