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

Function SQL_relation

src/gpre/sql.cpp:927–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

925//
926
927gpre_rel* SQL_relation(gpre_req* request,
928 const TEXT* rel_string,
929 const TEXT* db_string,
930 const TEXT* owner_string,
931 bool err_flag)
932{
933 if (db_string && db_string[0])
934 {
935 // a database was specified for the relation,
936 // search the known symbols for the database name
937
938 gpre_sym* symbol = MSC_find_symbol(HSH_lookup(db_string), SYM_database);
939 if (!symbol)
940 PAR_error("Unknown database specifier.");
941 if (request->req_database)
942 {
943 if ((gpre_dbb*) symbol->sym_object != request->req_database)
944 PAR_error("Inconsistent database specifier");
945 }
946 else
947 request->req_database = (gpre_dbb*) symbol->sym_object;
948 }
949
950 SCHAR s[ERROR_LENGTH];
951 gpre_rel* relation = NULL;
952
953 if (request->req_database)
954 relation = MET_get_relation(request->req_database, rel_string, owner_string);
955 else
956 {
957 // no database was specified, check the metadata for all the databases
958 // for the existence of the relation
959
960 relation = NULL; // redundant
961 for (gpre_dbb* db = gpreGlob.isc_databases; db; db = db->dbb_next)
962 {
963 gpre_rel* tmp_relation = MET_get_relation(db, rel_string, owner_string);
964 if (tmp_relation)
965 {
966 if (relation)
967 {
968 // relation was found in more than one database
969
970 sprintf(s, "TABLE %s is ambiguous", rel_string);
971 PAR_error(s);
972 }
973 else
974 {
975 relation = tmp_relation;
976 request->req_database = db;
977 }
978 }
979 }
980 }
981
982 if (!relation)
983 {
984 if (!err_flag)

Callers 5

act_deleteFunction · 0.85
act_grant_revokeFunction · 0.85
act_open_blobFunction · 0.85
act_updateFunction · 0.85
SQE_contextFunction · 0.85

Calls 4

MSC_find_symbolFunction · 0.85
HSH_lookupFunction · 0.85
MET_get_relationFunction · 0.85
PAR_errorFunction · 0.70

Tested by

no test coverage detected