Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
11.8, 12.3, 13.1, 12.3.3
-
None
-
None
-
Linux/amd64; STRICT_ALL_TABLES session mode
Description
A CREATE TABLE ... AS SELECT ... UNION ALL operation combining VECTOR(1) and VARBINARY(5) creates a destination reported as VECTOR(1) but with CHARACTER_MAXIMUM_LENGTH=5. The destination then rejects the same four-byte vector value that an explicitly declared VECTOR(1) column accepts. This was observed with MariaDB 12.3.3 on Linux/amd64 using STRICT_ALL_TABLES.
Reproducer
Run this SQL with the MariaDB client so that the DELIMITER directives are processed:
CREATE DATABASE vector_union; |
USE vector_union; |
SET SESSION sql_mode='STRICT_ALL_TABLES'; |
CREATE TABLE source_values (a VECTOR(1), b VARBINARY(5)); |
CREATE TABLE vector_derived AS SELECT a AS v FROM source_values UNION ALL SELECT b AS v FROM source_values; |
CREATE TABLE vector_control (v VECTOR(1)); |
SELECT TABLE_NAME,COLUMN_TYPE,CHARACTER_MAXIMUM_LENGTH FROM information_schema.COLUMNS |
WHERE TABLE_SCHEMA='vector_union' AND COLUMN_NAME='v' ORDER BY TABLE_NAME; |
INSERT INTO vector_control VALUES (VEC_FROMTEXT('[1]')); |
DELIMITER //
|
CREATE PROCEDURE try_vector_insert() |
BEGIN
|
DECLARE insert_errno INT DEFAULT 0; |
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION GET DIAGNOSTICS CONDITION 1 insert_errno = MYSQL_ERRNO; |
INSERT INTO vector_derived VALUES (VEC_FROMTEXT('[1]')); |
SELECT 'derived_insert_errno' AS oracle,insert_errno AS observed; |
END// |
DELIMITER ;
|
CALL try_vector_insert();
|
SELECT 'control_value' AS oracle,HEX(v) AS observed FROM vector_control; |
SELECT 'derived_rows' AS oracle,COUNT(*) AS observed FROM vector_derived; |
DROP DATABASE vector_union; |
SELECT 'cleanup_schemas' AS oracle,COUNT(*) AS observed FROM information_schema.SCHEMATA WHERE SCHEMA_NAME='vector_union'; |
The client output is:
TABLE_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH
|
vector_control vector(1) 4
|
vector_derived vector(1) 5
|
oracle observed
|
derived_insert_errno 1292
|
oracle observed
|
control_value 0000803F
|
oracle observed
|
derived_rows 0
|
oracle observed
|
cleanup_schemas 0
|
The derived column is advertised as vector(1) with a five-byte maximum length. Inserting VEC_FROMTEXT('[1]') raises error 1292 and leaves the derived table empty, while the explicit VECTOR(1) control stores the value as 0000803F.
A destination advertised as VECTOR(1) should have storage metadata aligned to one four-byte vector element and accept the same valid four-byte value as an explicitly declared VECTOR(1) column. Alternatively, type aggregation must select a compatible binary destination rather than construct inconsistent VECTOR metadata. The available source evidence suggests that UNION result aggregation retains the maximum binary length without aligning it to a whole four-byte vector element before constructing the destination field.
This occurs when UNION CTAS aggregates a VECTOR column with a five-byte VARBINARY column.
Attachments
Issue Links
- relates to
-
MDEV-40751 CREATE ... SELECT VEC_FROMTEXT(...) may create VECTOR columns that reject every value
-
- Closed
-