[MDEV-29966] Function is accepted for default in CREATE TABLE but makes ALTER fail Created: 2022-11-07  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Character Sets, Data Definition - Alter Table
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

In the test case below, CREATE TABLE succeeds, but the following ALTER fails with ER_INVALID_DEFAULT.
I could only reproduce the error with "special" character sets (utf16, utf32, ucs2), although maybe if the test case is changed in a right way, it will show up elsewhere.

create table t (a VARBINARY(33000) DEFAULT REPEAT('a',33000)) CHARACTER SET ucs2;
alter table t force;
show create table t;
 
# Cleanup
drop table t;

10.3 92be8d20

CURRENT_TEST: bug.t2
mysqltest: At line 2: query 'alter table t force' failed: 1067: Invalid default value for 'a'

However, this (same default value but from a variable instead of a function) works all right, no errors:

SET @a= REPEAT('a',33000);
 
create table t (a VARBINARY(33000) DEFAULT @a) CHARACTER SET ucs2;
alter table t force;
show create table t;
drop table t;


Generated at Thu Feb 08 10:12:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.