[MDEV-6018] Strange interaction of SQL_MODE=ANSI and partition by TIMESTAMP Created: 2014-04-03  Updated: 2022-09-08

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.36, 10.0.10
Fix Version/s: 5.5

Type: Bug Priority: Minor
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: upstream
Environment:

Linux



 Description   

see also http://bugs.mysql.com/bug.php?id=72222

[3 Apr 14:21] Hartmut Holzgraefe

Description:
A table created with ansi-quoted identifiers and partitioned by UNIX_TIMESTAMP() of a timestamp column can't be dumped with mysqldump unless it is opened in table_cache

On closer look it turned out that if the table was created with SQL_MODE='ANSI_QUOTES' and indeed using ANSI quotes around identifiers
it is not possible to open it with ANSI_QUOTES mode being off
(mysqldump does "SET @@sql_mode='';" as its very first statement
after connecting)

The error message thrown on any attempt to open the table is

ERROR 1486 (HY000): Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed

although UNIX_TIMESTAMP(timestamp_column) should not be
treated as timezone-dependent in >= 5.5, and isn't in
other circumstances

How to repeat:
DROP TABLE IF EXISTS t1;
SET @@SQL_MODE='ANSI_QUOTES';
CREATE TABLE "t1" ( "id" int NOT NULL
, "t" timestamp NOT NULL
, PRIMARY KEY ("id","t")
) PARTITION BY RANGE ( UNIX_TIMESTAMP("t"))
( PARTITION p0 VALUES LESS THAN (1371513600)
, PARTITION p1 VALUES LESS THAN (1371600000));

FLUSH TABLES;
SET @@SQL_MODE='';
SHOW CREATE TABLE t1\G – fails

SET @@SQL_MODE='ANSI_QUOTES';
SHOW CREATE TABLE t1\G – works, table is now in open tables cache

SET @@SQL_MODE='';
SHOW CREATE TABLE t1\G – now works, too, as table is still open / cached

FLUSH TABLES;
SHOW CREATE TABLE t1\G – table no longer in cache: fails again

Suggested fix:
Remove whatever side effect is causing this ...

[3 Apr 14:27] Hartmut Holzgraefe

The problem seems to be in the ansi qotes in

PARTITION BY RANGE ( UNIX_TIMESTAMP("t"))

only, when removing these everything works fine



 Comments   
Comment by Hartmut Holzgraefe [ 2022-05-01 ]

Not reproducible in MariaDB 10.2.10 (the oldest 10.2 release I still have at hand) or later.

So with 10.1 now being beyond EOL we can probably just close this one.

Generated at Thu Feb 08 07:08:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.