vitess.io/vitess@v0.16.2/go/vt/vtgate/planbuilder/testdata/set_cases.json (about)

     1  [
     2    {
     3      "comment": "set single user defined variable",
     4      "query": "set @foo = 42",
     5      "plan": {
     6        "QueryType": "SET",
     7        "Original": "set @foo = 42",
     8        "Instructions": {
     9          "OperatorType": "Set",
    10          "Ops": [
    11            {
    12              "Type": "UserDefinedVariable",
    13              "Name": "foo",
    14              "Expr": "INT64(42)"
    15            }
    16          ],
    17          "Inputs": [
    18            {
    19              "OperatorType": "SingleRow"
    20            }
    21          ]
    22        }
    23      }
    24    },
    25    {
    26      "comment": "set multi user defined variable",
    27      "query": "set @foo = 42, @bar = @foo",
    28      "plan": {
    29        "QueryType": "SET",
    30        "Original": "set @foo = 42, @bar = @foo",
    31        "Instructions": {
    32          "OperatorType": "Set",
    33          "Ops": [
    34            {
    35              "Type": "UserDefinedVariable",
    36              "Name": "foo",
    37              "Expr": "INT64(42)"
    38            },
    39            {
    40              "Type": "UserDefinedVariable",
    41              "Name": "bar",
    42              "Expr": ":__vtudvfoo"
    43            }
    44          ],
    45          "Inputs": [
    46            {
    47              "OperatorType": "SingleRow"
    48            }
    49          ]
    50        }
    51      }
    52    },
    53    {
    54      "comment": "set multi user defined variable with complex expression",
    55      "query": "set @foo = 42, @bar = @foo + 1",
    56      "plan": {
    57        "QueryType": "SET",
    58        "Original": "set @foo = 42, @bar = @foo + 1",
    59        "Instructions": {
    60          "OperatorType": "Set",
    61          "Ops": [
    62            {
    63              "Type": "UserDefinedVariable",
    64              "Name": "foo",
    65              "Expr": "INT64(42)"
    66            },
    67            {
    68              "Type": "UserDefinedVariable",
    69              "Name": "bar",
    70              "Expr": ":__vtudvfoo + INT64(1)"
    71            }
    72          ],
    73          "Inputs": [
    74            {
    75              "OperatorType": "SingleRow"
    76            }
    77          ]
    78        }
    79      }
    80    },
    81    {
    82      "comment": "set UDV to expression that can't be evaluated at vtgate",
    83      "query": "set @foo = CONCAT('Any','Expression','Is','Valid')",
    84      "plan": {
    85        "QueryType": "SET",
    86        "Original": "set @foo = CONCAT('Any','Expression','Is','Valid')",
    87        "Instructions": {
    88          "OperatorType": "Set",
    89          "Ops": [
    90            {
    91              "Type": "UserDefinedVariable",
    92              "Name": "foo",
    93              "Expr": "[COLUMN 0]"
    94            }
    95          ],
    96          "Inputs": [
    97            {
    98              "OperatorType": "Send",
    99              "Keyspace": {
   100                "Name": "main",
   101                "Sharded": false
   102              },
   103              "TargetDestination": "AnyShard()",
   104              "Query": "select CONCAT('Any', 'Expression', 'Is', 'Valid') from dual",
   105              "SingleShardOnly": true
   106            }
   107          ]
   108        }
   109      }
   110    },
   111    {
   112      "comment": "single sysvar cases",
   113      "query": "SET sql_mode = 'STRICT_ALL_TABLES,NO_AUTO_VALUE_ON_ZERO'",
   114      "plan": {
   115        "QueryType": "SET",
   116        "Original": "SET sql_mode = 'STRICT_ALL_TABLES,NO_AUTO_VALUE_ON_ZERO'",
   117        "Instructions": {
   118          "OperatorType": "Set",
   119          "Ops": [
   120            {
   121              "Type": "SysVarSet",
   122              "Name": "sql_mode",
   123              "Keyspace": {
   124                "Name": "main",
   125                "Sharded": false
   126              },
   127              "Expr": "'STRICT_ALL_TABLES,NO_AUTO_VALUE_ON_ZERO'",
   128              "SupportSetVar": true
   129            }
   130          ],
   131          "Inputs": [
   132            {
   133              "OperatorType": "SingleRow"
   134            }
   135          ]
   136        }
   137      }
   138    },
   139    {
   140      "comment": "multiple sysvar cases",
   141      "query": "SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_safe_updates = 0",
   142      "plan": {
   143        "QueryType": "SET",
   144        "Original": "SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_safe_updates = 0",
   145        "Instructions": {
   146          "OperatorType": "Set",
   147          "Ops": [
   148            {
   149              "Type": "SysVarSet",
   150              "Name": "sql_mode",
   151              "Keyspace": {
   152                "Name": "main",
   153                "Sharded": false
   154              },
   155              "Expr": "CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO')",
   156              "SupportSetVar": true
   157            },
   158            {
   159              "Type": "SysVarSet",
   160              "Name": "sql_safe_updates",
   161              "Keyspace": {
   162                "Name": "main",
   163                "Sharded": false
   164              },
   165              "Expr": "0",
   166              "SupportSetVar": true
   167            }
   168          ],
   169          "Inputs": [
   170            {
   171              "OperatorType": "SingleRow"
   172            }
   173          ]
   174        }
   175      }
   176    },
   177    {
   178      "comment": "autocommit case",
   179      "query": "SET autocommit = 1, autocommit = on, autocommit = 'on', autocommit = @myudv, autocommit = `on`, autocommit = `off`",
   180      "plan": {
   181        "QueryType": "SET",
   182        "Original": "SET autocommit = 1, autocommit = on, autocommit = 'on', autocommit = @myudv, autocommit = `on`, autocommit = `off`",
   183        "Instructions": {
   184          "OperatorType": "Set",
   185          "Ops": [
   186            {
   187              "Type": "SysVarAware",
   188              "Name": "autocommit",
   189              "Expr": "INT64(1)"
   190            },
   191            {
   192              "Type": "SysVarAware",
   193              "Name": "autocommit",
   194              "Expr": "INT64(1)"
   195            },
   196            {
   197              "Type": "SysVarAware",
   198              "Name": "autocommit",
   199              "Expr": "INT64(1)"
   200            },
   201            {
   202              "Type": "SysVarAware",
   203              "Name": "autocommit",
   204              "Expr": ":__vtudvmyudv"
   205            },
   206            {
   207              "Type": "SysVarAware",
   208              "Name": "autocommit",
   209              "Expr": "INT64(1)"
   210            },
   211            {
   212              "Type": "SysVarAware",
   213              "Name": "autocommit",
   214              "Expr": "INT64(0)"
   215            }
   216          ],
   217          "Inputs": [
   218            {
   219              "OperatorType": "SingleRow"
   220            }
   221          ]
   222        }
   223      }
   224    },
   225    {
   226      "comment": "set ignore plan",
   227      "query": "set @@default_storage_engine = 'DONOTCHANGEME'",
   228      "plan": {
   229        "QueryType": "SET",
   230        "Original": "set @@default_storage_engine = 'DONOTCHANGEME'",
   231        "Instructions": {
   232          "OperatorType": "Set",
   233          "Ops": [
   234            {
   235              "Type": "SysVarIgnore",
   236              "Name": "default_storage_engine",
   237              "Expr": "'DONOTCHANGEME'"
   238            }
   239          ],
   240          "Inputs": [
   241            {
   242              "OperatorType": "SingleRow"
   243            }
   244          ]
   245        }
   246      }
   247    },
   248    {
   249      "comment": "set check and ignore plan",
   250      "query": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER')",
   251      "plan": {
   252        "QueryType": "SET",
   253        "Original": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER')",
   254        "Instructions": {
   255          "OperatorType": "Set",
   256          "Ops": [
   257            {
   258              "Type": "SysVarSet",
   259              "Name": "sql_mode",
   260              "Keyspace": {
   261                "Name": "main",
   262                "Sharded": false
   263              },
   264              "Expr": "concat(@@sql_mode, ',NO_AUTO_CREATE_USER')",
   265              "SupportSetVar": true
   266            }
   267          ],
   268          "Inputs": [
   269            {
   270              "OperatorType": "SingleRow"
   271            }
   272          ]
   273        }
   274      }
   275    },
   276    {
   277      "comment": "set system settings",
   278      "query": "set @@sql_safe_updates = 1",
   279      "plan": {
   280        "QueryType": "SET",
   281        "Original": "set @@sql_safe_updates = 1",
   282        "Instructions": {
   283          "OperatorType": "Set",
   284          "Ops": [
   285            {
   286              "Type": "SysVarSet",
   287              "Name": "sql_safe_updates",
   288              "Keyspace": {
   289                "Name": "main",
   290                "Sharded": false
   291              },
   292              "Expr": "1",
   293              "SupportSetVar": true
   294            }
   295          ],
   296          "Inputs": [
   297            {
   298              "OperatorType": "SingleRow"
   299            }
   300          ]
   301        }
   302      }
   303    },
   304    {
   305      "comment": "set plan building with ON/OFF enum",
   306      "query": "set @@innodb_strict_mode = OFF",
   307      "plan": {
   308        "QueryType": "SET",
   309        "Original": "set @@innodb_strict_mode = OFF",
   310        "Instructions": {
   311          "OperatorType": "Set",
   312          "Ops": [
   313            {
   314              "Type": "SysVarIgnore",
   315              "Name": "innodb_strict_mode",
   316              "Expr": "0"
   317            }
   318          ],
   319          "Inputs": [
   320            {
   321              "OperatorType": "SingleRow"
   322            }
   323          ]
   324        }
   325      }
   326    },
   327    {
   328      "comment": "set plan building with string literal",
   329      "query": "set @@innodb_strict_mode = 'OFF'",
   330      "plan": {
   331        "QueryType": "SET",
   332        "Original": "set @@innodb_strict_mode = 'OFF'",
   333        "Instructions": {
   334          "OperatorType": "Set",
   335          "Ops": [
   336            {
   337              "Type": "SysVarIgnore",
   338              "Name": "innodb_strict_mode",
   339              "Expr": "0"
   340            }
   341          ],
   342          "Inputs": [
   343            {
   344              "OperatorType": "SingleRow"
   345            }
   346          ]
   347        }
   348      }
   349    },
   350    {
   351      "comment": "set plan building with string literal",
   352      "query": "set @@innodb_tmpdir = 'OFF'",
   353      "plan": {
   354        "QueryType": "SET",
   355        "Original": "set @@innodb_tmpdir = 'OFF'",
   356        "Instructions": {
   357          "OperatorType": "Set",
   358          "Ops": [
   359            {
   360              "Type": "SysVarIgnore",
   361              "Name": "innodb_tmpdir",
   362              "Expr": "'OFF'"
   363            }
   364          ],
   365          "Inputs": [
   366            {
   367              "OperatorType": "SingleRow"
   368            }
   369          ]
   370        }
   371      }
   372    },
   373    {
   374      "comment": "set system settings",
   375      "query": "set @@ndbinfo_max_bytes = 192",
   376      "plan": "VT12001: unsupported: system setting: ndbinfo_max_bytes"
   377    },
   378    {
   379      "comment": "set autocommit",
   380      "query": "set autocommit = 1",
   381      "plan": {
   382        "QueryType": "SET",
   383        "Original": "set autocommit = 1",
   384        "Instructions": {
   385          "OperatorType": "Set",
   386          "Ops": [
   387            {
   388              "Type": "SysVarAware",
   389              "Name": "autocommit",
   390              "Expr": "INT64(1)"
   391            }
   392          ],
   393          "Inputs": [
   394            {
   395              "OperatorType": "SingleRow"
   396            }
   397          ]
   398        }
   399      }
   400    },
   401    {
   402      "comment": "set autocommit false",
   403      "query": "set autocommit = 0",
   404      "plan": {
   405        "QueryType": "SET",
   406        "Original": "set autocommit = 0",
   407        "Instructions": {
   408          "OperatorType": "Set",
   409          "Ops": [
   410            {
   411              "Type": "SysVarAware",
   412              "Name": "autocommit",
   413              "Expr": "INT64(0)"
   414            }
   415          ],
   416          "Inputs": [
   417            {
   418              "OperatorType": "SingleRow"
   419            }
   420          ]
   421        }
   422      }
   423    },
   424    {
   425      "comment": "set autocommit with backticks",
   426      "query": "set @@session.`autocommit` = 0",
   427      "plan": {
   428        "QueryType": "SET",
   429        "Original": "set @@session.`autocommit` = 0",
   430        "Instructions": {
   431          "OperatorType": "Set",
   432          "Ops": [
   433            {
   434              "Type": "SysVarAware",
   435              "Name": "autocommit",
   436              "Expr": "INT64(0)"
   437            }
   438          ],
   439          "Inputs": [
   440            {
   441              "OperatorType": "SingleRow"
   442            }
   443          ]
   444        }
   445      }
   446    },
   447    {
   448      "comment": "more vitess aware settings",
   449      "query": "set client_found_rows = off, skip_query_plan_cache = ON, sql_select_limit=20",
   450      "plan": {
   451        "QueryType": "SET",
   452        "Original": "set client_found_rows = off, skip_query_plan_cache = ON, sql_select_limit=20",
   453        "Instructions": {
   454          "OperatorType": "Set",
   455          "Ops": [
   456            {
   457              "Type": "SysVarAware",
   458              "Name": "client_found_rows",
   459              "Expr": "INT64(0)"
   460            },
   461            {
   462              "Type": "SysVarAware",
   463              "Name": "skip_query_plan_cache",
   464              "Expr": "INT64(1)"
   465            },
   466            {
   467              "Type": "SysVarAware",
   468              "Name": "sql_select_limit",
   469              "Expr": "INT64(20)"
   470            }
   471          ],
   472          "Inputs": [
   473            {
   474              "OperatorType": "SingleRow"
   475            }
   476          ]
   477        }
   478      }
   479    },
   480    {
   481      "comment": "set autocommit to default",
   482      "query": "set @@autocommit = default",
   483      "plan": {
   484        "QueryType": "SET",
   485        "Original": "set @@autocommit = default",
   486        "Instructions": {
   487          "OperatorType": "Set",
   488          "Ops": [
   489            {
   490              "Type": "SysVarAware",
   491              "Name": "autocommit",
   492              "Expr": "INT64(1)"
   493            }
   494          ],
   495          "Inputs": [
   496            {
   497              "OperatorType": "SingleRow"
   498            }
   499          ]
   500        }
   501      }
   502    },
   503    {
   504      "comment": "set global autocommit to default",
   505      "query": "set global autocommit = off",
   506      "plan": {
   507        "QueryType": "SET",
   508        "Original": "set global autocommit = off",
   509        "Instructions": {
   510          "OperatorType": "Set",
   511          "Ops": [
   512            {
   513              "Type": "SysVarCheckAndIgnore",
   514              "Name": "autocommit",
   515              "Keyspace": {
   516                "Name": "main",
   517                "Sharded": false
   518              },
   519              "TargetDestination": {},
   520              "Expr": "0"
   521            }
   522          ],
   523          "Inputs": [
   524            {
   525              "OperatorType": "SingleRow"
   526            }
   527          ]
   528        }
   529      }
   530    },
   531    {
   532      "comment": "change read only variable",
   533      "query": "set socket = ''",
   534      "plan": "VT03010: variable 'socket' is a read only variable"
   535    },
   536    {
   537      "comment": "set transaction read only",
   538      "query": "set session transaction read only",
   539      "plan": {
   540        "QueryType": "SET",
   541        "Original": "set session transaction read only",
   542        "Instructions": {
   543          "OperatorType": "Set",
   544          "Ops": [
   545            {
   546              "Type": "SysVarAware",
   547              "Name": "transaction_read_only",
   548              "Expr": "INT64(1)"
   549            }
   550          ],
   551          "Inputs": [
   552            {
   553              "OperatorType": "SingleRow"
   554            }
   555          ]
   556        }
   557      }
   558    },
   559    {
   560      "comment": "set transaction isolation level",
   561      "query": "set transaction isolation level read committed",
   562      "plan": {
   563        "QueryType": "SET",
   564        "Original": "set transaction isolation level read committed",
   565        "Instructions": {
   566          "OperatorType": "Set",
   567          "Ops": [
   568            {
   569              "Type": "SysVarSet",
   570              "Name": "transaction_isolation",
   571              "Keyspace": {
   572                "Name": "main",
   573                "Sharded": false
   574              },
   575              "Expr": "'READ-COMMITTED'",
   576              "SupportSetVar": false
   577            }
   578          ],
   579          "Inputs": [
   580            {
   581              "OperatorType": "SingleRow"
   582            }
   583          ]
   584        }
   585      }
   586    },
   587    {
   588      "comment": "set vitess_metadata",
   589      "query": "set @@vitess_metadata.app_v1= '1'",
   590      "plan": {
   591        "QueryType": "SET",
   592        "Original": "set @@vitess_metadata.app_v1= '1'",
   593        "Instructions": {
   594          "OperatorType": "Set",
   595          "Ops": [
   596            {
   597              "Name": "app_v1",
   598              "Value": "1"
   599            }
   600          ],
   601          "Inputs": [
   602            {
   603              "OperatorType": "SingleRow"
   604            }
   605          ]
   606        }
   607      }
   608    }
   609  ]