-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the ability to change sql security option without specifying the entire body of the function/procedure/package #7807
Changes from 2 commits
9b823e6
5b62093
695082e
b774645
93c1b1f
ecc0fec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -215,6 +215,9 @@ string CreateAlterPackageNode::internalPrint(NodePrinter& printer) const | |||||
|
||||||
DdlNode* CreateAlterPackageNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) | ||||||
{ | ||||||
if(alter && !items) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return DdlNode::dsqlPass(dsqlScratch); | ||||||
|
||||||
MemoryPool& pool = dsqlScratch->getPool(); | ||||||
|
||||||
source.ltrim("\n\r\t "); | ||||||
|
@@ -319,9 +322,18 @@ void CreateAlterPackageNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlS | |||||
// run all statements under savepoint control | ||||||
AutoSavePoint savePoint(tdbb, transaction); | ||||||
|
||||||
const bool alterIndividualParameters = (alter && !items); | ||||||
|
||||||
if (alter) | ||||||
{ | ||||||
if (!executeAlter(tdbb, dsqlScratch, transaction)) | ||||||
if(alterIndividualParameters) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
if(!executeAlterIndividualParameters(tdbb, dsqlScratch, transaction)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
status_exception::raise( | ||||||
Arg::Gds(isc_no_meta_update) << | ||||||
Arg::Gds(isc_dyn_package_not_found) << Arg::Str(name)); | ||||||
} | ||||||
else if (!executeAlter(tdbb, dsqlScratch, transaction)) | ||||||
{ | ||||||
if (create) // create or alter | ||||||
executeCreate(tdbb, dsqlScratch, transaction); | ||||||
|
@@ -371,10 +383,10 @@ void CreateAlterPackageNode::executeCreate(thread_db* tdbb, DsqlCompilerScratch* | |||||
PKG.RDB$PACKAGE_HEADER_SOURCE.NULL = FALSE; | ||||||
attachment->storeMetaDataBlob(tdbb, transaction, &PKG.RDB$PACKAGE_HEADER_SOURCE, source); | ||||||
|
||||||
if (ssDefiner.isAssigned()) | ||||||
if (ssDefiner.has_value()) | ||||||
{ | ||||||
PKG.RDB$SQL_SECURITY.NULL = FALSE; | ||||||
PKG.RDB$SQL_SECURITY = ssDefiner.asBool() ? FB_TRUE : FB_FALSE; | ||||||
PKG.RDB$SQL_SECURITY = ssDefiner.value() == SqlSecurity::SS_DEFINER ? FB_TRUE : FB_FALSE; | ||||||
} | ||||||
else | ||||||
PKG.RDB$SQL_SECURITY.NULL = TRUE; | ||||||
|
@@ -445,10 +457,10 @@ bool CreateAlterPackageNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* | |||||
if (!PKG.RDB$VALID_BODY_FLAG.NULL) | ||||||
PKG.RDB$VALID_BODY_FLAG = FALSE; | ||||||
|
||||||
if (ssDefiner.isAssigned()) | ||||||
if (ssDefiner.has_value()) | ||||||
{ | ||||||
PKG.RDB$SQL_SECURITY.NULL = FALSE; | ||||||
PKG.RDB$SQL_SECURITY = ssDefiner.asBool() ? FB_TRUE : FB_FALSE; | ||||||
PKG.RDB$SQL_SECURITY = ssDefiner.value() == SqlSecurity::SS_DEFINER ? FB_TRUE : FB_FALSE; | ||||||
} | ||||||
else | ||||||
PKG.RDB$SQL_SECURITY.NULL = TRUE; | ||||||
|
@@ -475,6 +487,44 @@ bool CreateAlterPackageNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* | |||||
} | ||||||
|
||||||
|
||||||
bool CreateAlterPackageNode::executeAlterIndividualParameters(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction) | ||||||
{ | ||||||
AutoCacheRequest requestHandle(tdbb, drq_m_prm_pkg, DYN_REQUESTS); | ||||||
bool modified = false; | ||||||
|
||||||
FOR (REQUEST_HANDLE requestHandle TRANSACTION_HANDLE transaction) | ||||||
PKG IN RDB$PACKAGES | ||||||
WITH PKG.RDB$PACKAGE_NAME EQ name.c_str() | ||||||
{ | ||||||
modified = true; | ||||||
|
||||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, | ||||||
DDL_TRIGGER_ALTER_PACKAGE, name, NULL); | ||||||
|
||||||
MODIFY PKG | ||||||
if (ssDefiner.has_value()) | ||||||
{ | ||||||
if(ssDefiner.value() != SqlSecurity::SS_DROP) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
PKG.RDB$SQL_SECURITY.NULL = FALSE; | ||||||
PKG.RDB$SQL_SECURITY = ssDefiner.value() == SqlSecurity::SS_DEFINER ? FB_TRUE : FB_FALSE; | ||||||
} | ||||||
else | ||||||
PKG.RDB$SQL_SECURITY.NULL = TRUE; | ||||||
} | ||||||
END_MODIFY | ||||||
} | ||||||
END_FOR | ||||||
|
||||||
if (modified) | ||||||
{ | ||||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, | ||||||
DTW_AFTER, DDL_TRIGGER_ALTER_PACKAGE, name, NULL); | ||||||
} | ||||||
|
||||||
return modified; | ||||||
} | ||||||
|
||||||
void CreateAlterPackageNode::executeItems(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, | ||||||
jrd_tra* transaction) | ||||||
{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2707,9 +2707,13 @@ procedure_clause | |
| external_procedure_clause | ||
; | ||
|
||
%type <createAlterProcedureNode> change_opt_procedure_clause | ||
change_opt_procedure_clause | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this empty rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not empty, the definition is below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And why you "declared it" here?
|
||
; | ||
|
||
%type <createAlterProcedureNode> psql_procedure_clause | ||
psql_procedure_clause | ||
: procedure_clause_start sql_security_clause_opt AS local_declarations_opt full_proc_block | ||
: procedure_clause_start optional_sql_security_full_alter_clause AS local_declarations_opt full_proc_block | ||
{ | ||
$$ = $1; | ||
$$->ssDefiner = $2; | ||
|
@@ -2738,6 +2742,17 @@ procedure_clause_start | |
{ $$ = $2; } | ||
; | ||
|
||
%type <createAlterProcedureNode> change_opt_procedure_clause | ||
change_opt_procedure_clause | ||
: symbol_procedure_name | ||
{ $$ = newNode<CreateAlterProcedureNode>(*$1); } | ||
optional_sql_security_partial_alter_clause | ||
{ | ||
$$ = $2; | ||
$$->ssDefiner = $3; | ||
} | ||
; | ||
|
||
%type <createAlterProcedureNode> alter_procedure_clause | ||
alter_procedure_clause | ||
: procedure_clause | ||
|
@@ -2746,6 +2761,12 @@ alter_procedure_clause | |
$$->alter = true; | ||
$$->create = false; | ||
} | ||
| change_opt_procedure_clause | ||
{ | ||
$$ = $1; | ||
$$->alter = true; | ||
$$->create = false; | ||
} | ||
; | ||
|
||
%type <createAlterProcedureNode> replace_procedure_clause | ||
|
@@ -2956,7 +2977,7 @@ replace_function_clause | |
|
||
%type <createAlterPackageNode> package_clause | ||
package_clause | ||
: symbol_package_name sql_security_clause_opt AS BEGIN package_items_opt END | ||
: symbol_package_name optional_sql_security_full_alter_clause AS BEGIN package_items_opt END | ||
{ | ||
CreateAlterPackageNode* node = newNode<CreateAlterPackageNode>(*$1); | ||
node->ssDefiner = $2; | ||
|
@@ -2966,6 +2987,16 @@ package_clause | |
} | ||
; | ||
|
||
%type <createAlterPackageNode> change_opt_package_clause | ||
change_opt_package_clause | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made rules There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You call it partial and I call it just another form of alter. Every alter is partial, they change what was specified. So my suggestion to just use another branch of the original rules directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Every alter is partial, they change what was specified." - is not correct for functions, procedures and packages.
The deterministic and sql security parameters were not specified, but are still being modified Now partial alter (
The deterministic parameter is not specified here and it is not modified. My opinion: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we have a big inconsistency with triggers:
|
||
: symbol_package_name optional_sql_security_partial_alter_clause | ||
{ | ||
CreateAlterPackageNode* node = newNode<CreateAlterPackageNode>(*$1); | ||
node->ssDefiner = $2; | ||
$$ = node; | ||
} | ||
; | ||
|
||
%type <packageItems> package_items_opt | ||
package_items_opt | ||
: package_items | ||
|
@@ -3003,6 +3034,12 @@ alter_package_clause | |
$$->alter = true; | ||
$$->create = false; | ||
} | ||
| change_opt_package_clause | ||
{ | ||
$$ = $1; | ||
$$->alter = true; | ||
$$->create = false; | ||
} | ||
; | ||
|
||
%type <createAlterPackageNode> replace_package_clause | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.