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

Function t_start_auto

src/gpre/languages/cob.cpp:4181–4256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4179//
4180
4181static void t_start_auto(const gpre_req* request,
4182 const TEXT* vector,
4183 const act* action,
4184 bool test)
4185{
4186 TEXT dbname[80], buffer[256], temp[MAX_CURSOR_SIZE + 10];
4187
4188 const TEXT* trname = request_trans(action, request);
4189
4190 // find out whether we're using a status vector or not
4191
4192 const bool stat = !strcmp(vector, names[isc_status_vector_pos]);
4193
4194 // this is a default transaction, make sure all databases are ready
4195
4196 const gpre_dbb* db;
4197 int count;
4198
4199 if (gpreGlob.sw_auto)
4200 {
4201 buffer[0] = 0;
4202 for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++)
4203 {
4204 const TEXT* filename = db->dbb_runtime;
4205 if (filename || !(db->dbb_flags & DBB_sqlca))
4206 {
4207 fprintf(gpreGlob.out_file, "%sIF %s = 0", names[COLUMN], db->dbb_name->sym_string);
4208 if (stat && buffer[0])
4209 fprintf(gpreGlob.out_file, " AND %s(2) = 0", names[isc_status_pos]);
4210 fprintf(gpreGlob.out_file, " THEN\n");
4211 const USHORT namelength = static_cast<USHORT>(filename ? strlen(filename) : 0);
4212 if (filename)
4213 {
4214 sprintf(dbname, "%s%ddb", names[isc_b_pos], db->dbb_id);
4215 filename = dbname;
4216 }
4217 make_ready(db, filename, vector, 0, namelength);
4218 printa(names[COLUMN], false, "END-IF");
4219 if (buffer[0])
4220 strcat(buffer, ") AND (");
4221 fb_utils::snprintf(temp, sizeof(temp), "%s NOT = 0", db->dbb_name->sym_string);
4222 strcat(buffer, temp);
4223 }
4224 }
4225 fb_assert(strlen(buffer) < sizeof(buffer));
4226 if (test)
4227 {
4228 if (buffer[0])
4229 printa(names[COLUMN], false, "IF (%s) AND %s = 0 THEN", buffer, trname);
4230 else
4231 printa(names[COLUMN], false, "IF %s = 0 THEN", trname);
4232 }
4233 else if (buffer[0])
4234 printa(names[COLUMN], false, "IF (%s) THEN", buffer);
4235 }
4236 else
4237 for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++);
4238

Callers 9

gen_blob_openFunction · 0.70
gen_compileFunction · 0.70
gen_ddlFunction · 0.70
gen_dyn_executeFunction · 0.70
gen_dyn_immediateFunction · 0.70
gen_dyn_openFunction · 0.70
gen_dyn_prepareFunction · 0.70
gen_procedureFunction · 0.70
gen_t_startFunction · 0.70

Calls 5

request_transFunction · 0.70
make_readyFunction · 0.70
printaFunction · 0.70
set_sqlcodeFunction · 0.70
snprintfFunction · 0.50

Tested by

no test coverage detected