mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:03:02 +01:00
Prevent using DECRYPT and ENCRYPT clauses in one query
This commit is contained in:
parent
a8e163ba8c
commit
08aabbf41d
@ -11587,12 +11587,6 @@ void AlterDatabaseNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
if (cryptPlugin.hasData())
|
||||
DFW_post_work(transaction, dfw_db_crypt, cryptPlugin.c_str(), 0);
|
||||
|
||||
if (clauses & CLAUSE_DECRYPT)
|
||||
DFW_post_work(transaction, dfw_db_crypt, "", 0);
|
||||
|
||||
Attachment* const attachment = transaction->tra_attachment;
|
||||
dsql_dbb* dbb = transaction->getDsqlAttachment();
|
||||
SLONG dbAlloc = PageSpace::maxAlloc(tdbb->getDatabase());
|
||||
@ -11655,6 +11649,13 @@ void AlterDatabaseNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
|
||||
}
|
||||
END_FOR
|
||||
|
||||
// Allow update above to work as a lock, preventing altering of the database from parallel transactions
|
||||
// Moreover, if should load crypt plugin if it (by a miracle) wasn't already loaded yet
|
||||
if (clauses & CLAUSE_CRYPT)
|
||||
{
|
||||
DFW_post_work(transaction, dfw_db_crypt, cryptPlugin.c_str(), 0);
|
||||
}
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
|
@ -2212,7 +2212,7 @@ public:
|
||||
static const unsigned CLAUSE_BEGIN_BACKUP = 0x01;
|
||||
static const unsigned CLAUSE_END_BACKUP = 0x02;
|
||||
static const unsigned CLAUSE_DROP_DIFFERENCE = 0x04;
|
||||
static const unsigned CLAUSE_DECRYPT = 0x08;
|
||||
static const unsigned CLAUSE_CRYPT = 0x08;
|
||||
|
||||
static const unsigned RDB_DATABASE_MASK =
|
||||
CLAUSE_BEGIN_BACKUP | CLAUSE_END_BACKUP | CLAUSE_DROP_DIFFERENCE;
|
||||
|
@ -275,6 +275,16 @@ private:
|
||||
setClause(clause, duplicateMsg, true);
|
||||
}
|
||||
|
||||
void setClauseFlag(unsigned& clause, const unsigned flag, const char* duplicateMsg)
|
||||
{
|
||||
using namespace Firebird;
|
||||
if (clause & flag)
|
||||
status_exception::raise(
|
||||
Arg::Gds(isc_sqlerr) << Arg::Num(-637) <<
|
||||
Arg::Gds(isc_dsql_duplicate_spec) << duplicateMsg);
|
||||
clause |= flag;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void checkDuplicateClause(const T& clause, const char* duplicateMsg)
|
||||
{
|
||||
|
@ -3962,9 +3962,12 @@ db_alter_clause($alterDatabaseNode)
|
||||
| SET DEFAULT CHARACTER SET symbol_character_set_name
|
||||
{ $alterDatabaseNode->setDefaultCharSet = *$5; }
|
||||
| ENCRYPT WITH valid_symbol_name
|
||||
{ $alterDatabaseNode->cryptPlugin = *$3; }
|
||||
{
|
||||
setClauseFlag($alterDatabaseNode->clauses, AlterDatabaseNode::CLAUSE_CRYPT, "CRYPT");
|
||||
$alterDatabaseNode->cryptPlugin = *$3;
|
||||
}
|
||||
| DECRYPT
|
||||
{ $alterDatabaseNode->clauses |= AlterDatabaseNode::CLAUSE_DECRYPT; }
|
||||
{ setClauseFlag($alterDatabaseNode->clauses, AlterDatabaseNode::CLAUSE_CRYPT, "CRYPT"); }
|
||||
| SET LINGER TO long_integer
|
||||
{ $alterDatabaseNode->linger = $4; }
|
||||
| DROP LINGER
|
||||
|
Loading…
Reference in New Issue
Block a user