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-25241] Add SQL syntax to change the owner of the serial #5038

Merged
merged 33 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a099d37
ADD Syntax ALTER SERIAL .. OWNER TO ..
Mar 5, 2024
92e8f4e
1) style: Change au_change_serial_owner_method() to au_change_serial_…
Mar 9, 2024
9715b94
Modified to the contents confirmed on 03/12 day, 1) style : change au…
Mar 15, 2024
83dcf82
style : Modify the authenticate.c file line
Mar 15, 2024
3f38dfb
style : Correct error in authenticate.c file
Mar 15, 2024
2639f0a
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Mar 15, 2024
52d900d
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Mar 31, 2024
44445ae
feat : Added semantic_check logic and error message MSGCAT_SET_PARSER…
Apr 2, 2024
18ec8b8
Correction of typos
Apr 2, 2024
bc9390e
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 2, 2024
8452dd9
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 8, 2024
f4d1e81
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 11, 2024
0fc408b
style: Change au_change_serial_owner() to au_change_serial_owner_meth…
Apr 11, 2024
2de54d1
style: Fixed PT_CHANGE_OWNER conditional check inside semantic_check
Apr 11, 2024
0098e21
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 12, 2024
c0047b2
style: Re-registering where error message text is broken
Apr 12, 2024
0086df5
style: Re-registering where error message text is broken (ko_KR.euckr)
Apr 12, 2024
43dc688
Crash actions
Apr 22, 2024
a824ba6
Crash actions
Apr 22, 2024
c853e97
Crash actions(3)
Apr 22, 2024
3206bab
Crash actions(4)
Apr 22, 2024
da187a8
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 22, 2024
6f33842
1) feat : Add container_11(c1 ~ c11), 2) style : Change opt_serial_op…
Apr 22, 2024
6e4e986
style: Re-registering where error message text is broken (ko_KR.euckr)
Apr 23, 2024
a2bf082
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 28, 2024
c3e1196
1) style: Deduplicate PT_SERIAL_COMMENT and COMMENT, 2) style : Retur…
Apr 28, 2024
98e3a9c
1) style: Fixed to make it clear to users when changing the SERIAL OW…
Apr 28, 2024
aa6b1aa
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 29, 2024
f6f7b74
style: Add PT_SERIAL_COMMENT again
Apr 29, 2024
6414578
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
Apr 30, 2024
32385bf
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
May 3, 2024
d19a4d2
Merge remote-tracking branch 'upstream/develop' into CBRD-25241
May 8, 2024
6108a05
style: Delete PT_SERIAL_COMMENT
May 8, 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
7 changes: 7 additions & 0 deletions src/object/authenticate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5254,6 +5254,13 @@ au_change_serial_owner_method (MOP obj, DB_VALUE * return_val, DB_VALUE * serial
return;
}

if (!au_is_dba_group_member (Au_user))
{
ERROR_SET_WARNING_1ARG (error, ER_AU_DBA_ONLY, "change_serial_owner");
db_make_error (return_val, error);
return;
}

if (!DB_IS_STRING (serial_val) || (serial_name = db_get_string (serial_val)) == NULL)
{
ERROR_SET_WARNING_1ARG (error, ER_OBJ_INVALID_ARGUMENT, "");
Expand Down
20 changes: 20 additions & 0 deletions src/parser/csql_grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -3771,6 +3771,26 @@ alter_stmt
MSGCAT_SEMANTIC_SERIAL_ALTER_NO_OPTION, 0);
}

DBG_PRINT}}
| ALTER /* 1 */
SERIAL /* 2 */
serial_name /* 3 */
OWNER TO identifier /* 4, 5, 6 */
opt_comment_spec /* 7 */
jongmin-won marked this conversation as resolved.
Show resolved Hide resolved
{{ DBG_TRACE_GRAMMAR(alter_stmt, | ALTER SERIAL serial_name OWNER TO identifier opt_comment_spec);

PT_NODE *node = parser_new_node (this_parser, PT_ALTER_SERIAL);

if (node)
{
node->info.serial.serial_name = $3;
node->info.serial.owner_name = $6;
node->info.serial.comment = $7;
}

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

DBG_PRINT}}
| ALTER /* 1 */
{ /* 2 */
Expand Down
1 change: 1 addition & 0 deletions src/parser/parse_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,7 @@ struct pt_serial_info
PT_NODE *max_val; /* PT_VALUE */
PT_NODE *min_val; /* PT_VALUE */
PT_NODE *cached_num_val; /* PT_VALUE */
PT_NODE *owner_name; /* PT_NAME */
PT_NODE *comment; /* PT_VALUE */
int cyclic;
int no_max;
Expand Down
8 changes: 8 additions & 0 deletions src/parser/parse_tree_cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8159,6 +8159,13 @@ pt_print_alter_serial (PARSER_CONTEXT * parser, PT_NODE * p)
q = pt_append_nulstring (parser, q, " nocache ");
}

if (p->info.serial.owner_name != NULL)
{
r1 = pt_print_bytes (parser, p->info.serial.owner_name);
q = pt_append_nulstring (parser, q, " owner to ");
q = pt_append_varchar (parser, q, r1);
}

if (p->info.serial.comment != NULL)
{
r1 = pt_print_bytes (parser, p->info.serial.comment);
Expand Down Expand Up @@ -8273,6 +8280,7 @@ pt_apply_alter_serial (PARSER_CONTEXT * parser, PT_NODE * p, void *arg)
PT_APPLY_WALK (parser, p->info.serial.increment_val, arg);
PT_APPLY_WALK (parser, p->info.serial.min_val, arg);
PT_APPLY_WALK (parser, p->info.serial.max_val, arg);
PT_APPLY_WALK (parser, p->info.serial.owner_name, arg);
return p;
}

Expand Down
38 changes: 37 additions & 1 deletion src/query/execute_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -2318,8 +2318,14 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
DB_VALUE abs_inc_val, range_val;
int cached_num;
int ret_msg_id = 0;

PT_NODE *serial_owner = NULL;
const char *serial_owner_name = NULL;
DB_VALUE serial_name_val, returnval, serial_owner_val;
const char *comment = NULL;

bool opt_serial_option_list_flag = false;

int new_inc_val_flag = 0, new_cyclic;
bool cur_val_change, inc_val_change, max_val_change, min_val_change, cyclic_change, cached_num_change;

Expand Down Expand Up @@ -2347,6 +2353,9 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
db_make_null (&class_name_val);
db_make_null (&abs_inc_val);
db_make_null (&range_val);
db_make_null (&serial_name_val);
db_make_null (&returnval);
db_make_null (&serial_owner_val);
OID_SET_NULL (&serial_obj_id);

/*
Expand Down Expand Up @@ -2778,6 +2787,7 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
goto end;
}
pr_clear_value (&value);
opt_serial_option_list_flag = true;
}

/* increment_val */
Expand All @@ -2788,6 +2798,7 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
{
goto end;
}
opt_serial_option_list_flag = true;
}

/* max_val */
Expand All @@ -2798,6 +2809,7 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
{
goto end;
}
opt_serial_option_list_flag = true;
}

/* min_val */
Expand All @@ -2808,6 +2820,7 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
{
goto end;
}
opt_serial_option_list_flag = true;
}

/* cyclic */
Expand All @@ -2820,6 +2833,7 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
goto end;
}
pr_clear_value (&value);
opt_serial_option_list_flag = true;
}

/* cached num */
Expand All @@ -2846,6 +2860,28 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
goto end;
}
pr_clear_value (&value);
opt_serial_option_list_flag = true;
}

/* owner to */
serial_owner = statement->info.serial.owner_name;
if (serial_owner != NULL)
{
jongmin-won marked this conversation as resolved.
Show resolved Hide resolved
serial_owner_name = serial_owner->info.name.original;

db_make_string (&serial_name_val, (char *) PT_NODE_SR_NAME (statement));
db_make_string (&serial_owner_val, serial_owner_name);

au_change_serial_owner_method (serial_class, &returnval, &serial_name_val, &serial_owner_val);

pr_clear_value (&serial_name_val);
pr_clear_value (&serial_owner_val);

if (DB_VALUE_TYPE (&returnval) == DB_TYPE_ERROR)
{
error = db_get_error (&returnval);
goto end;
}
}

/* comment */
Expand Down Expand Up @@ -2874,7 +2910,7 @@ do_alter_serial (PARSER_CONTEXT * parser, PT_NODE * statement)
obj_tmpl = NULL;

end:
if (!OID_ISNULL (&serial_obj_id))
if (!OID_ISNULL (&serial_obj_id) && opt_serial_option_list_flag == true)
{
(void) serial_decache ((OID *) (&serial_obj_id));
}
Expand Down
Loading