Skip to content
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

[CBRD-25352] Add a user schema to your stored procedures for consistency with other objects #5258

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
76f3145
Merge the code from the main development branch (CBRD-25352) into the…
Jun 14, 2024
1ce9ff5
Modify to execute the CALL PROCEDURE/FUNCTION statement correctly. Ad…
Jun 18, 2024
fab738a
Modify to execute the SELECT PROCEDURE/FUNCTION statement correctly. …
Jun 19, 2024
b2ade1d
Merge commit 'f101fbc9c' into feature/plcsql-CBRD-25352
Jun 19, 2024
95a96e0
1) Add unique_name to sp_info object to find pl/casl system stored pr…
Jun 21, 2024
1aeb682
1) Resolving the issue where the OWNER is changed to the current sess…
Jun 21, 2024
6f190ca
Modify the if-statement in the case PT_METHOD_CALL: part of pt_bind_n…
Jun 28, 2024
f90eab9
Merge branch 'goodone' into feature/plcsql-CBRD-25352
Jul 3, 2024
4fabc96
1) Modified the logic to allow for separate execution of SP and Metho…
Jul 3, 2024
1a797f1
Merge commit 'fe9cd5192' into feature/plcsql-CBRD-25352
Jul 4, 2024
c658a6c
dba 와 dba 그룹 이외 사용자가 다른 사용자의 CREATE PROCEDURE/FUNCTION 구문을 사용할 경우 에러가…
Jul 5, 2024
e2d51a1
1) test_sql 에서 error가 발생하는 case 수정(trigger_action, query_spec), 2) sy…
Jul 9, 2024
54be451
pt_bind_names()에서 다음과 같은 이유로 [user_schema]를 다시 제거되도록 수정함. 첫 번째 arg_li…
Jul 10, 2024
170b14c
1) ALTER PROCEDURE/FUNCTION 구문에서 OWNER TO 없이 수행시 unique_name의 값이 empt…
Jul 11, 2024
df41f70
[Rollback] PT_FUNCTION 노드를 수행시 generic_name 값은 사용자가 입력한 그대로 출력하게 수정 e…
Jul 11, 2024
aca5193
name_resolution 파일에 오타 수정
Jul 11, 2024
f869886
name_resolution 파일에 누락된 if-statement 추가
Jul 11, 2024
c0fa0ff
sp_param_def 토큰 내부의 sp_param_type 토큰 위치에 data_type 토큰이 잘못 사용되었기 때문에 d…
Jul 15, 2024
f8ab9a0
Merge commit 'c18553564' into feature/plcsql-CBRD-25352
Jul 15, 2024
61fb31e
Merge commit 'ca9beeff5' into feature/plcsql-CBRD-25352
Jul 15, 2024
b9cae15
Fixed an error where the next value of the PT_DOT node is missing
Jul 16, 2024
fc2d58a
1) The procedure_name and function_name tokens were merged into a pro…
Jul 17, 2024
89d439b
Merge remote-tracking branch 'upstream/feature/plcsql-p1n' into featu…
Jul 19, 2024
df4f051
Add dbms_output user_schema to CALL enable and CALL disalbe related t…
Jul 19, 2024
5694430
I modified it by referring to the code review.
Jul 22, 2024
bbdd267
1) I modified it by referring to the code review. 2) The unique_name …
Jul 23, 2024
4ac8596
Merge commit '59c98d544' into feature/plcsql-CBRD-25352
Jul 23, 2024
01ba477
The maximum length of the identifier name that includes the user_sche…
Jul 24, 2024
fd1de0c
Merge commit '5ae12df82' into feature/plcsql-CBRD-25352
Jul 29, 2024
0572d68
Reflecting the code review content and adding a part to change the un…
Jul 29, 2024
b7482bb
There was a part where the ; (semicolon) was omitted, so I corrected it.
Jul 29, 2024
c6ae8b8
1) Modify sp_name to be downcased in pl/csql, 2) We previously used s…
Jul 31, 2024
45d26fd
We added that part by omitting the length value of the NULL terminati…
Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/executables/csql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ csql_print_server_output (const CSQL_ARGUMENT * csql_arg)

do
{
errors = csql_execute_query ("CALL get_line (:pl_output_str, :pl_output_status);");
errors = csql_execute_query ("CALL dbms_output.get_line (:pl_output_str, :pl_output_status);");
if (errors != 0)
{
break;
Expand Down
16 changes: 12 additions & 4 deletions src/executables/unload_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -4323,13 +4323,15 @@ emit_stored_procedure (extract_context & ctxt, print_output & output_ctx)
{
MOP cls, obj, owner;
DB_OBJLIST *sp_list = NULL, *cur_sp;
DB_VALUE sp_name_val, pkg_name_val, sp_type_val, arg_cnt_val, generated_val, args_val, rtn_type_val, method_val,
comment_val;
DB_VALUE unique_name_val, sp_name_val, pkg_name_val, sp_type_val, arg_cnt_val, generated_val, args_val, rtn_type_val,
method_val, comment_val;
DB_VALUE owner_val, owner_name_val;
int sp_type, rtn_type, arg_cnt, save;
DB_SET *arg_set;
int err;
int err_count = 0;
char owner_name[DB_MAX_USER_LENGTH] = { '\0' };
char output_owner[DB_MAX_USER_LENGTH + 4] = { '\0' };

AU_DISABLE (save);

Expand All @@ -4346,6 +4348,7 @@ emit_stored_procedure (extract_context & ctxt, print_output & output_ctx)
obj = cur_sp->op;

if ((err = db_get (obj, SP_ATTR_SP_TYPE, &sp_type_val)) != NO_ERROR
|| (err = db_get (obj, SP_ATTR_UNIQUE_NAME, &unique_name_val)) != NO_ERROR
|| (err = db_get (obj, SP_ATTR_NAME, &sp_name_val)) != NO_ERROR
|| (err = db_get (obj, SP_ATTR_PKG, &pkg_name_val)) != NO_ERROR
|| (err = db_get (obj, SP_ATTR_ARG_COUNT, &arg_cnt_val)) != NO_ERROR
Expand All @@ -4365,7 +4368,12 @@ emit_stored_procedure (extract_context & ctxt, print_output & output_ctx)
continue;
}

const char *unique_name = db_get_string (&unique_name_val);
const char *sp_name = db_get_string (&sp_name_val);
sm_qualifier_name (unique_name, owner_name, DB_MAX_USER_LENGTH);

PRINT_OWNER_NAME (owner_name, (ctxt.is_dba_user || ctxt.is_dba_group_member), output_owner,
sizeof (output_owner));

if (ctxt.is_dba_user == false && ctxt.is_dba_group_member == false)
{
Expand Down Expand Up @@ -4393,7 +4401,7 @@ emit_stored_procedure (extract_context & ctxt, print_output & output_ctx)
}
else
{
output_ctx (" %s%s%s (", PRINT_IDENTIFIER (sp_name));
output_ctx (" %s%s%s%s (", output_owner, PRINT_IDENTIFIER (sp_name));
}

arg_cnt = db_get_int (&arg_cnt_val);
Expand Down Expand Up @@ -4440,7 +4448,7 @@ emit_stored_procedure (extract_context & ctxt, print_output & output_ctx)

if (ctxt.is_dba_user || ctxt.is_dba_group_member)
{
output_ctx ("call [change_sp_owner]('%s', '%s') on class [db_root];\n", db_get_string (&sp_name_val),
output_ctx ("call [change_sp_owner]('%s', '%s') on class [db_root];\n", unique_name,
db_get_string (&owner_name_val));
}

Expand Down
38 changes: 37 additions & 1 deletion src/object/authenticate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5118,7 +5118,14 @@ au_change_sp_owner (MOP sp, MOP owner)
{
int error = NO_ERROR;
int save;
DB_VALUE value;
const char *name_str = NULL, *owner_str = NULL;
char new_name_str[DB_MAX_IDENTIFIER_LENGTH] = { '\0' };
char downcase_owner_name[DB_MAX_USER_LENGTH] = { '\0' };
DB_VALUE value, name_value, owner_value;

db_make_null (&value);
db_make_null (&name_value);
db_make_null (&owner_value);

AU_DISABLE (save);
if (!au_is_dba_group_member (Au_user))
Expand All @@ -5128,6 +5135,35 @@ au_change_sp_owner (MOP sp, MOP owner)
}
else
{
error = obj_get (sp, "sp_name", &name_value);
if (error != NO_ERROR)
{
goto end;
}
error = obj_get (owner, "name", &owner_value);
if (error != NO_ERROR)
{
goto end;
}

name_str = db_get_string (&name_value);
owner_str = db_get_string (&owner_value);

sm_downcase_name (owner_str, downcase_owner_name, DB_MAX_USER_LENGTH);
sprintf (new_name_str, "%s.%s", downcase_owner_name, name_str);

/* change the unique_name */
if (new_name_str != NULL)
ctshim marked this conversation as resolved.
Show resolved Hide resolved
{
db_make_string (&value, new_name_str);
error = obj_set (sp, SP_ATTR_UNIQUE_NAME, &value);
if (error < 0)
{
goto end;
}
pr_clear_value (&value);
}

db_make_object (&value, owner);
error = obj_set (sp, SP_ATTR_OWNER, &value);
if (error < 0)
Expand Down
9 changes: 6 additions & 3 deletions src/object/schema_system_catalog_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ namespace cubschema
CT_STORED_PROC_NAME,
// columns
{
{"unique_name", format_varchar (255)},
{"sp_name", format_varchar (255)},
{"sp_type", "integer"},
{"return_type", "integer"},
Expand All @@ -845,7 +846,8 @@ namespace cubschema
},
// constraints
{
{DB_CONSTRAINT_UNIQUE, "", {"sp_name", nullptr}, false},
{DB_CONSTRAINT_PRIMARY_KEY, "pk_db_stored_procedure_unique_name", {"unique_name", nullptr}, false},
{DB_CONSTRAINT_UNIQUE, "", {"sp_name", "owner", nullptr}, false}
hgryoo marked this conversation as resolved.
Show resolved Hide resolved
},
// authorization
{
Expand All @@ -866,7 +868,7 @@ namespace cubschema
CT_STORED_PROC_ARGS_NAME,
// columns
{
{"sp_name", format_varchar (255)},
{"sp_of", CT_STORED_PROC_NAME},
{"pkg_name", format_varchar (255)},
{"index_of", "integer"},
{"is_system_generated", "integer"},
Expand All @@ -879,7 +881,7 @@ namespace cubschema
},
// constraints
{
{DB_CONSTRAINT_INDEX, "", {"sp_name", nullptr}, false},
{DB_CONSTRAINT_INDEX, "", {"sp_of", nullptr}, false},
},
// authorization
{
Expand Down Expand Up @@ -1842,6 +1844,7 @@ namespace cubschema
// columns
{
{"sp_name", "varchar(255)"},
{"sp_owner_name", "varchar(255)"},
hgryoo marked this conversation as resolved.
Show resolved Hide resolved
{"pkg_name", "varchar (255)"},
{"index_of", "integer"},
{"arg_name", "varchar(255)"},
Expand Down
5 changes: 3 additions & 2 deletions src/object/schema_system_catalog_install_query_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,8 @@ sm_define_view_stored_procedure_arguments_spec (void)
// *INDENT-OFF*
sprintf (stmt,
"SELECT "
"[sp].[sp_name] AS [sp_name], "
"[sp].[sp_of].[sp_name] AS [sp_name], "
"CAST ([sp].[sp_of].[owner].[name] AS VARCHAR(255)) AS [sp_owner_name], " /* string -> varchar(255) */
"[sp].[pkg_name] AS [pkg_name], "
"[sp].[index_of] AS [index_of], "
"[sp].[arg_name] AS [arg_name], "
Expand All @@ -1212,7 +1213,7 @@ sm_define_view_stored_procedure_arguments_spec (void)
"[%s] AS [sp] "
"WHERE [sp].[is_system_generated] = 0 "
"ORDER BY " /* Is it possible to remove ORDER BY? */
"[sp].[sp_name], "
"[sp].[sp_of].[sp_name], "
"[sp].[index_of]",
CT_DATATYPE_NAME,
CT_STORED_PROC_ARGS_NAME);
Expand Down
102 changes: 90 additions & 12 deletions src/parser/csql_grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ static char *g_plcsql_text;
%type <node> serial_name
%type <node> synonym_name_without_dot
%type <node> synonym_name
%type <node> procedure_name_without_dot
%type <node> procedure_name
%type <node> procedure_name_list
%type <node> function_name_without_dot
%type <node> function_name
%type <node> function_name_list
%type <node> opt_alter_synonym
%type <node> opt_identifier
%type <node> normal_or_class_attr_list_with_commas
Expand Down Expand Up @@ -3063,7 +3069,7 @@ create_stmt
push_msg(MSGCAT_SYNTAX_INVALID_CREATE_PROCEDURE);
expecting_pl_lang_spec = 1;
}
identifier opt_sp_param_list /* 5, 6 */
procedure_name_without_dot opt_sp_param_list /* 5, 6 */
opt_authid /* 7 */
is_or_as pl_language_spec /* 8, 9 */
opt_comment_spec /* 10 */
Expand Down Expand Up @@ -3096,7 +3102,7 @@ create_stmt
push_msg(MSGCAT_SYNTAX_INVALID_CREATE_FUNCTION);
expecting_pl_lang_spec = 1;
}
identifier opt_sp_param_list /* 5, 6 */
function_name_without_dot opt_sp_param_list /* 5, 6 */
RETURN sp_return_type /* 7, 8 */
opt_authid /* 9 */
is_or_as pl_language_spec /* 10, 11 */
Expand Down Expand Up @@ -4092,10 +4098,10 @@ alter_stmt
DBG_PRINT}}
| ALTER /* 1 */
procedure_or_function /* 2 */
identifier /* 3 */
procedure_name /* 3 */
ctshim marked this conversation as resolved.
Show resolved Hide resolved
opt_owner_clause /* 4 */
opt_comment_spec /* 5 */
{{ DBG_TRACE_GRAMMAR(alter_stmt, | ALTER procedure_or_function identifier opt_owner_clause opt_comment_spec);
{{ DBG_TRACE_GRAMMAR(alter_stmt, | ALTER procedure_or_function procedure_name opt_owner_clause opt_comment_spec);

PT_NODE *node = parser_new_node (this_parser, PT_ALTER_STORED_PROCEDURE);

Expand Down Expand Up @@ -4671,8 +4677,8 @@ drop_stmt
PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)

DBG_PRINT}}
| DROP PROCEDURE identifier_list
{{ DBG_TRACE_GRAMMAR(drop_stmt, | DROP PROCEDURE identifier_list);
| DROP PROCEDURE procedure_name_list
{{ DBG_TRACE_GRAMMAR(drop_stmt, | DROP PROCEDURE procedure_name_list);

PT_NODE *node = parser_new_node (this_parser, PT_DROP_STORED_PROCEDURE);

Expand All @@ -4687,8 +4693,8 @@ drop_stmt
PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)

DBG_PRINT}}
| DROP FUNCTION identifier_list
{{ DBG_TRACE_GRAMMAR(drop_stmt, | DROP FUNCTION identifier_list);
| DROP FUNCTION function_name_list
{{ DBG_TRACE_GRAMMAR(drop_stmt, | DROP FUNCTION function_name_list);

PT_NODE *node = parser_new_node (this_parser, PT_DROP_STORED_PROCEDURE);

Expand Down Expand Up @@ -5882,6 +5888,68 @@ synonym_name
}
;

procedure_name_without_dot
: user_specified_name_without_dot
{ DBG_TRACE_GRAMMAR(procedure_name_without_dot, : user_specified_name_without_dot);
$$ = $1;
}
;

procedure_name
: user_specified_name
{ DBG_TRACE_GRAMMAR(procedure_name, : user_specified_name);
$$ = $1;
}
;

procedure_name_list
: procedure_name_list ',' procedure_name
{{

ctshim marked this conversation as resolved.
Show resolved Hide resolved
$$ = parser_make_link($1, $3);
PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)

DBG_PRINT}}
| procedure_name
{{

$$ = $1;
PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)

DBG_PRINT}}
;

function_name_without_dot
: user_specified_name_without_dot
{ DBG_TRACE_GRAMMAR(function_name_without_dot, : user_specified_name_without_dot);
$$ = $1;
}
;

function_name
: user_specified_name
{ DBG_TRACE_GRAMMAR(function_name, : user_specified_name);
$$ = $1;
}
;

function_name_list
: function_name_list ',' function_name
{{

$$ = parser_make_link($1, $3);
PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)

DBG_PRINT}}
| function_name
{{

ctshim marked this conversation as resolved.
Show resolved Hide resolved
$$ = $1;
PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)

DBG_PRINT}}
;

opt_partition_spec
: /* empty */
{{ DBG_TRACE_GRAMMAR(opt_partition_spec, : );
Expand Down Expand Up @@ -12872,7 +12940,7 @@ sp_param_list
sp_param_def
: identifier
opt_sp_in_out
data_type
sp_param_type
ctshim marked this conversation as resolved.
Show resolved Hide resolved
opt_sp_default_value
opt_comment_spec
{{ DBG_TRACE_GRAMMAR(sp_param_def, : identifier opt_sp_in_out sp_param_type opt_comment_spec);
Expand Down Expand Up @@ -19351,7 +19419,7 @@ generic_function
;

generic_function_for_call
: identifier
: procedure_name
{
if(pwd_info.parser_call_check)
{
Expand All @@ -19366,8 +19434,7 @@ generic_function_for_call
}
}
'(' opt_expression_list_for_call ')' opt_on_target
{{ DBG_TRACE_GRAMMAR(generic_function_for_call, : identifier '(' opt_expression_list ')' opt_on_target );

{{ DBG_TRACE_GRAMMAR(generic_function_for_call, : procedure_name '(' opt_expression_list_for_call ')' opt_on_target );
PT_NODE *node = NULL;

if ($6 == NULL)
Expand All @@ -19384,6 +19451,17 @@ generic_function_for_call
node->info.method_call.method_name = $1;
node->info.method_call.arg_list = $4;
node->info.method_call.on_call_target = $6;
if (node->info.method_call.on_call_target != NULL)
{
PT_NAME_INFO_CLEAR_FLAG (node->info.method_call.method_name, PT_NAME_INFO_USER_SPECIFIED);
}
else
{
if (node->info.method_call.arg_list != NULL && node->info.method_call.arg_list->node_type == PT_NAME && node->info.method_call.arg_list->info.name.meta_class == PT_META_CLASS)
{
PT_NAME_INFO_CLEAR_FLAG (node->info.method_call.method_name, PT_NAME_INFO_USER_SPECIFIED);
}
}
node->info.method_call.call_or_expr = PT_IS_MTHD_EXPR;
}

Expand Down
Loading
Loading