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

Make table attributes position-independent + some logic ported from the Dimitry Sibiryakov's PR

This commit is contained in:
Dmitry Yemanov 2020-04-16 08:54:37 +03:00
parent 54ed1e6b33
commit 96eeeb2ef7
3 changed files with 50 additions and 57 deletions

View File

@ -7806,9 +7806,6 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
{ {
MODIFY REL MODIFY REL
{ {
const Nullable<bool> ssDefiner =
static_cast<const AlterSqlSecurityClause*>(i->getObject())->ssDefiner;
if (ssDefiner.specified) if (ssDefiner.specified)
{ {
REL.RDB$SQL_SECURITY.NULL = FALSE; REL.RDB$SQL_SECURITY.NULL = FALSE;
@ -7826,10 +7823,9 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
case Clause::TYPE_ALTER_PUBLICATION: case Clause::TYPE_ALTER_PUBLICATION:
{ {
const bool publicationState = fb_assert(replicationState.specified);
static_cast<const AlterPublicationClause*>(i->getObject())->state;
if (publicationState) if (replicationState.value)
{ {
// Add table to the publication // Add table to the publication

View File

@ -1499,26 +1499,6 @@ public:
Firebird::MetaName name; Firebird::MetaName name;
}; };
struct AlterSqlSecurityClause : public Clause
{
explicit AlterSqlSecurityClause(MemoryPool& p)
: Clause(p, TYPE_ALTER_SQL_SECURITY)
{
}
Nullable<bool> ssDefiner;
};
struct AlterPublicationClause : public Clause
{
explicit AlterPublicationClause(MemoryPool& p)
: Clause(p, TYPE_ALTER_PUBLICATION)
{
}
bool state;
};
RelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode); RelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode);
static void deleteLocalField(thread_db* tdbb, jrd_tra* transaction, static void deleteLocalField(thread_db* tdbb, jrd_tra* transaction,

View File

@ -2178,26 +2178,42 @@ table_clause
{ {
$<createRelationNode>$ = newNode<CreateRelationNode>($1, $2); $<createRelationNode>$ = newNode<CreateRelationNode>($1, $2);
} }
'(' table_elements($3) ')' sql_security_clause publication_state '(' table_elements($3) ')' table_attributes($3)
{ {
$$ = $3; $$ = $3;
$$->ssDefiner = $7;
$$->replicationState = $8;
} }
; ;
%type <nullableBoolVal> sql_security_clause %type table_attributes(<relationNode>)
sql_security_clause table_attributes($relationNode)
: /* nothing */ { $$ = Nullable<bool>::empty(); } : /* nothing */
| SQL SECURITY DEFINER { $$ = Nullable<bool>::val(true); } | table_attribute($relationNode) table_attributes($relationNode)
| SQL SECURITY INVOKER { $$ = Nullable<bool>::val(false); }
; ;
%type <nullableBoolVal> publication_state %type table_attribute(<relationNode>)
table_attribute($relationNode)
: sql_security_clause
{ setClause($relationNode->ssDefiner, "SQL SECURITY", $1); }
| publication_state
{ setClause($relationNode->replicationState, "PUBLICATION", $1); }
;
%type <boolVal> sql_security_clause
sql_security_clause
: SQL SECURITY DEFINER { $$ = true; }
| SQL SECURITY INVOKER { $$ = false; }
;
%type <nullableBoolVal> sql_security_clause_opt
sql_security_clause_opt
: /* nothing */ { $$ = Nullable<bool>::empty(); }
| sql_security_clause { $$ = Nullable<bool>::val($1); }
;
%type <boolVal> publication_state
publication_state publication_state
: /* nothing */ { $$ = Nullable<bool>::empty(); } : ENABLE PUBLICATION { $$ = true; }
| ENABLE PUBLICATION { $$ = Nullable<bool>::val(true); } | DISABLE PUBLICATION { $$ = false; }
| DISABLE PUBLICATION { $$ = Nullable<bool>::val(false); }
; ;
%type <createRelationNode> gtt_table_clause %type <createRelationNode> gtt_table_clause
@ -2224,8 +2240,8 @@ gtt_ops($createRelationNode)
%type gtt_op(<createRelationNode>) %type gtt_op(<createRelationNode>)
gtt_op($createRelationNode) gtt_op($createRelationNode)
: // nothing by default. Will be set "on commit delete rows" in dsqlPass : // nothing by default. Will be set "on commit delete rows" in dsqlPass
| sql_security_clause | sql_security_clause_opt
{ setClause(static_cast<BaseNullable<bool>&>($createRelationNode->ssDefiner), "SQL SECURITY", $1); } { setClause($createRelationNode->ssDefiner, "SQL SECURITY", $1); }
| ON COMMIT DELETE ROWS | ON COMMIT DELETE ROWS
{ setClause($createRelationNode->relationType, "ON COMMIT DELETE ROWS", rel_global_temp_delete); } { setClause($createRelationNode->relationType, "ON COMMIT DELETE ROWS", rel_global_temp_delete); }
| ON COMMIT PRESERVE ROWS | ON COMMIT PRESERVE ROWS
@ -2630,7 +2646,7 @@ procedure_clause
%type <createAlterProcedureNode> psql_procedure_clause %type <createAlterProcedureNode> psql_procedure_clause
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; $$ = $1;
$$->ssDefiner = $2; $$->ssDefiner = $2;
@ -2754,7 +2770,7 @@ function_clause
%type <createAlterFunctionNode> psql_function_clause %type <createAlterFunctionNode> psql_function_clause
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; $$ = $1;
$$->ssDefiner = $2; $$->ssDefiner = $2;
@ -2840,7 +2856,7 @@ replace_function_clause
%type <createAlterPackageNode> package_clause %type <createAlterPackageNode> package_clause
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<CreateAlterPackageNode>(*$1); CreateAlterPackageNode* node = newNode<CreateAlterPackageNode>(*$1);
node->ssDefiner = $2; node->ssDefiner = $2;
@ -4128,36 +4144,37 @@ alter_op($relationNode)
} }
| ALTER SQL SECURITY DEFINER | ALTER SQL SECURITY DEFINER
{ {
RelationNode::AlterSqlSecurityClause* clause = setClause($relationNode->ssDefiner, "SQL SECURITY", true);
newNode<RelationNode::AlterSqlSecurityClause>(); RelationNode::Clause* clause =
clause->ssDefiner = Nullable<bool>::val(true); newNode<RelationNode::Clause>(RelationNode::Clause::TYPE_ALTER_SQL_SECURITY);
$relationNode->clauses.add(clause); $relationNode->clauses.add(clause);
} }
| ALTER SQL SECURITY INVOKER | ALTER SQL SECURITY INVOKER
{ {
RelationNode::AlterSqlSecurityClause* clause = setClause($relationNode->ssDefiner, "SQL SECURITY", false);
newNode<RelationNode::AlterSqlSecurityClause>(); RelationNode::Clause* clause =
clause->ssDefiner = Nullable<bool>::val(false); newNode<RelationNode::Clause>(RelationNode::Clause::TYPE_ALTER_SQL_SECURITY);
$relationNode->clauses.add(clause); $relationNode->clauses.add(clause);
} }
| DROP SQL SECURITY | DROP SQL SECURITY
{ {
RelationNode::AlterSqlSecurityClause* clause = setClause($relationNode->ssDefiner, "SQL SECURITY", Nullable<bool>::empty());
newNode<RelationNode::AlterSqlSecurityClause>(); RelationNode::Clause* clause =
newNode<RelationNode::Clause>(RelationNode::Clause::TYPE_ALTER_SQL_SECURITY);
$relationNode->clauses.add(clause); $relationNode->clauses.add(clause);
} }
| ENABLE PUBLICATION | ENABLE PUBLICATION
{ {
RelationNode::AlterPublicationClause* clause = setClause($relationNode->replicationState, "PUBLICATION", true);
newNode<RelationNode::AlterPublicationClause>(); RelationNode::Clause* clause =
clause->state = true; newNode<RelationNode::Clause>(RelationNode::Clause::TYPE_ALTER_PUBLICATION);
$relationNode->clauses.add(clause); $relationNode->clauses.add(clause);
} }
| DISABLE PUBLICATION | DISABLE PUBLICATION
{ {
RelationNode::AlterPublicationClause* clause = setClause($relationNode->replicationState, "PUBLICATION", false);
newNode<RelationNode::AlterPublicationClause>(); RelationNode::Clause* clause =
clause->state = false; newNode<RelationNode::Clause>(RelationNode::Clause::TYPE_ALTER_PUBLICATION);
$relationNode->clauses.add(clause); $relationNode->clauses.add(clause);
} }
; ;