[MDEV-2398] LP:912552 - SET optimizer_switch = REPLACE(...) causes ER_WRONG_VALUE_FOR_VAR Created: 2012-01-05  Updated: 2014-06-20  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug912552.xml    

 Description   

The following statement

SET optimizer_switch = REPLACE( @@optimizer_switch, '=off', '=on' )

as well as many other similar constructions, fails with ER_WRONG_VALUE_FOR_VAR: 1231: Variable 'optimizer_switch' can't be set to the value of 'table_elimination=on'.

bzr version-info
revision-id: <email address hidden>
date: 2012-01-05 00:02:57 +0100
build-date: 2012-01-06 03:01:39 +0400
revno: 3203
branch-nick: maria-5.5

In 5.2 and 5.3 it works all right.

It does not seem to be about the value, since this way it works:

SET @a = REPLACE( @@optimizer_switch, '=off', '=on' );
SET optimizer_switch = @a;

But not this way

SET @b = @@optimizer_switch;
SET optimizer_switch = REPLACE( @b, '=off', '=on' );

It also does not seem to be about the result of REPLACE being too long, since this one works:

SET optimizer_switch = REPLACE( @@optimizer_switch, '=on', '=off' )

REPLACE statements are a convenient way to set optimizer_switch to a needed value in tests, and keep it version-independent; otherwise, it's not an important problem in itself, but it might signify an underlying issue, either with the REPLACE function, or with the optimizer_switch, so I find it worrisome.

Test case:

SET @saved_switch = @@optimizer_switch;

  1. This works
    SET optimizer_switch = REPLACE( @@optimizer_switch, '=on', '=off' );

SET optimizer_switch = @saved_switch;

  1. This doesn't
    SET optimizer_switch = REPLACE( @@optimizer_switch, '=off', '=on' );

SET optimizer_switch = @saved_switch;

  1. This works
    SET @a = REPLACE( @@optimizer_switch, '=off', '=on' );
    SET optimizer_switch = @a;

SET optimizer_switch = @saved_switch;

  1. This doesn't

SET @b = @@optimizer_switch;
SET optimizer_switch = REPLACE( @b, '=off', '=on' );



 Comments   
Comment by Elena Stepanova [ 2012-01-05 ]

Re: SET optimizer_switch = REPLACE(...) causes ER_WRONG_VALUE_FOR_VAR
This bug has also been filed in JIRA as MDEV-69

Comment by Elena Stepanova [ 2012-01-12 ]

Re: SET optimizer_switch = REPLACE(...) causes ER_WRONG_VALUE_FOR_VAR
Assigning to Serg for proper distribution, as it's not clear who it belongs to, and as the JIRA one is currently assigned to Serg too.

Comment by Elena Stepanova [ 2012-03-18 ]

Re: SET optimizer_switch = REPLACE(...) causes ER_WRONG_VALUE_FOR_VAR
Fix released with 5.5.20.

Comment by Rasmus Johansson (Inactive) [ 2012-03-18 ]

Launchpad bug id: 912552

Generated at Thu Feb 08 06:41:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.