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

Function finish_based

src/gpre/gpre.cpp:1447–1563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1445//
1446
1447static void finish_based( act* action)
1448{
1449 gpre_rel* relation = NULL;
1450 gpre_fld* field = NULL;
1451 TEXT s[MAXPATHLEN << 1];
1452
1453 for (; action; action = action->act_rest)
1454 {
1455 if (action->act_type != ACT_basedon)
1456 continue;
1457
1458 // If there are no databases either on the command line or in
1459 // this subroutine or main program, can't do a BASED_ON.
1460
1461 if (!gpreGlob.isc_databases)
1462 {
1463 CPR_error("No database defined. Needed for a BASED_ON operation");
1464 continue;
1465 }
1466
1467 bas* based_on = (bas*) action->act_object;
1468 if (!based_on->bas_fld_name)
1469 continue;
1470
1471 gpre_dbb* db = NULL;
1472 if (based_on->bas_db_name)
1473 {
1474 gpre_sym* symbol = HSH_lookup(based_on->bas_db_name->str_string);
1475 for (; symbol; symbol = symbol->sym_homonym)
1476 {
1477 if (symbol->sym_type == SYM_database)
1478 break;
1479 }
1480
1481 if (symbol)
1482 {
1483 db = (gpre_dbb*) symbol->sym_object;
1484 relation = MET_get_relation(db, based_on->bas_rel_name->str_string, "");
1485 if (!relation)
1486 {
1487 fb_utils::snprintf(s, sizeof(s), "relation %s is not defined in database %s",
1488 based_on->bas_rel_name->str_string, based_on->bas_db_name->str_string);
1489 CPR_error(s);
1490 continue;
1491 }
1492 field = MET_field(relation, based_on->bas_fld_name->str_string);
1493 }
1494 else
1495 {
1496 if (based_on->bas_flags & BAS_ambiguous)
1497 {
1498 // The reference could have been DB.RELATION.FIELD or
1499 // RELATION.FIELD.SEGMENT. It's not the former. Try
1500 // the latter.
1501
1502 based_on->bas_fld_name = based_on->bas_rel_name;
1503 based_on->bas_rel_name = based_on->bas_db_name;
1504 based_on->bas_db_name = NULL;

Callers 1

compile_moduleFunction · 0.85

Calls 5

CPR_errorFunction · 0.85
HSH_lookupFunction · 0.85
MET_get_relationFunction · 0.85
MET_fieldFunction · 0.85
snprintfFunction · 0.50

Tested by

no test coverage detected