| 3946 | // |
| 3947 | |
| 3948 | static void t_start_auto(const act* action, |
| 3949 | const gpre_req* request, |
| 3950 | const TEXT* vector, |
| 3951 | int column, |
| 3952 | bool test) |
| 3953 | { |
| 3954 | const TEXT* trname = request_trans(action, request); |
| 3955 | |
| 3956 | // find out whether we're using a status vector or not |
| 3957 | |
| 3958 | const int stat = !strcmp(vector, global_status_name); |
| 3959 | |
| 3960 | // this is a default transaction, make sure all databases are ready |
| 3961 | |
| 3962 | begin(column); |
| 3963 | |
| 3964 | const gpre_dbb* db; |
| 3965 | int count; |
| 3966 | |
| 3967 | if (gpreGlob.sw_auto) |
| 3968 | { |
| 3969 | TEXT buffer[256]; |
| 3970 | buffer[0] = 0; |
| 3971 | for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++) |
| 3972 | { |
| 3973 | const TEXT* filename = db->dbb_runtime; |
| 3974 | if (filename || !(db->dbb_flags & DBB_sqlca)) |
| 3975 | { |
| 3976 | align(column); |
| 3977 | fprintf(gpreGlob.out_file, "if (!%s", db->dbb_name->sym_string); |
| 3978 | if (stat && buffer[0]) |
| 3979 | fprintf(gpreGlob.out_file, " && !(%s->getState() & Firebird::IStatus::STATE_ERRORS)", vector); |
| 3980 | fprintf(gpreGlob.out_file, ")"); |
| 3981 | make_ready(db, filename, vector, (USHORT) (column + INDENT), 0); |
| 3982 | if (buffer[0]) |
| 3983 | strcat(buffer, " && "); |
| 3984 | strcat(buffer, db->dbb_name->sym_string); |
| 3985 | } |
| 3986 | } |
| 3987 | if (!buffer[0]) |
| 3988 | strcpy(buffer, "1"); |
| 3989 | if (test) |
| 3990 | printa(column, "if (%s && !%s)", buffer, trname); |
| 3991 | else |
| 3992 | printa(column, "if (%s)", buffer); |
| 3993 | column += INDENT; |
| 3994 | } |
| 3995 | else |
| 3996 | for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++) |
| 3997 | ; // empty loop body |
| 3998 | |
| 3999 | if (count == 1) |
| 4000 | { |
| 4001 | printa(column, "%s = %s->startTransaction(%s, 0, NULL);", |
| 4002 | trname, gpreGlob.isc_databases->dbb_name->sym_string, vector); |
| 4003 | } |
| 4004 | else |
| 4005 | { |
no test coverage detected