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

Function gen_create_database

src/gpre/c_cxx.cpp:1245–1326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243//
1244
1245static void gen_create_database( const act* action, int column)
1246{
1247 const TEXT* pattern1 =
1248 "isc_create_database (%V1, %N1, \"%DF\", &%DH, %IF%S1, %S2%EL(short) 0, (char*) 0%EN, 0);";
1249 TEXT s1[32], s2[32], trname[32];
1250
1251 const gpre_req* request = ((const mdbb*) action->act_object)->mdbb_dpb_request;
1252 const gpre_dbb* db = request->req_database;
1253
1254 sprintf(s1, "isc_%dl", request->req_ident);
1255 sprintf(trname, "isc_%dt", request->req_ident);
1256
1257 if (request->req_flags & REQ_extend_dpb)
1258 {
1259 sprintf(s2, "isc_%dp", request->req_ident);
1260 if (request->req_length)
1261 printa(column, "%s = isc_%d;", s2, request->req_ident);
1262 else
1263 printa(column, "%s = (char*) 0;", s2);
1264
1265 printa(column,
1266 "isc_expand_dpb (&%s, &%s, isc_dpb_user_name, %s, isc_dpb_password, %s, isc_dpb_sql_role_name, %s, isc_dpb_lc_messages, %s, isc_dpb_lc_ctype, %s, 0);",
1267 s2, s1,
1268 db->dbb_r_user ? db->dbb_r_user : "(char*) 0",
1269 db->dbb_r_password ? db->dbb_r_password : "(char*) 0",
1270 db->dbb_r_sql_role ? db->dbb_r_sql_role : "(char*) 0",
1271 db->dbb_r_lc_messages ? db->dbb_r_lc_messages : "(char*) 0",
1272 db->dbb_r_lc_ctype ? db->dbb_r_lc_ctype : "(char*) 0");
1273 }
1274 else
1275 sprintf(s2, "isc_%d", request->req_ident);
1276
1277 PAT args;
1278 args.pat_vector1 = status_vector(action);
1279 args.pat_request = request;
1280 args.pat_database = db;
1281 args.pat_value1 = static_cast<int>(strlen(db->dbb_filename));
1282 args.pat_condition = (request->req_length || (request->req_flags & REQ_extend_dpb));
1283 args.pat_string1 = s1;
1284 args.pat_string2 = s2;
1285
1286 PATTERN_expand((USHORT) column, pattern1, &args);
1287
1288 // if the dpb was extended, free it here
1289
1290 if (request->req_flags & REQ_extend_dpb)
1291 {
1292 if (request->req_length)
1293 printa(column, "if (%s != isc_%d)", s2, request->req_ident);
1294 printa(column + (request->req_length ? INDENT : 0), "isc_free ((char*) %s);", s2);
1295
1296 // reset the length of the dpb
1297
1298 printa(column, "%s = %d;", s1, request->req_length);
1299 }
1300
1301 request = action->act_request;
1302 printa(column, "if (!%s [1])", global_status_name);

Callers 1

C_CXX_actionFunction · 0.70

Calls 7

PATTERN_expandFunction · 0.85
printaFunction · 0.70
status_vectorFunction · 0.70
beginFunction · 0.70
alignFunction · 0.70
set_sqlcodeFunction · 0.70
endpFunction · 0.70

Tested by

no test coverage detected