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-24638] The problem of the default value of column when altering the type of column. #4074

Merged
merged 16 commits into from
Mar 17, 2023
Merged
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions src/object/schema_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -4442,6 +4442,8 @@ smt_change_attribute_w_dflt_w_order (DB_CTMPL * def, const char *name, const cha
int is_class_attr;
DB_VALUE *orig_value = NULL;
DB_VALUE *new_orig_value = NULL;
DB_VALUE default_value;
DB_DEFAULT_EXPR default_expr;
TP_DOMAIN_STATUS status;

*found_att = NULL;
Expand All @@ -4458,12 +4460,34 @@ smt_change_attribute_w_dflt_w_order (DB_CTMPL * def, const char *name, const cha
return error;
}

/*
The default value's domain should be checked even though the new default is not specified
*/
db_make_null (&default_value);
if (new_default_value == NULL && new_default_expr->default_expr_type == DB_DEFAULT_NONE)
{
pr_clone_value (&(*found_att)->default_value.value, &default_value);
default_expr = (*found_att)->default_value.default_expr;

if (!DB_IS_NULL (&default_value))
{
new_default_value = &default_value;
}

if (default_expr.default_expr_type != DB_DEFAULT_NONE)
{
new_default_expr = &default_expr;
}
}

is_class_attr = (name_space == ID_CLASS_ATTRIBUTE);
if (new_default_value != NULL || (new_default_expr != NULL && new_default_expr->default_expr_type != DB_DEFAULT_NONE))
{
assert (((*found_att)->flags & SM_ATTFLAG_NEW) == 0);
error = smt_set_attribute_default (def, ((new_name != NULL) ? new_name : name), is_class_attr, new_default_value,
new_default_expr);

db_value_clear (&default_value);
if (error != NO_ERROR)
{
return error;
Expand Down