Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6176

Request: assign value to server var within LAST_VALUE()

    Details

    • Type: Task
    • Status: Closed
    • Priority: Trivial
    • Resolution: Won't Fix
    • Fix Version/s: N/A
    • Component/s: OTHER
    • 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.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            What did that statement suppose to do?

            Show
            serg Sergei Golubchik added a comment - What did that statement suppose to do?
            Hide
            f_razzoli Federico Razzoli added a comment -

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

            Show
            f_razzoli Federico Razzoli added a comment - If LAST_VALUE() worked with server variables, that statement would assign the same string to both session sql_mode and global sql_mode.
            Hide
            serg Sergei Golubchik added a comment -

            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.

            Show
            serg Sergei Golubchik added a comment - 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.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                f_razzoli Federico Razzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: