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

SET STATEMENT default_week_format = .. has no effect

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: N/A
    • Fix Version/s: 10.1.2
    • Component/s: Admin statements
    • Labels:
      None

      Description

      MariaDB [test]> SELECT @@default_week_format;
      +-----------------------+
      | @@default_week_format |
      +-----------------------+
      |                     0 |
      +-----------------------+
      1 row in set (0.00 sec)
      
      MariaDB [test]> SELECT WEEK('2000-01-01');
      +--------------------+
      | WEEK('2000-01-01') |
      +--------------------+
      |                  0 |
      +--------------------+
      1 row in set (0.00 sec)
      
      MariaDB [test]> SELECT WEEK('2000-01-01',2);
      +----------------------+
      | WEEK('2000-01-01',2) |
      +----------------------+
      |                   52 |
      +----------------------+
      1 row in set (0.00 sec)
      
      MariaDB [test]> SET STATEMENT default_week_format = 2 FOR SELECT WEEK('2000-01-01');
      +--------------------+
      | WEEK('2000-01-01') |
      +--------------------+
      |                  0 |
      +--------------------+
      1 row in set (0.01 sec)
      
      MariaDB [test]> SET default_week_format = 2;
      Query OK, 0 rows affected (0.00 sec)
      
      MariaDB [test]> SELECT WEEK('2000-01-01');
      +--------------------+
      | WEEK('2000-01-01') |
      +--------------------+
      |                 52 |
      +--------------------+
      1 row in set (0.00 sec)
      

      All the same in Percona server.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              sanja Oleksandr Byelkin added a comment - - edited

              The problem is that week format put as an constant argument during parsing:

                          Item *i1= new (thd->mem_root) Item_int((char*) "0",
                                                         thd->variables.default_week_format,
                                                                 1);
                          if (i1 == NULL)
                            MYSQL_YYABORT;
                          $$= new (thd->mem_root) Item_func_week($3, i1);
                          if ($$ == NULL)
                            MYSQL_YYABORT;
              
              Show
              sanja Oleksandr Byelkin added a comment - - edited The problem is that week format put as an constant argument during parsing: Item *i1= new (thd->mem_root) Item_int(( char *) "0" , thd->variables.default_week_format, 1); if (i1 == NULL) MYSQL_YYABORT; $$= new (thd->mem_root) Item_func_week($3, i1); if ($$ == NULL) MYSQL_YYABORT;
              Hide
              sanja Oleksandr Byelkin added a comment -

              The variable prohibited as a workaround.

              Show
              sanja Oleksandr Byelkin added a comment - The variable prohibited as a workaround.
              Hide
              sanja Oleksandr Byelkin added a comment -

              Parameters set during parsing so changing variables has no effect.

              Show
              sanja Oleksandr Byelkin added a comment - Parameters set during parsing so changing variables has no effect.
              Hide
              serg Sergei Golubchik added a comment -

              This is a bug, a variable should not be set during parsing.
              So, keep it enabled and fix the following bug instead:

              create table t1 (a date);
              insert t1 values ('2001-01-01');
              prepare x from "select week(a) from t1";
              execute x;
              set default_week_format = 2;
              execute x;
              alter table t1 engine=myisam;
              execute x;
              
              Show
              serg Sergei Golubchik added a comment - This is a bug, a variable should not be set during parsing. So, keep it enabled and fix the following bug instead: create table t1 (a date); insert t1 values ('2001-01-01'); prepare x from " select week(a) from t1" ; execute x; set default_week_format = 2; execute x; alter table t1 engine=myisam; execute x;
              Hide
              serg Sergei Golubchik added a comment -

              An easy fix would be to generate Item_func_get_system_var for a second argument.

              Show
              serg Sergei Golubchik added a comment - An easy fix would be to generate Item_func_get_system_var for a second argument.
              Hide
              sanja Oleksandr Byelkin added a comment -

              I did a bit different but fix is:
              [Commits] b14de6a: MDEV-6996: SET STATEMENT default_week_format = .. has no effect
              20.11.14 11:32

              Show
              sanja Oleksandr Byelkin added a comment - I did a bit different but fix is: [Commits] b14de6a: MDEV-6996 : SET STATEMENT default_week_format = .. has no effect 20.11.14 11:32

                People

                • Assignee:
                  sanja Oleksandr Byelkin
                  Reporter:
                  elenst Elena Stepanova
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: