8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 06:43:04 +01:00

New feature CORE-4933 : Add better transaction control to isql

This commit is contained in:
hvlad 2020-02-16 16:33:44 +02:00
parent 7e881881b3
commit 0a0a0560d8

View File

@ -468,6 +468,7 @@ public:
BailOnError = false;
StmtTimeout = 0;
ISQL_charset[0] = 0;
KeepTranParams = false;
}
ColList global_Cols;
@ -489,8 +490,10 @@ public:
bool BailOnError;
unsigned int StmtTimeout;
SCHAR ISQL_charset[MAXCHARSET_SIZE];
bool KeepTranParams;
};
static Firebird::GlobalPtr<Firebird::string> TranParams;
static SetValues setValues;
@ -549,6 +552,8 @@ static const UCHAR default_tpb[] =
isc_tpb_no_rec_version
};
static const char* DEFAULT_DML_TRANS_SQL = "SET TRANSACTION";
#ifdef NOT_USED_OR_REPLACED
// CVC: Just in case we need it for R/O operations in the future.
static const UCHAR batch_tpb[] =
@ -586,6 +591,17 @@ static bool startTransaction(Firebird::ITransaction** t, unsigned len = 0, const
static bool M_Transaction()
{
if (DB && !M__trans && setValues.KeepTranParams)
{
M__trans = DB->execute(fbStatus, nullptr,
TranParams->length(), TranParams->c_str(),
isqlGlob.SQL_dialect, nullptr, nullptr, nullptr, nullptr);
if (ISQL_errmsg(fbStatus))
return false;
return DB != NULL;
}
return startTransaction(&M__trans);
}
@ -4949,6 +4965,7 @@ static processing_state frontend_set(const char* cmd, const char* const* parms,
//#endif
sql, warning, sqlCont, heading, bail,
bulk_insert, maxrows, stmtTimeout,
keepTranParams,
wrong
};
SetOptions(const optionsMap* inmap, size_t insize, int wrongval)
@ -4989,6 +5006,7 @@ static processing_state frontend_set(const char* cmd, const char* const* parms,
{SetOptions::sqlCont, "TRUSTED", 0}, // TRUSTED ROLE, will get DSQL error other case
{SetOptions::stmtTimeout, "LOCAL_TIMEOUT", 0},
{SetOptions::sqlCont, "DECFLOAT", 0},
{SetOptions::keepTranParams, "KEEP_TRAN_PARAMS", 9},
};
// Display current set options
@ -5166,6 +5184,13 @@ static processing_state frontend_set(const char* cmd, const char* const* parms,
}
break;
case SetOptions::keepTranParams:
ret = do_set_command(parms[2], &setValues.KeepTranParams);
if (ret != ps_ERR)
TranParams->assign(setValues.KeepTranParams ? DEFAULT_DML_TRANS_SQL : "");
break;
default:
//{
// TEXT msg_string[MSG_LENGTH];
@ -5997,6 +6022,9 @@ static processing_state print_sets()
print_set("Warnings:", setValues.Warnings);
print_set("Bail on error:", setValues.BailOnError);
isqlGlob.printf("%-25s%lu%s", "Local statement timeout:", setValues.StmtTimeout, NEWLINE);
print_set("Keep transaction params:", setValues.KeepTranParams);
if (setValues.KeepTranParams)
isqlGlob.printf(" %s%s", TranParams->c_str(), NEWLINE);
return SKIP;
}
@ -6668,6 +6696,9 @@ static processing_state newtrans(const TEXT* statement)
return FAIL;
}
if (setValues.KeepTranParams)
TranParams->assign(statement);
return SKIP;
}