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

Function par_alias_list

src/gpre/sqe.cpp:1697–1792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1695//
1696
1697static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list)
1698{
1699 assert_IS_REQ(request);
1700 assert_IS_NOD(alias_list);
1701
1702 gpre_nod** arg = alias_list->nod_arg;
1703 const gpre_nod* const* const end = alias_list->nod_arg + alias_list->nod_count;
1704
1705 // check the first alias in the list with the relations
1706 // in the current context for a match
1707
1708 gpre_rel* relation = 0; // unreliable test many lines below without initializing.
1709 gpre_ctx* context = par_alias(request, (const TEXT*) *arg);
1710 if (context)
1711 {
1712 if (alias_list->nod_count == 1)
1713 return context;
1714 relation = context->ctx_relation;
1715 }
1716
1717 SCHAR error_string[ERROR_LENGTH];
1718
1719 // if the first alias didn't specify a table in the context stack,
1720 // look through all contexts to find one which might be a view with
1721 // a base table having a matching table name or alias
1722
1723 if (!context)
1724 {
1725 for (context = request->req_contexts; context; context = context->ctx_next)
1726 {
1727 if (context->ctx_scope_level != request->req_scope_level)
1728 continue;
1729 if (!context->ctx_relation)
1730 continue;
1731 if (relation = par_base_table(request, context->ctx_relation, (const TEXT*) *arg))
1732 {
1733 break;
1734 }
1735 }
1736 }
1737
1738 if (!context)
1739 {
1740 fb_utils::snprintf(error_string, sizeof(error_string),
1741 "there is no alias or table named %s at this scope level",
1742 (TEXT*) *arg);
1743 PAR_error(error_string);
1744 }
1745
1746 // find the base table using the specified alias list, skipping the first one
1747 // since we already matched it to the context
1748
1749 for (arg++; arg < end; arg++)
1750 {
1751 if (!(relation = par_base_table(request, relation, (const TEXT*) *arg)))
1752 break;
1753 }
1754

Callers 1

par_plan_itemFunction · 0.85

Calls 5

par_aliasFunction · 0.85
par_base_tableFunction · 0.85
MSC_allocFunction · 0.85
PAR_errorFunction · 0.70
snprintfFunction · 0.50

Tested by

no test coverage detected