MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / dsqlPassAliasList

Method dsqlPassAliasList

src/jrd/RecordSourceNodes.cpp:418–521  ·  view source on GitHub ↗

The passed alias list fully specifies a relation. The first alias represents a relation specified in the from list at this scope levels. Subsequent contexts, if there are any, represent base relations in a view stack. They are used to fully specify a base relation of a view. The aliases used in the view stack are those used in the view definition.

Source from the content-addressed store, hash-verified

416// represent base relations in a view stack. They are used to fully specify a base relation of
417// a view. The aliases used in the view stack are those used in the view definition.
418dsql_ctx* PlanNode::dsqlPassAliasList(DsqlCompilerScratch* dsqlScratch)
419{
420 DEV_BLKCHK(dsqlScratch, dsql_type_req);
421
422 ObjectsArray<MetaName>::iterator arg = dsqlNames->begin();
423 ObjectsArray<MetaName>::iterator end = dsqlNames->end();
424
425 // Loop through every alias and find the context for that alias.
426 // All aliases should have a corresponding context.
427 int aliasCount = dsqlNames->getCount();
428 USHORT savedScopeLevel = dsqlScratch->scopeLevel;
429 dsql_ctx* context = NULL;
430 while (aliasCount > 0)
431 {
432 if (context)
433 {
434 if (context->ctx_rse && !context->ctx_relation && !context->ctx_procedure)
435 {
436 // Derived table
437 dsqlScratch->scopeLevel++;
438 context = dsqlPassAlias(dsqlScratch, context->ctx_childs_derived_table, *arg);
439 }
440 else if (context->ctx_relation)
441 {
442 // This must be a VIEW
443 ObjectsArray<MetaName>::iterator startArg = arg;
444 dsql_rel* viewRelation = context->ctx_relation;
445
446 dsql_rel* relation = nullptr;
447 dsql_prc* procedure = nullptr;
448
449 // find the base table using the specified alias list, skipping the first one
450 // since we already matched it to the context.
451 for (; arg != end; ++arg)
452 {
453 if (!METD_get_view_relation(dsqlScratch->getTransaction(),
454 dsqlScratch, viewRelation->rel_name, *arg,
455 relation, procedure))
456 {
457 break;
458 };
459
460 --aliasCount;
461
462 if (!relation)
463 break;
464 }
465
466 // Found base relation
467 if (aliasCount == 0 && (relation || procedure))
468 {
469 // AB: Pretty ugly huh?
470 // make up a dummy context to hold the resultant relation.
471 dsql_ctx* newContext = FB_NEW_POOL(dsqlScratch->getPool()) dsql_ctx(dsqlScratch->getPool());
472 newContext->ctx_context = context->ctx_context;
473 newContext->ctx_relation = relation;
474 newContext->ctx_procedure = procedure;
475

Callers

nothing calls this directly

Calls 12

ERRD_postFunction · 0.85
GdsClass · 0.85
NumClass · 0.85
dsql_ctxClass · 0.50
beginMethod · 0.45
endMethod · 0.45
getCountMethod · 0.45
getTransactionMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45
appendMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected