diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index ac5c510625..abaff3f754 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -7806,9 +7806,6 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc { MODIFY REL { - const Nullable ssDefiner = - static_cast(i->getObject())->ssDefiner; - if (ssDefiner.specified) { REL.RDB$SQL_SECURITY.NULL = FALSE; @@ -7826,10 +7823,9 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc case Clause::TYPE_ALTER_PUBLICATION: { - const bool publicationState = - static_cast(i->getObject())->state; + fb_assert(replicationState.specified); - if (publicationState) + if (replicationState.value) { // Add table to the publication diff --git a/src/dsql/DdlNodes.h b/src/dsql/DdlNodes.h index 2df80c09e5..988229445b 100644 --- a/src/dsql/DdlNodes.h +++ b/src/dsql/DdlNodes.h @@ -1499,26 +1499,6 @@ public: Firebird::MetaName name; }; - struct AlterSqlSecurityClause : public Clause - { - explicit AlterSqlSecurityClause(MemoryPool& p) - : Clause(p, TYPE_ALTER_SQL_SECURITY) - { - } - - Nullable ssDefiner; - }; - - struct AlterPublicationClause : public Clause - { - explicit AlterPublicationClause(MemoryPool& p) - : Clause(p, TYPE_ALTER_PUBLICATION) - { - } - - bool state; - }; - RelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode); static void deleteLocalField(thread_db* tdbb, jrd_tra* transaction, diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 623edd3949..966475b1aa 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -2178,26 +2178,42 @@ table_clause { $$ = newNode($1, $2); } - '(' table_elements($3) ')' sql_security_clause publication_state + '(' table_elements($3) ')' table_attributes($3) { $$ = $3; - $$->ssDefiner = $7; - $$->replicationState = $8; } ; -%type sql_security_clause -sql_security_clause - : /* nothing */ { $$ = Nullable::empty(); } - | SQL SECURITY DEFINER { $$ = Nullable::val(true); } - | SQL SECURITY INVOKER { $$ = Nullable::val(false); } +%type table_attributes() +table_attributes($relationNode) + : /* nothing */ + | table_attribute($relationNode) table_attributes($relationNode) ; -%type publication_state +%type table_attribute() +table_attribute($relationNode) + : sql_security_clause + { setClause($relationNode->ssDefiner, "SQL SECURITY", $1); } + | publication_state + { setClause($relationNode->replicationState, "PUBLICATION", $1); } + ; + +%type sql_security_clause +sql_security_clause + : SQL SECURITY DEFINER { $$ = true; } + | SQL SECURITY INVOKER { $$ = false; } + ; + +%type sql_security_clause_opt +sql_security_clause_opt + : /* nothing */ { $$ = Nullable::empty(); } + | sql_security_clause { $$ = Nullable::val($1); } + ; + +%type publication_state publication_state - : /* nothing */ { $$ = Nullable::empty(); } - | ENABLE PUBLICATION { $$ = Nullable::val(true); } - | DISABLE PUBLICATION { $$ = Nullable::val(false); } + : ENABLE PUBLICATION { $$ = true; } + | DISABLE PUBLICATION { $$ = false; } ; %type gtt_table_clause @@ -2224,8 +2240,8 @@ gtt_ops($createRelationNode) %type gtt_op() gtt_op($createRelationNode) : // nothing by default. Will be set "on commit delete rows" in dsqlPass - | sql_security_clause - { setClause(static_cast&>($createRelationNode->ssDefiner), "SQL SECURITY", $1); } + | sql_security_clause_opt + { setClause($createRelationNode->ssDefiner, "SQL SECURITY", $1); } | ON COMMIT DELETE ROWS { setClause($createRelationNode->relationType, "ON COMMIT DELETE ROWS", rel_global_temp_delete); } | ON COMMIT PRESERVE ROWS @@ -2630,7 +2646,7 @@ procedure_clause %type psql_procedure_clause psql_procedure_clause - : procedure_clause_start sql_security_clause AS local_declarations_opt full_proc_block + : procedure_clause_start sql_security_clause_opt AS local_declarations_opt full_proc_block { $$ = $1; $$->ssDefiner = $2; @@ -2754,7 +2770,7 @@ function_clause %type psql_function_clause psql_function_clause - : function_clause_start sql_security_clause AS local_declarations_opt full_proc_block + : function_clause_start sql_security_clause_opt AS local_declarations_opt full_proc_block { $$ = $1; $$->ssDefiner = $2; @@ -2840,7 +2856,7 @@ replace_function_clause %type package_clause package_clause - : symbol_package_name sql_security_clause AS BEGIN package_items_opt END + : symbol_package_name sql_security_clause_opt AS BEGIN package_items_opt END { CreateAlterPackageNode* node = newNode(*$1); node->ssDefiner = $2; @@ -4128,36 +4144,37 @@ alter_op($relationNode) } | ALTER SQL SECURITY DEFINER { - RelationNode::AlterSqlSecurityClause* clause = - newNode(); - clause->ssDefiner = Nullable::val(true); + setClause($relationNode->ssDefiner, "SQL SECURITY", true); + RelationNode::Clause* clause = + newNode(RelationNode::Clause::TYPE_ALTER_SQL_SECURITY); $relationNode->clauses.add(clause); } | ALTER SQL SECURITY INVOKER { - RelationNode::AlterSqlSecurityClause* clause = - newNode(); - clause->ssDefiner = Nullable::val(false); + setClause($relationNode->ssDefiner, "SQL SECURITY", false); + RelationNode::Clause* clause = + newNode(RelationNode::Clause::TYPE_ALTER_SQL_SECURITY); $relationNode->clauses.add(clause); } | DROP SQL SECURITY { - RelationNode::AlterSqlSecurityClause* clause = - newNode(); + setClause($relationNode->ssDefiner, "SQL SECURITY", Nullable::empty()); + RelationNode::Clause* clause = + newNode(RelationNode::Clause::TYPE_ALTER_SQL_SECURITY); $relationNode->clauses.add(clause); } | ENABLE PUBLICATION { - RelationNode::AlterPublicationClause* clause = - newNode(); - clause->state = true; + setClause($relationNode->replicationState, "PUBLICATION", true); + RelationNode::Clause* clause = + newNode(RelationNode::Clause::TYPE_ALTER_PUBLICATION); $relationNode->clauses.add(clause); } | DISABLE PUBLICATION { - RelationNode::AlterPublicationClause* clause = - newNode(); - clause->state = false; + setClause($relationNode->replicationState, "PUBLICATION", false); + RelationNode::Clause* clause = + newNode(RelationNode::Clause::TYPE_ALTER_PUBLICATION); $relationNode->clauses.add(clause); } ;