Skip to content

Commit 9359ea8

Browse files
better version, more general intercept (#77)
1 parent b8ef446 commit 9359ea8

2 files changed

Lines changed: 4 additions & 32 deletions

File tree

sql/field.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10491,6 +10491,9 @@ Create_field_wrapper::Create_field_wrapper(const Create_field *fld)
1049110491
if (fld->is_unsigned) {
1049210492
set_flag(UNSIGNED_FLAG);
1049310493
}
10494+
if (fld->custom_type_context != nullptr) {
10495+
set_type_context(fld->custom_type_context);
10496+
}
1049410497
}
1049510498

1049610499
Item_result Create_field_wrapper::result_type() const {

villagesql/types/util.cc

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,38 +1071,7 @@ bool ValidateAndConvertVDFArguments(THD *thd, const char *func_name,
10711071
continue;
10721072
}
10731073

1074-
// Case 3: Argument is a column reference (Item_field) without type context
1075-
// yet. This happens during functional index creation: the table is being
1076-
// created, so MaybeInjectCustomType hasn't run yet. The field's underlying
1077-
// Create_field_wrapper (set by replace_field_processor) lets us check
1078-
// whether the column will actually be a custom type.
1079-
// We match on qualified_base_name() (extension.type, no parameters),
1080-
// consistent with Case 1, because VDF signatures cannot express type
1081-
// parameterization - a VDF declared with param("TVECTOR") must accept any
1082-
// TVECTOR(N) column.
1083-
if (args[i]->type() == Item::FIELD_ITEM) {
1084-
auto *item_field = down_cast<Item_field *>(args[i]);
1085-
if (item_field->field != nullptr &&
1086-
item_field->field->is_wrapper_field()) {
1087-
auto *wrapper =
1088-
down_cast<const Create_field_wrapper *>(item_field->field);
1089-
const Create_field *cf = wrapper->get_create_field();
1090-
if (cf->custom_type_context != nullptr) {
1091-
if (cf->custom_type_context->qualified_base_name() != expected_qbn) {
1092-
villagesql_error(
1093-
"Cannot initialize function '%s': argument %u type mismatch "
1094-
"(expected %s, got %s)",
1095-
MYF(0), func_name, i + 1, expected_qbn.c_str(),
1096-
cf->custom_type_context->qualified_base_name().c_str());
1097-
return true;
1098-
}
1099-
continue;
1100-
}
1101-
}
1102-
// Column has no custom type context - fall through
1103-
}
1104-
1105-
// Case 4: Argument is not a custom type and not a constant string
1074+
// Case 3: Argument is not a custom type and not a constant string
11061075
villagesql_error(
11071076
"Cannot initialize function '%s': argument %u must be a custom type "
11081077
"or string constant",

0 commit comments

Comments
 (0)