~ubuntu-branches/ubuntu/oneiric/firebird2.5/oneiric-security

« back to all changes in this revision

Viewing changes to src/jrd/met.epp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-07-27 18:12:34 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100727181234-88lvl2nuord9ysx5
Tags: 2.5.0.26054~ReleaseCandidate3.ds2-1
* New upstream release candidate

* update d/copyright to reflect changes in upstream sources
* drop patches applied/implemented upstream
  + refresh the rest to apply cleanly
* Standards-Version: 3.9.1 (no changes necessary)

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
static void lookup_view_contexts(thread_db*, jrd_rel*);
116
116
static void make_relation_scope_name(const TEXT*, const USHORT, Firebird::string& str);
117
117
static jrd_nod* parse_field_blr(thread_db* tdbb, bid* blob_id, const Firebird::MetaName name = Firebird::MetaName());
118
 
static jrd_nod* parse_param_blr(thread_db*, jrd_prc*, bid*, CompilerScratch*);
119
118
static jrd_nod* parse_procedure_blr(thread_db*, jrd_prc*, bid*, CompilerScratch*);
120
119
static void par_messages(thread_db*, const UCHAR* const, USHORT, jrd_prc*, CompilerScratch*);
121
120
static bool resolve_charset_and_collation(thread_db*, USHORT*, const UCHAR*, const UCHAR*);
2684
2683
 
2685
2684
/* System relations are above suspicion */
2686
2685
 
2687
 
        if (id < (int) rel_MAX)
 
2686
        if (id <= (int) dbb->dbb_max_sys_rel)
2688
2687
        {
2689
2688
                fb_assert(id < MAX_USHORT);
2690
2689
                return MET_relation(tdbb, (USHORT) id);
3165
3164
                                         (fb_utils::implicit_domain(F.RDB$FIELD_NAME) && !F.RDB$DEFAULT_VALUE.NULL)))
3166
3165
                                {
3167
3166
                                        procedure->prc_defaults++;
3168
 
                                        Jrd::ContextPoolHolder context(tdbb, dbb->createPool());
3169
 
                                        CompilerScratch* csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5);
3170
 
 
3171
 
                                        if (!pa_default_value_null)
3172
 
                                        {
3173
 
                                                parameter->prm_default_value =
3174
 
                                                        parse_param_blr(tdbb, procedure, &pa_default_value, csb);
3175
 
                                        }
3176
 
                                        else
3177
 
                                        {
3178
 
                                                parameter->prm_default_value =
3179
 
                                                        parse_param_blr(tdbb, procedure, &F.RDB$DEFAULT_VALUE, csb);
3180
 
                                        }
3181
 
 
3182
 
                                        delete csb;
 
3167
                                        MemoryPool* pool = dbb->createPool();
 
3168
                                        Jrd::ContextPoolHolder context(tdbb, pool);
 
3169
 
 
3170
                                        if (pa_default_value_null)
 
3171
                                                pa_default_value = F.RDB$DEFAULT_VALUE;
 
3172
        
 
3173
                                        try
 
3174
                                        {
 
3175
                                                parameter->prm_default_value =
 
3176
                                                        MET_parse_blob(tdbb, NULL, &pa_default_value, NULL, NULL, false);
 
3177
                                        }
 
3178
                                        catch(const Exception&)
 
3179
                                        {
 
3180
                                                // Here we lose pools created for previous defaults.
 
3181
                                                // Probably we should use common pool for defaults and procedure itself.
 
3182
 
 
3183
                                                dbb->deletePool(pool);
 
3184
                                                throw;
 
3185
                                        }
3183
3186
                                }
3184
3187
 
3185
3188
                        END_FOR;
3372
3375
                return relation;
3373
3376
        }
3374
3377
 
3375
 
        const USHORT major_version = dbb->dbb_ods_version;
3376
 
        const USHORT minor_original = dbb->dbb_minor_original;
3377
 
 
3378
 
/* From ODS 9 onwards, the first 128 relation IDS have been
3379
 
   reserved for system relations */
3380
 
        USHORT max_sys_rel;
3381
 
        if (ENCODE_ODS(major_version, minor_original) < ODS_9_0) {
3382
 
                max_sys_rel = USER_REL_INIT_ID_ODS8 - 1;
3383
 
        }
3384
 
        else {
3385
 
                max_sys_rel = USER_DEF_REL_INIT_ID - 1;
3386
 
        }
3387
 
 
3388
3378
        relation = FB_NEW(*dbb->dbb_permanent) jrd_rel(*dbb->dbb_permanent);
3389
3379
        (*vector)[id] = relation;
3390
3380
        relation->rel_id = id;
3403
3393
        }
3404
3394
 
3405
3395
        // This should check system flag instead.
3406
 
        if (relation->rel_id <= max_sys_rel) {
 
3396
        if (relation->rel_id <= dbb->dbb_max_sys_rel) {
3407
3397
                return relation;
3408
3398
        }
3409
3399
 
4509
4499
}
4510
4500
 
4511
4501
 
4512
 
static jrd_nod* parse_param_blr(thread_db* tdbb,
4513
 
                jrd_prc* procedure, bid* blob_id, CompilerScratch* csb)
4514
 
{
4515
 
        SET_TDBB(tdbb);
4516
 
        Database* dbb = tdbb->getDatabase();
4517
 
 
4518
 
        blb* blob = BLB_open(tdbb, dbb->dbb_sys_trans, blob_id);
4519
 
        SLONG length = blob->blb_length + 10;
4520
 
        Firebird::HalfStaticArray<UCHAR, 512> temp;
4521
 
 
4522
 
        length = BLB_get_data(tdbb, blob, temp.getBuffer(length), length);
4523
 
 
4524
 
        jrd_nod* node = PAR_blr(tdbb, NULL, temp.begin(), length, NULL, &csb,
4525
 
                &procedure->prc_request, false, 0);
4526
 
        csb->csb_blr_reader = BlrReader();
4527
 
 
4528
 
        return node;
4529
 
}
4530
 
 
4531
4502
static jrd_nod* parse_procedure_blr(thread_db* tdbb,
4532
4503
                                                                        jrd_prc* procedure,
4533
4504
                                                                        bid* blob_id,