[MDEV-6176] Request: assign value to server var within LAST_VALUE() Created: 2014-04-25  Updated: 2015-02-18  Resolved: 2015-02-18

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: N/A

Type: Task Priority: Trivial
Reporter: Federico Razzoli Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

I tried the following:

MariaDB [test]> SET @@global.sql_mode := LAST_VALUE(@@session.sql_mode := 'STRICT_ALL_TABLES');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':= 'STRICT_ALL_TABLES')' at line 1

Not surprising: after all setting @@session.sql_mode requires SET. But this is something one might wish to do.



 Comments   
Comment by Sergei Golubchik [ 2014-04-28 ]

What did that statement suppose to do?

Comment by Federico Razzoli [ 2014-04-28 ]

If LAST_VALUE() worked with server variables, that statement would assign the same string to both session sql_mode and global sql_mode.

Comment by Sergei Golubchik [ 2015-02-18 ]

Server variables can only be assigned in the SET statement. Not in an expression. User variables can be assigned inside of an expression — that's why they work in the LAST_VALUE, and often are used in the SELECT statement. But you cannot use server variables this way (not in the SELECT statement either). I don't think we should make an exception for "LAST_VALUE in the SET statement" use case. So what you're really asking about is to allow server variables to be assigned inside an expression. This looks like a reasonable feature request.

But I'll close this MDEV-6176, because we cannot implement it the way it's formulated (allow server variables to be assigned in LAST_VALUE in the SET statement). And it's too specific to be converted to a more general one (allow server variables to be assigned inside an expression). Feel free to create a new feature request for server variables in an expression, if you'd like it to be considered.

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