Skip to content

MDEV-40839: SET members from the 9th on lost on a pushed-down SELECT - #5968

Open
GoldenEmperor1177 wants to merge 1 commit into
MariaDB:11.4from
GoldenEmperor1177:MDEV-40839
Open

GoldenEmperor1177 wants to merge 1 commit into
MariaDB:11.4from
GoldenEmperor1177:MDEV-40839

Conversation

@GoldenEmperor1177

@GoldenEmperor1177 GoldenEmperor1177 commented Oct 23, 2026 •

Copy link
Copy Markdown

MDEV-40839: SET column on ENGINE=DuckDB silently drops any member at ordinal position 9 or higher

Type_handler_set::make_table_field() built the Field_set with get_enum_pack_length(), the ENUM rule (1 byte below 256 values). A pushed-down SELECT (select handler) reads the result into a temporary table made through this function, so a SET with more than 8 members got a 1-byte field there and every member from the 9th on was cut off (a,i came back as a, i as an empty value). The stored data was always right, which is why CAST(s AS CHAR), s='i', group_concat(s) and concat(s,'') gave the correct result.

The fix uses get_set_pack_length(), as the other Type_handler_set functions (Column_definition_fix_attributes(), calc_key_length()) already do. Only sql/sql_type.cc changes, by one line; the DuckDB engine code is untouched. This path is only reached by engines that use a select handler. A plain InnoDB UNION or derived table turns the SET into a varchar and was never affected.

Also reproduced with FederatedX (federated_pushdown=1): a SET with more than 8 members loses members from the 9th on when read through the select handler, and reads correctly with the pushdown off. This shows the problem is in the core function and is not specific to DuckDB.

Tests:

  • new federated.federatedx_set_pushdown: without the fix the pushdown read loses members, with it it matches the remote table; also passes with --ps-protocol and --cursor-protocol
  • new duckdb.set_wide_members: fails without the fix (a / h / empty), passes with it; it also passes with --ps-protocol and --cursor-protocol
  • main.type_set, type_enum, union, derived, derived_cond_pushdown, func_set, ps, view, create_select, subselect, select, ctype_utf8mb4, cte_nonrecursive pass
  • duckdb.create_table_column and duckdb.feature_duckdb_data_type pass. Other tests of the suite fail on my machine only because of a time zone warning ("Can't find corresponding duckdb time_zone"), which happens without the change too.
  • tested on an 11.4 debug build with the DuckDB plugin, rebased on current 11.4 (36a265d)

Base branch is 11.4, as agreed on the ticket.

Type_handler_set::make_table_field() built the Field_set with
get_enum_pack_length(), the ENUM rule (1 byte below 256 values), so
a SET with more than 8 members got a 1-byte field in the temporary
table of a select handler (used by the DuckDB engine and by FederatedX
with federated_pushdown=1) and every member from the 9th on was cut
off. Use get_set_pack_length(), as the other Type_handler_set
functions already do.

Tests: duckdb.set_wide_members and federated.federatedx_set_pushdown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant