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-24905] The problem is that a core dump occurs when a value of an invalid index type (such as Collection Type) is bound to host variables (#4614) #4631

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 13 additions & 3 deletions src/query/scan_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,7 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
bool need_new_setdomain = false;
TP_DOMAIN *idx_setdomain = NULL, *vals_setdomain = NULL;
TP_DOMAIN *idx_dom = NULL, *val_dom = NULL, *dom = NULL, *next = NULL;
DB_TYPE idx_type_id;
TP_DOMAIN dom_buf;
DB_VALUE *coerced_values = NULL;
bool *has_coerced_values = NULL;
Expand Down Expand Up @@ -1585,7 +1586,16 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
}
}

idx_type_id = TP_DOMAIN_TYPE (idx_dom);
val_type_id = DB_VALUE_DOMAIN_TYPE (val);

if (!tp_valid_indextype (val_type_id))
{
er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_TP_CANT_COERCE, 2, pr_type_name (idx_type_id),
pr_type_name (val_type_id));
goto err_exit;
}

if (TP_IS_STRING_TYPE (val_type_id))
{
/* we need to check for maxes */
Expand All @@ -1600,7 +1610,7 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
}
}

if (TP_DOMAIN_TYPE (idx_dom) != val_type_id)
if (idx_type_id != val_type_id)
{
/* allocate DB_VALUE array to store coerced values. */
if (has_coerced_values == NULL)
Expand Down Expand Up @@ -1635,8 +1645,8 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
has_coerced_values[i] = true;
}
}
else if (TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_NUMERIC || TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_CHAR
|| TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_BIT || TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_NCHAR)
else if (idx_type_id == DB_TYPE_NUMERIC || idx_type_id == DB_TYPE_CHAR || idx_type_id == DB_TYPE_BIT
|| idx_type_id == DB_TYPE_NCHAR)
{
/* skip variable string domain : DB_TYPE_VARCHAR, DB_TYPE_VARNCHAR, DB_TYPE_VARBIT */

Expand Down
6 changes: 3 additions & 3 deletions src/storage/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -18690,9 +18690,6 @@ btree_compare_key (DB_VALUE * key1, DB_VALUE * key2, TP_DOMAIN * key_domain, int
assert (key1_type != DB_TYPE_MIDXKEY);
assert (key2_type != DB_TYPE_MIDXKEY);

assert (tp_valid_indextype (key1_type));
assert (tp_valid_indextype (key2_type));

/* safe code */
if (key1_type == DB_TYPE_MIDXKEY)
{
Expand Down Expand Up @@ -18737,6 +18734,9 @@ btree_compare_key (DB_VALUE * key1, DB_VALUE * key2, TP_DOMAIN * key_domain, int
}
}

assert (tp_valid_indextype (key1_type));
assert (tp_valid_indextype (key2_type));

assert_release (c == DB_UNK || (DB_LT <= c && c <= DB_GT));

/* for single-column desc index */
Expand Down
Loading