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

Function init

src/yvalve/user_dsql.cpp:1104–1154  ·  view source on GitHub ↗

____________________________________________________________ Initialize dynamic SQL. This is called only once.

Source from the content-addressed store, hash-verified

1102// Initialize dynamic SQL. This is called only once.
1103//
1104static void init(FB_API_HANDLE* db_handle)
1105{
1106 // If we haven't been initialized yet, do it now
1107 if (!init_flag)
1108 {
1109 UDSQL_error = (dsql_err_stblock*) gds__alloc((SLONG) sizeof(dsql_err_stblock));
1110 // FREE: by exit cleanup()
1111 if (!UDSQL_error)
1112 {
1113 // NOMEM:
1114 return; // Don't set the init_flag
1115 }
1116 init_flag = true;
1117 gds__register_cleanup(cleanup, 0);
1118 }
1119
1120 if (!db_handle) {
1121 return;
1122 }
1123
1124 dsql_dbb* dbb;
1125
1126 { // scope
1127 Firebird::ReadLockGuard guard(global_sync, FB_FUNCTION);
1128
1129 for (dbb = databases; dbb; dbb = dbb->dbb_next)
1130 {
1131 if (dbb->dbb_handle == *db_handle) {
1132 return;
1133 }
1134 }
1135 }
1136
1137 dbb = (dsql_dbb*) gds__alloc((SLONG) sizeof(dsql_dbb));
1138
1139 // FREE: by database exit handler cleanup_database()
1140 if (!dbb)
1141 {
1142 // NOMEM
1143 return; // Not a great error handler
1144 }
1145
1146 Firebird::WriteLockGuard guard(global_sync, FB_FUNCTION);
1147
1148 dbb->dbb_next = databases;
1149 databases = dbb;
1150 dbb->dbb_handle = *db_handle;
1151
1152 ISC_STATUS_ARRAY local_status;
1153 isc_database_cleanup(local_status, db_handle, cleanup_database, NULL);
1154}
1155
1156
1157static dsql_name* insert_name(const TEXT* symbol_name, dsql_name** list_ptr, dsql_stmt* stmt)

Callers 4

INIT_DSQLFunction · 0.70
YEntryMethod · 0.70
YEntryMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected