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

Function SQL_procedure

src/gpre/sql.cpp:850–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

848//
849
850gpre_prc* SQL_procedure(gpre_req* request,
851 const TEXT* prc_string,
852 const TEXT* db_string,
853 const TEXT* owner_string,
854 bool err_flag)
855{
856 SCHAR s[ERROR_LENGTH];
857
858 if (db_string && db_string[0])
859 {
860 // a database was specified for the procedure
861 // search the known symbols for the database name
862
863 gpre_sym* symbol = MSC_find_symbol(HSH_lookup(db_string), SYM_database);
864 if (!symbol)
865 PAR_error("Unknown database specifier.");
866 if (request->req_database)
867 {
868 if ((gpre_dbb*) symbol->sym_object != request->req_database)
869 PAR_error("Inconsistent database specifier");
870 }
871 else
872 request->req_database = (gpre_dbb*) symbol->sym_object;
873 }
874
875 gpre_prc* procedure = NULL;
876
877 if (request->req_database)
878 procedure = MET_get_procedure(request->req_database, prc_string, owner_string);
879 else
880 {
881 // no database was specified, check the metadata for all the databases
882 // for the existence of the procedure
883
884 procedure = NULL; // redundant
885 for (gpre_dbb* db = gpreGlob.isc_databases; db; db = db->dbb_next)
886 {
887 gpre_prc* tmp_procedure = MET_get_procedure(db, prc_string, owner_string);
888 if (tmp_procedure)
889 {
890 if (procedure)
891 {
892 // relation was found in more than one database
893
894 sprintf(s, "PROCEDURE %s is ambiguous", prc_string);
895 PAR_error(s);
896 }
897 else
898 {
899 procedure = tmp_procedure;
900 request->req_database = db;
901 }
902 }
903 }
904 }
905
906 if (!procedure)
907 {

Callers 3

act_grant_revokeFunction · 0.85
act_procedureFunction · 0.85
SQE_contextFunction · 0.85

Calls 4

MSC_find_symbolFunction · 0.85
HSH_lookupFunction · 0.85
MET_get_procedureFunction · 0.85
PAR_errorFunction · 0.70

Tested by

no test coverage detected