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

     1  [
     2    {
     3      "comment": "Single information_schema query",
     4      "query": "select TABLE_NAME from information_schema.TABLES",
     5      "plan": {
     6        "QueryType": "SELECT",
     7        "Original": "select TABLE_NAME from information_schema.TABLES",
     8        "Instructions": {
     9          "OperatorType": "Route",
    10          "Variant": "DBA",
    11          "Keyspace": {
    12            "Name": "main",
    13            "Sharded": false
    14          },
    15          "FieldQuery": "select TABLE_NAME from information_schema.`TABLES` where 1 != 1",
    16          "Query": "select TABLE_NAME from information_schema.`TABLES`",
    17          "Table": "information_schema.`TABLES`"
    18        }
    19      }
    20    },
    21    {
    22      "comment": "',' join information_schema",
    23      "query": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b",
    24      "v3-plan": {
    25        "QueryType": "SELECT",
    26        "Original": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b",
    27        "Instructions": {
    28          "OperatorType": "Route",
    29          "Variant": "DBA",
    30          "Keyspace": {
    31            "Name": "main",
    32            "Sharded": false
    33          },
    34          "FieldQuery": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b where 1 != 1",
    35          "Query": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b",
    36          "Table": "information_schema.`TABLES`, information_schema.`COLUMNS`"
    37        }
    38      },
    39      "gen4-plan": {
    40        "QueryType": "SELECT",
    41        "Original": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b",
    42        "Instructions": {
    43          "OperatorType": "Route",
    44          "Variant": "DBA",
    45          "Keyspace": {
    46            "Name": "main",
    47            "Sharded": false
    48          },
    49          "FieldQuery": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b where 1 != 1",
    50          "Query": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b",
    51          "Table": "information_schema.`COLUMNS`, information_schema.`TABLES`"
    52        }
    53      }
    54    },
    55    {
    56      "comment": "information schema query that uses table_schema",
    57      "query": "select column_name from information_schema.columns where table_schema = (select schema())",
    58      "plan": {
    59        "QueryType": "SELECT",
    60        "Original": "select column_name from information_schema.columns where table_schema = (select schema())",
    61        "Instructions": {
    62          "OperatorType": "Route",
    63          "Variant": "DBA",
    64          "Keyspace": {
    65            "Name": "main",
    66            "Sharded": false
    67          },
    68          "FieldQuery": "select column_name from information_schema.`columns` where 1 != 1",
    69          "Query": "select column_name from information_schema.`columns` where table_schema = schema()",
    70          "Table": "information_schema.`columns`"
    71        }
    72      }
    73    },
    74    {
    75      "comment": "information schema join",
    76      "query": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files",
    77      "v3-plan": "VT03019: symbol `tables`.TABLE_SCHEMA not found",
    78      "gen4-plan": {
    79        "QueryType": "SELECT",
    80        "Original": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files",
    81        "Instructions": {
    82          "OperatorType": "Route",
    83          "Variant": "DBA",
    84          "Keyspace": {
    85            "Name": "main",
    86            "Sharded": false
    87          },
    88          "FieldQuery": "select `tables`.TABLE_SCHEMA, files.`STATUS` from information_schema.`tables`, information_schema.files where 1 != 1",
    89          "Query": "select `tables`.TABLE_SCHEMA, files.`STATUS` from information_schema.`tables`, information_schema.files",
    90          "Table": "information_schema.`tables`, information_schema.files"
    91        }
    92      }
    93    },
    94    {
    95      "comment": "access to qualified column names in information_schema",
    96      "query": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'",
    97      "v3-plan": {
    98        "QueryType": "SELECT",
    99        "Original": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'",
   100        "Instructions": {
   101          "OperatorType": "Route",
   102          "Variant": "DBA",
   103          "Keyspace": {
   104            "Name": "main",
   105            "Sharded": false
   106          },
   107          "FieldQuery": "select * from information_schema.`COLUMNS` where 1 != 1",
   108          "Query": "select * from information_schema.`COLUMNS` where information_schema.`COLUMNS`.COLUMN_NAME = 'toto'",
   109          "Table": "information_schema.`COLUMNS`"
   110        }
   111      },
   112      "gen4-plan": {
   113        "QueryType": "SELECT",
   114        "Original": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'",
   115        "Instructions": {
   116          "OperatorType": "Route",
   117          "Variant": "DBA",
   118          "Keyspace": {
   119            "Name": "main",
   120            "Sharded": false
   121          },
   122          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_NAME, COLLATION_NAME, COLUMN_TYPE, COLUMN_KEY, EXTRA, `PRIVILEGES`, COLUMN_COMMENT, GENERATION_EXPRESSION, SRS_ID from information_schema.`COLUMNS` where 1 != 1",
   123          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_NAME, COLLATION_NAME, COLUMN_TYPE, COLUMN_KEY, EXTRA, `PRIVILEGES`, COLUMN_COMMENT, GENERATION_EXPRESSION, SRS_ID from information_schema.`COLUMNS` where `COLUMNS`.COLUMN_NAME = 'toto'",
   124          "Table": "information_schema.`COLUMNS`"
   125        }
   126      }
   127    },
   128    {
   129      "comment": "union of information_schema",
   130      "query": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables",
   131      "plan": {
   132        "QueryType": "SELECT",
   133        "Original": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables",
   134        "Instructions": {
   135          "OperatorType": "Route",
   136          "Variant": "DBA",
   137          "Keyspace": {
   138            "Name": "main",
   139            "Sharded": false
   140          },
   141          "FieldQuery": "select TABLE_NAME from information_schema.`columns` where 1 != 1 union select table_schema from information_schema.`tables` where 1 != 1",
   142          "Query": "select TABLE_NAME from information_schema.`columns` union select table_schema from information_schema.`tables`",
   143          "Table": "information_schema.`columns`"
   144        }
   145      }
   146    },
   147    {
   148      "comment": "union between information_schema tables that should not be merged",
   149      "query": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'",
   150      "v3-plan": {
   151        "QueryType": "SELECT",
   152        "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'",
   153        "Instructions": {
   154          "OperatorType": "Distinct",
   155          "Inputs": [
   156            {
   157              "OperatorType": "Concatenate",
   158              "Inputs": [
   159                {
   160                  "OperatorType": "Route",
   161                  "Variant": "DBA",
   162                  "Keyspace": {
   163                    "Name": "main",
   164                    "Sharded": false
   165                  },
   166                  "FieldQuery": "select * from information_schema.`tables` where 1 != 1",
   167                  "Query": "select * from information_schema.`tables` where table_schema = :__vtschemaname",
   168                  "SysTableTableSchema": "[VARCHAR(\"user\")]",
   169                  "Table": "information_schema.`tables`"
   170                },
   171                {
   172                  "OperatorType": "Route",
   173                  "Variant": "DBA",
   174                  "Keyspace": {
   175                    "Name": "main",
   176                    "Sharded": false
   177                  },
   178                  "FieldQuery": "select * from information_schema.`tables` where 1 != 1",
   179                  "Query": "select * from information_schema.`tables` where table_schema = :__vtschemaname",
   180                  "SysTableTableSchema": "[VARCHAR(\"main\")]",
   181                  "Table": "information_schema.`tables`"
   182                }
   183              ]
   184            }
   185          ]
   186        }
   187      },
   188      "gen4-plan": {
   189        "QueryType": "SELECT",
   190        "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'",
   191        "Instructions": {
   192          "OperatorType": "Distinct",
   193          "Collations": [
   194            "(0:21)",
   195            "(1:22)",
   196            "(2:23)",
   197            "(3:24)",
   198            "(4:25)",
   199            "5: binary",
   200            "(6:26)",
   201            "7: binary",
   202            "8: binary",
   203            "9: binary",
   204            "10: binary",
   205            "11: binary",
   206            "12: binary",
   207            "13: binary",
   208            "(14:27)",
   209            "(15:28)",
   210            "(16:29)",
   211            "(17:30)",
   212            "18: binary",
   213            "(19:31)",
   214            "(20:32)"
   215          ],
   216          "ResultColumns": 21,
   217          "Inputs": [
   218            {
   219              "OperatorType": "Concatenate",
   220              "Inputs": [
   221                {
   222                  "OperatorType": "Route",
   223                  "Variant": "DBA",
   224                  "Keyspace": {
   225                    "Name": "main",
   226                    "Sharded": false
   227                  },
   228                  "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where 1 != 1",
   229                  "Query": "select distinct TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where table_schema = :__vtschemaname",
   230                  "SysTableTableSchema": "[VARCHAR(\"user\")]",
   231                  "Table": "information_schema.`tables`"
   232                },
   233                {
   234                  "OperatorType": "Route",
   235                  "Variant": "DBA",
   236                  "Keyspace": {
   237                    "Name": "main",
   238                    "Sharded": false
   239                  },
   240                  "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where 1 != 1",
   241                  "Query": "select distinct TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where table_schema = :__vtschemaname",
   242                  "SysTableTableSchema": "[VARCHAR(\"main\")]",
   243                  "Table": "information_schema.`tables`"
   244                }
   245              ]
   246            }
   247          ]
   248        }
   249      }
   250    },
   251    {
   252      "comment": "Select from information schema query with two tables that route should be merged",
   253      "query": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME",
   254      "v3-plan": {
   255        "QueryType": "SELECT",
   256        "Original": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME",
   257        "Instructions": {
   258          "OperatorType": "Route",
   259          "Variant": "DBA",
   260          "Keyspace": {
   261            "Name": "main",
   262            "Sharded": false
   263          },
   264          "FieldQuery": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where 1 != 1",
   265          "Query": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.COLUMN_NAME = 'id' and KCU.REFERENCED_TABLE_SCHEMA = :__vtschemaname and KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc",
   266          "SysTableTableName": "[KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]",
   267          "SysTableTableSchema": "[VARCHAR(\"test\"), VARCHAR(\"test\")]",
   268          "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS"
   269        }
   270      },
   271      "gen4-plan": {
   272        "QueryType": "SELECT",
   273        "Original": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME",
   274        "Instructions": {
   275          "OperatorType": "Route",
   276          "Variant": "DBA",
   277          "Keyspace": {
   278            "Name": "main",
   279            "Sharded": false
   280          },
   281          "FieldQuery": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC where 1 != 1",
   282          "Query": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.COLUMN_NAME = 'id' and KCU.REFERENCED_TABLE_SCHEMA = 'test' and KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' and KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc",
   283          "SysTableTableName": "[KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]",
   284          "SysTableTableSchema": "[VARCHAR(\"test\")]",
   285          "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS"
   286        }
   287      }
   288    },
   289    {
   290      "comment": "Select from information schema query with three tables such that route for 2 should be merged but not for the last.",
   291      "query": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM  INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME",
   292      "v3-plan": {
   293        "QueryType": "SELECT",
   294        "Original": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM  INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME",
   295        "Instructions": {
   296          "OperatorType": "Join",
   297          "Variant": "Join",
   298          "JoinColumnIndexes": "L:0,R:0",
   299          "TableName": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS_INFORMATION_SCHEMA.`TABLES`",
   300          "Inputs": [
   301            {
   302              "OperatorType": "Route",
   303              "Variant": "DBA",
   304              "Keyspace": {
   305                "Name": "main",
   306                "Sharded": false
   307              },
   308              "FieldQuery": "select KCU.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where 1 != 1",
   309              "Query": "select KCU.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.TABLE_NAME = :KCU_TABLE_NAME1 order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc",
   310              "SysTableTableName": "[KCU_TABLE_NAME1:VARCHAR(\"data_type_table\"), KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]",
   311              "SysTableTableSchema": "[VARCHAR(\"test\")]",
   312              "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS"
   313            },
   314            {
   315              "OperatorType": "Route",
   316              "Variant": "DBA",
   317              "Keyspace": {
   318                "Name": "main",
   319                "Sharded": false
   320              },
   321              "FieldQuery": "select S.TABLE_NAME from INFORMATION_SCHEMA.`TABLES` as S where 1 != 1",
   322              "Query": "select S.TABLE_NAME from INFORMATION_SCHEMA.`TABLES` as S where S.TABLE_SCHEMA = :__vtschemaname and S.TABLE_NAME = :S_TABLE_NAME",
   323              "SysTableTableName": "[S_TABLE_NAME:VARCHAR(\"sc\")]",
   324              "SysTableTableSchema": "[VARCHAR(\"test\")]",
   325              "Table": "INFORMATION_SCHEMA.`TABLES`"
   326            }
   327          ]
   328        }
   329      },
   330      "gen4-plan": {
   331        "QueryType": "SELECT",
   332        "Original": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM  INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME",
   333        "Instructions": {
   334          "OperatorType": "Route",
   335          "Variant": "DBA",
   336          "Keyspace": {
   337            "Name": "main",
   338            "Sharded": false
   339          },
   340          "FieldQuery": "select KCU.TABLE_NAME, S.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC, INFORMATION_SCHEMA.`TABLES` as S where 1 != 1",
   341          "Query": "select KCU.TABLE_NAME, S.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC, INFORMATION_SCHEMA.`TABLES` as S where S.TABLE_SCHEMA = :__vtschemaname and S.TABLE_NAME = :S_TABLE_NAME and KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc",
   342          "SysTableTableName": "[KCU_TABLE_NAME:VARCHAR(\"data_type_table\"), S_TABLE_NAME:VARCHAR(\"sc\")]",
   343          "SysTableTableSchema": "[VARCHAR(\"test\"), VARCHAR(\"test\")]",
   344          "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS, INFORMATION_SCHEMA.`TABLES`"
   345        }
   346      }
   347    },
   348    {
   349      "comment": "information_schema.routines",
   350      "query": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'",
   351      "plan": {
   352        "QueryType": "SELECT",
   353        "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'",
   354        "Instructions": {
   355          "OperatorType": "Route",
   356          "Variant": "DBA",
   357          "Keyspace": {
   358            "Name": "main",
   359            "Sharded": false
   360          },
   361          "FieldQuery": "select routine_name as `name`, routine_definition as definition from information_schema.routines where 1 != 1",
   362          "Query": "select routine_name as `name`, routine_definition as definition from information_schema.routines where ROUTINE_SCHEMA = :__vtschemaname and ROUTINE_TYPE = 'PROCEDURE'",
   363          "SysTableTableSchema": "[:v1]",
   364          "Table": "information_schema.routines"
   365        }
   366      }
   367    },
   368    {
   369      "comment": "information_schema table sizes",
   370      "query": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?",
   371      "plan": {
   372        "QueryType": "SELECT",
   373        "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?",
   374        "Instructions": {
   375          "OperatorType": "Route",
   376          "Variant": "DBA",
   377          "Keyspace": {
   378            "Name": "main",
   379            "Sharded": false
   380          },
   381          "FieldQuery": "select sum(data_length + index_length) as size from information_schema.`TABLES` where 1 != 1",
   382          "Query": "select sum(data_length + index_length) as size from information_schema.`TABLES` where table_schema = :__vtschemaname",
   383          "SysTableTableSchema": "[:v1]",
   384          "Table": "information_schema.`TABLES`"
   385        }
   386      }
   387    },
   388    {
   389      "comment": "information_schema referential contraints",
   390      "query": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position",
   391      "v3-plan": {
   392        "QueryType": "SELECT",
   393        "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position",
   394        "Instructions": {
   395          "OperatorType": "Route",
   396          "Variant": "DBA",
   397          "Keyspace": {
   398            "Name": "main",
   399            "Sharded": false
   400          },
   401          "FieldQuery": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu join information_schema.referential_constraints as rc on kcu.constraint_name = rc.constraint_name where 1 != 1",
   402          "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu join information_schema.referential_constraints as rc on kcu.constraint_name = rc.constraint_name where kcu.table_schema = :__vtschemaname and rc.constraint_schema = :__vtschemaname and kcu.referenced_column_name is not null order by ordinal_position asc",
   403          "SysTableTableSchema": "[:v1, :v2]",
   404          "Table": "information_schema.key_column_usage, information_schema.referential_constraints"
   405        }
   406      },
   407      "gen4-plan": {
   408        "QueryType": "SELECT",
   409        "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position",
   410        "Instructions": {
   411          "OperatorType": "Route",
   412          "Variant": "DBA",
   413          "Keyspace": {
   414            "Name": "main",
   415            "Sharded": false
   416          },
   417          "FieldQuery": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu, information_schema.referential_constraints as rc where 1 != 1",
   418          "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu, information_schema.referential_constraints as rc where kcu.table_schema = :__vtschemaname and kcu.referenced_column_name is not null and rc.constraint_schema = :__vtschemaname and kcu.constraint_name = rc.constraint_name order by ordinal_position asc",
   419          "SysTableTableSchema": "[:v1, :v2]",
   420          "Table": "information_schema.key_column_usage, information_schema.referential_constraints"
   421        }
   422      }
   423    },
   424    {
   425      "comment": "rails query",
   426      "query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'",
   427      "v3-plan": {
   428        "QueryType": "SELECT",
   429        "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'",
   430        "Instructions": {
   431          "OperatorType": "Route",
   432          "Variant": "DBA",
   433          "Keyspace": {
   434            "Name": "main",
   435            "Sharded": false
   436          },
   437          "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where 1 != 1",
   438          "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :fk_table_name and rc.constraint_schema = database() and rc.table_name = :rc_table_name",
   439          "SysTableTableName": "[fk_table_name:VARCHAR(\":vtg1\"), rc_table_name:VARCHAR(\":vtg1\")]",
   440          "Table": "information_schema.referential_constraints, information_schema.key_column_usage"
   441        }
   442      },
   443      "gen4-plan": {
   444        "QueryType": "SELECT",
   445        "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'",
   446        "Instructions": {
   447          "OperatorType": "Route",
   448          "Variant": "DBA",
   449          "Keyspace": {
   450            "Name": "main",
   451            "Sharded": false
   452          },
   453          "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where 1 != 1",
   454          "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = database() and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :fk_table_name and rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name",
   455          "SysTableTableName": "[fk_table_name:VARCHAR(\":vtg1\"), rc_table_name:VARCHAR(\":vtg1\")]",
   456          "Table": "information_schema.key_column_usage, information_schema.referential_constraints"
   457        }
   458      }
   459    },
   460    {
   461      "comment": "rails_query 2",
   462      "query": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'",
   463      "v3-plan": {
   464        "QueryType": "SELECT",
   465        "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'",
   466        "Instructions": {
   467          "OperatorType": "Route",
   468          "Variant": "DBA",
   469          "Keyspace": {
   470            "Name": "main",
   471            "Sharded": false
   472          },
   473          "FieldQuery": "select * from information_schema.schemata where 1 != 1",
   474          "Query": "select * from information_schema.schemata where schema_name = :__vtschemaname",
   475          "SysTableTableSchema": "[VARCHAR(\"user\")]",
   476          "Table": "information_schema.schemata"
   477        }
   478      },
   479      "gen4-plan": {
   480        "QueryType": "SELECT",
   481        "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'",
   482        "Instructions": {
   483          "OperatorType": "Route",
   484          "Variant": "DBA",
   485          "Keyspace": {
   486            "Name": "main",
   487            "Sharded": false
   488          },
   489          "FieldQuery": "select CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, SQL_PATH, DEFAULT_ENCRYPTION from information_schema.schemata where 1 != 1",
   490          "Query": "select CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, SQL_PATH, DEFAULT_ENCRYPTION from information_schema.schemata where schema_name = :__vtschemaname",
   491          "SysTableTableSchema": "[VARCHAR(\"user\")]",
   492          "Table": "information_schema.schemata"
   493        }
   494      }
   495    },
   496    {
   497      "comment": "rails_query 3",
   498      "query": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'",
   499      "plan": {
   500        "QueryType": "SELECT",
   501        "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'",
   502        "Instructions": {
   503          "OperatorType": "Route",
   504          "Variant": "DBA",
   505          "Keyspace": {
   506            "Name": "main",
   507            "Sharded": false
   508          },
   509          "FieldQuery": "select table_comment from information_schema.`tables` where 1 != 1",
   510          "Query": "select table_comment from information_schema.`tables` where table_schema = :__vtschemaname and table_name = :table_name",
   511          "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]",
   512          "SysTableTableSchema": "[VARCHAR(\"schema_name\")]",
   513          "Table": "information_schema.`tables`"
   514        }
   515      }
   516    },
   517    {
   518      "comment": "rails_query 4",
   519      "query": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'",
   520      "v3-plan": {
   521        "QueryType": "SELECT",
   522        "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'",
   523        "Instructions": {
   524          "OperatorType": "Route",
   525          "Variant": "DBA",
   526          "Keyspace": {
   527            "Name": "main",
   528            "Sharded": false
   529          },
   530          "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where 1 != 1",
   531          "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :fk_table_name and rc.constraint_schema = :__vtschemaname and rc.table_name = :rc_table_name",
   532          "SysTableTableName": "[fk_table_name:VARCHAR(\"table_name\"), rc_table_name:VARCHAR(\"table_name\")]",
   533          "SysTableTableSchema": "[VARCHAR(\"table_schema\"), VARCHAR(\"table_schema\")]",
   534          "Table": "information_schema.referential_constraints, information_schema.key_column_usage"
   535        }
   536      },
   537      "gen4-plan": {
   538        "QueryType": "SELECT",
   539        "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'",
   540        "Instructions": {
   541          "OperatorType": "Route",
   542          "Variant": "DBA",
   543          "Keyspace": {
   544            "Name": "main",
   545            "Sharded": false
   546          },
   547          "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where 1 != 1",
   548          "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = :__vtschemaname and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :fk_table_name and rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name",
   549          "SysTableTableName": "[fk_table_name:VARCHAR(\"table_name\"), rc_table_name:VARCHAR(\"table_name\")]",
   550          "SysTableTableSchema": "[VARCHAR(\"table_schema\"), VARCHAR(\"table_schema\")]",
   551          "Table": "information_schema.key_column_usage, information_schema.referential_constraints"
   552        }
   553      }
   554    },
   555    {
   556      "comment": "rails_query 5",
   557      "query": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'",
   558      "v3-plan": {
   559        "QueryType": "SELECT",
   560        "Original": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'",
   561        "Instructions": {
   562          "OperatorType": "Route",
   563          "Variant": "DBA",
   564          "Keyspace": {
   565            "Name": "main",
   566            "Sharded": false
   567          },
   568          "FieldQuery": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc join information_schema.table_constraints as tc using (constraint_schema, constraint_name) where 1 != 1",
   569          "Query": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc join information_schema.table_constraints as tc using (constraint_schema, constraint_name) where tc.table_schema = :__vtschemaname and tc.table_name = :tc_table_name and cc.constraint_schema = :__vtschemaname",
   570          "SysTableTableName": "[tc_table_name:VARCHAR(\"table_name\")]",
   571          "SysTableTableSchema": "[VARCHAR(\"table_schema\"), VARCHAR(\"constraint_schema\")]",
   572          "Table": "information_schema.check_constraints, information_schema.table_constraints"
   573        }
   574      },
   575      "gen4-plan": {
   576        "QueryType": "SELECT",
   577        "Original": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'",
   578        "Instructions": {
   579          "OperatorType": "Route",
   580          "Variant": "DBA",
   581          "Keyspace": {
   582            "Name": "main",
   583            "Sharded": false
   584          },
   585          "FieldQuery": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc, information_schema.table_constraints as tc where 1 != 1",
   586          "Query": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc, information_schema.table_constraints as tc where cc.constraint_schema = :__vtschemaname and tc.table_schema = :__vtschemaname and tc.table_name = :tc_table_name and cc.constraint_schema = tc.constraint_schema and cc.constraint_name = tc.constraint_name",
   587          "SysTableTableName": "[tc_table_name:VARCHAR(\"table_name\")]",
   588          "SysTableTableSchema": "[VARCHAR(\"constraint_schema\"), VARCHAR(\"table_schema\")]",
   589          "Table": "information_schema.check_constraints, information_schema.table_constraints"
   590        }
   591      }
   592    },
   593    {
   594      "comment": "rails_query 6",
   595      "query": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index",
   596      "plan": {
   597        "QueryType": "SELECT",
   598        "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index",
   599        "Instructions": {
   600          "OperatorType": "Route",
   601          "Variant": "DBA",
   602          "Keyspace": {
   603            "Name": "main",
   604            "Sharded": false
   605          },
   606          "FieldQuery": "select column_name from information_schema.statistics where 1 != 1",
   607          "Query": "select column_name from information_schema.statistics where index_name = 'PRIMARY' and table_schema = :__vtschemaname and table_name = :table_name order by seq_in_index asc",
   608          "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]",
   609          "SysTableTableSchema": "[VARCHAR(\"table_schema\")]",
   610          "Table": "information_schema.statistics"
   611        }
   612      }
   613    },
   614    {
   615      "comment": "rails_query 7",
   616      "query": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'",
   617      "plan": {
   618        "QueryType": "SELECT",
   619        "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'",
   620        "Instructions": {
   621          "OperatorType": "Route",
   622          "Variant": "DBA",
   623          "Keyspace": {
   624            "Name": "main",
   625            "Sharded": false
   626          },
   627          "FieldQuery": "select generation_expression from information_schema.`columns` where 1 != 1",
   628          "Query": "select generation_expression from information_schema.`columns` where table_schema = :__vtschemaname and table_name = :table_name and column_name = 'column_name'",
   629          "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]",
   630          "SysTableTableSchema": "[VARCHAR(\"table_schema\")]",
   631          "Table": "information_schema.`columns`"
   632        }
   633      }
   634    },
   635    {
   636      "comment": "rails_query 8",
   637      "query": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'",
   638      "plan": {
   639        "QueryType": "SELECT",
   640        "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'",
   641        "Instructions": {
   642          "OperatorType": "Route",
   643          "Variant": "DBA",
   644          "Keyspace": {
   645            "Name": "main",
   646            "Sharded": false
   647          },
   648          "FieldQuery": "select id from information_schema.`processlist` where 1 != 1",
   649          "Query": "select id from information_schema.`processlist` where info like '% FOR UPDATE'",
   650          "Table": "information_schema.`processlist`"
   651        }
   652      }
   653    },
   654    {
   655      "comment": "rails_query 9",
   656      "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery",
   657      "v3-plan": {
   658        "QueryType": "SELECT",
   659        "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery",
   660        "Instructions": {
   661          "OperatorType": "Route",
   662          "Variant": "DBA",
   663          "Keyspace": {
   664            "Name": "main",
   665            "Sharded": false
   666          },
   667          "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1",
   668          "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery",
   669          "SysTableTableSchema": "[VARCHAR(\"table_schema\")]",
   670          "Table": "information_schema.`tables`"
   671        }
   672      },
   673      "gen4-plan": {
   674        "QueryType": "SELECT",
   675        "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery",
   676        "Instructions": {
   677          "OperatorType": "Route",
   678          "Variant": "DBA",
   679          "Keyspace": {
   680            "Name": "main",
   681            "Sharded": false
   682          },
   683          "FieldQuery": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1",
   684          "Query": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery",
   685          "SysTableTableSchema": "[VARCHAR(\"table_schema\")]",
   686          "Table": "information_schema.`tables`"
   687        }
   688      }
   689    },
   690    {
   691      "comment": "rails_query 10",
   692      "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'",
   693      "v3-plan": {
   694        "QueryType": "SELECT",
   695        "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'",
   696        "Instructions": {
   697          "OperatorType": "Route",
   698          "Variant": "DBA",
   699          "Keyspace": {
   700            "Name": "main",
   701            "Sharded": false
   702          },
   703          "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1",
   704          "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery where _subquery.table_type = 'table_type' and _subquery.table_name = :_subquery_table_name",
   705          "SysTableTableName": "[_subquery_table_name:VARCHAR(\"table_name\")]",
   706          "SysTableTableSchema": "[VARCHAR(\"table_schema\")]",
   707          "Table": "information_schema.`tables`"
   708        }
   709      },
   710      "gen4-plan": {
   711        "QueryType": "SELECT",
   712        "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'",
   713        "Instructions": {
   714          "OperatorType": "Route",
   715          "Variant": "DBA",
   716          "Keyspace": {
   717            "Name": "main",
   718            "Sharded": false
   719          },
   720          "FieldQuery": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1",
   721          "Query": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where table_schema = :__vtschemaname and table_type = 'table_type' and table_name = 'table_name') as _subquery",
   722          "SysTableTableSchema": "[VARCHAR(\"table_schema\")]",
   723          "Table": "information_schema.`tables`"
   724        }
   725      }
   726    },
   727    {
   728      "comment": "two predicates specifying the database for the same table work if the database is the same",
   729      "query": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc  WHERE cc.constraint_schema = 'a' AND cc.`CONSTRAINT_CATALOG` = 'a'",
   730      "plan": {
   731        "QueryType": "SELECT",
   732        "Original": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc  WHERE cc.constraint_schema = 'a' AND cc.`CONSTRAINT_CATALOG` = 'a'",
   733        "Instructions": {
   734          "OperatorType": "Route",
   735          "Variant": "DBA",
   736          "Keyspace": {
   737            "Name": "main",
   738            "Sharded": false
   739          },
   740          "FieldQuery": "select cc.constraint_name as `name` from information_schema.check_constraints as cc where 1 != 1",
   741          "Query": "select cc.constraint_name as `name` from information_schema.check_constraints as cc where cc.constraint_schema = :__vtschemaname and cc.CONSTRAINT_CATALOG = 'a'",
   742          "SysTableTableSchema": "[VARCHAR(\"a\")]",
   743          "Table": "information_schema.check_constraints"
   744        }
   745      }
   746    },
   747    {
   748      "comment": "system schema in where clause of information_schema query",
   749      "query": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'",
   750      "plan": {
   751        "QueryType": "SELECT",
   752        "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'",
   753        "Instructions": {
   754          "OperatorType": "Route",
   755          "Variant": "DBA",
   756          "Keyspace": {
   757            "Name": "main",
   758            "Sharded": false
   759          },
   760          "FieldQuery": "select count(*) from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   761          "Query": "select count(*) from INFORMATION_SCHEMA.`TABLES` where table_schema = :__vtschemaname and table_name = :table_name",
   762          "SysTableTableName": "[table_name:VARCHAR(\"foo\")]",
   763          "SysTableTableSchema": "[VARCHAR(\"performance_schema\")]",
   764          "Table": "INFORMATION_SCHEMA.`TABLES`"
   765        }
   766      }
   767    },
   768    {
   769      "comment": "subquery of information_schema with itself",
   770      "query": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)",
   771      "v3-plan": "VT03019: symbol `TABLES`.`CHECKSUM` not found",
   772      "gen4-plan": {
   773        "QueryType": "SELECT",
   774        "Original": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)",
   775        "Instructions": {
   776          "OperatorType": "Route",
   777          "Variant": "DBA",
   778          "Keyspace": {
   779            "Name": "main",
   780            "Sharded": false
   781          },
   782          "FieldQuery": "select `TABLES`.`CHECKSUM` from information_schema.`TABLES` where 1 != 1",
   783          "Query": "select `TABLES`.`CHECKSUM` from information_schema.`TABLES` where TABLE_NAME in (select TABLE_NAME from information_schema.`COLUMNS`)",
   784          "Table": "information_schema.`TABLES`"
   785        }
   786      }
   787    },
   788    {
   789      "comment": "query trying to query two different keyspaces at the same time",
   790      "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'",
   791      "v3-plan": {
   792        "QueryType": "SELECT",
   793        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'",
   794        "Instructions": {
   795          "OperatorType": "Route",
   796          "Variant": "DBA",
   797          "Keyspace": {
   798            "Name": "main",
   799            "Sharded": false
   800          },
   801          "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   802          "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname",
   803          "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"main\")]",
   804          "Table": "INFORMATION_SCHEMA.`TABLES`"
   805        }
   806      },
   807      "gen4-plan": {
   808        "QueryType": "SELECT",
   809        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'",
   810        "Instructions": {
   811          "OperatorType": "Route",
   812          "Variant": "DBA",
   813          "Keyspace": {
   814            "Name": "main",
   815            "Sharded": false
   816          },
   817          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   818          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname",
   819          "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"main\")]",
   820          "Table": "INFORMATION_SCHEMA.`TABLES`"
   821        }
   822      }
   823    },
   824    {
   825      "comment": "information_schema query using database() func",
   826      "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()",
   827      "v3-plan": {
   828        "QueryType": "SELECT",
   829        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()",
   830        "Instructions": {
   831          "OperatorType": "Route",
   832          "Variant": "DBA",
   833          "Keyspace": {
   834            "Name": "main",
   835            "Sharded": false
   836          },
   837          "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   838          "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()",
   839          "Table": "INFORMATION_SCHEMA.`TABLES`"
   840        }
   841      },
   842      "gen4-plan": {
   843        "QueryType": "SELECT",
   844        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()",
   845        "Instructions": {
   846          "OperatorType": "Route",
   847          "Variant": "DBA",
   848          "Keyspace": {
   849            "Name": "main",
   850            "Sharded": false
   851          },
   852          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   853          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()",
   854          "Table": "INFORMATION_SCHEMA.`TABLES`"
   855        }
   856      }
   857    },
   858    {
   859      "comment": "table_schema predicate the wrong way around",
   860      "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA",
   861      "v3-plan": {
   862        "QueryType": "SELECT",
   863        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA",
   864        "Instructions": {
   865          "OperatorType": "Route",
   866          "Variant": "DBA",
   867          "Keyspace": {
   868            "Name": "main",
   869            "Sharded": false
   870          },
   871          "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   872          "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname",
   873          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   874          "Table": "INFORMATION_SCHEMA.`TABLES`"
   875        }
   876      },
   877      "gen4-plan": {
   878        "QueryType": "SELECT",
   879        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA",
   880        "Instructions": {
   881          "OperatorType": "Route",
   882          "Variant": "DBA",
   883          "Keyspace": {
   884            "Name": "main",
   885            "Sharded": false
   886          },
   887          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   888          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname",
   889          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   890          "Table": "INFORMATION_SCHEMA.`TABLES`"
   891        }
   892      }
   893    },
   894    {
   895      "comment": "table_name predicate against a routed table",
   896      "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'",
   897      "v3-plan": {
   898        "QueryType": "SELECT",
   899        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'",
   900        "Instructions": {
   901          "OperatorType": "Route",
   902          "Variant": "DBA",
   903          "Keyspace": {
   904            "Name": "main",
   905            "Sharded": false
   906          },
   907          "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   908          "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME",
   909          "SysTableTableName": "[TABLE_NAME:VARCHAR(\"route1\")]",
   910          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   911          "Table": "INFORMATION_SCHEMA.`TABLES`"
   912        }
   913      },
   914      "gen4-plan": {
   915        "QueryType": "SELECT",
   916        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'",
   917        "Instructions": {
   918          "OperatorType": "Route",
   919          "Variant": "DBA",
   920          "Keyspace": {
   921            "Name": "main",
   922            "Sharded": false
   923          },
   924          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   925          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME",
   926          "SysTableTableName": "[TABLE_NAME:VARCHAR(\"route1\")]",
   927          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   928          "Table": "INFORMATION_SCHEMA.`TABLES`"
   929        }
   930      }
   931    },
   932    {
   933      "comment": "information_schema query with additional predicates",
   934      "query": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42",
   935      "plan": {
   936        "QueryType": "SELECT",
   937        "Original": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42",
   938        "Instructions": {
   939          "OperatorType": "Route",
   940          "Variant": "DBA",
   941          "Keyspace": {
   942            "Name": "main",
   943            "Sharded": false
   944          },
   945          "FieldQuery": "select TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   946          "Query": "select TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and DATA_FREE = 42",
   947          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   948          "Table": "INFORMATION_SCHEMA.`TABLES`"
   949        }
   950      }
   951    },
   952    {
   953      "comment": "able to isolate table_schema value even when hidden inside of ORs",
   954      "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')",
   955      "v3-plan": {
   956        "QueryType": "SELECT",
   957        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')",
   958        "Instructions": {
   959          "OperatorType": "Route",
   960          "Variant": "DBA",
   961          "Keyspace": {
   962            "Name": "main",
   963            "Sharded": false
   964          },
   965          "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   966          "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and (DATA_FREE = 42 or `CHECKSUM` = 'value')",
   967          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   968          "Table": "INFORMATION_SCHEMA.`TABLES`"
   969        }
   970      },
   971      "gen4-plan": {
   972        "QueryType": "SELECT",
   973        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')",
   974        "Instructions": {
   975          "OperatorType": "Route",
   976          "Variant": "DBA",
   977          "Keyspace": {
   978            "Name": "main",
   979            "Sharded": false
   980          },
   981          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
   982          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and (DATA_FREE = 42 or `CHECKSUM` = 'value')",
   983          "SysTableTableSchema": "[VARCHAR(\"ks\")]",
   984          "Table": "INFORMATION_SCHEMA.`TABLES`"
   985        }
   986      }
   987    },
   988    {
   989      "comment": "expand star with information schema",
   990      "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x",
   991      "v3-plan": {
   992        "QueryType": "SELECT",
   993        "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x",
   994        "Instructions": {
   995          "OperatorType": "Route",
   996          "Variant": "DBA",
   997          "Keyspace": {
   998            "Name": "main",
   999            "Sharded": false
  1000          },
  1001          "FieldQuery": "select x.table_name from (select a.* from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1",
  1002          "Query": "select x.table_name from (select a.* from information_schema.key_column_usage as a) as x",
  1003          "Table": "information_schema.key_column_usage"
  1004        }
  1005      },
  1006      "gen4-plan": {
  1007        "QueryType": "SELECT",
  1008        "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x",
  1009        "Instructions": {
  1010          "OperatorType": "Route",
  1011          "Variant": "DBA",
  1012          "Keyspace": {
  1013            "Name": "main",
  1014            "Sharded": false
  1015          },
  1016          "FieldQuery": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1",
  1017          "Query": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a) as x",
  1018          "Table": "information_schema.key_column_usage"
  1019        }
  1020      }
  1021    },
  1022    {
  1023      "comment": "expand star with information schema in a derived table",
  1024      "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id",
  1025      "v3-plan": {
  1026        "QueryType": "SELECT",
  1027        "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id",
  1028        "Instructions": {
  1029          "OperatorType": "Join",
  1030          "Variant": "Join",
  1031          "JoinColumnIndexes": "L:0",
  1032          "JoinVars": {
  1033            "x_COLUMN_NAME": 1
  1034          },
  1035          "TableName": "information_schema.key_column_usage_`user`",
  1036          "Inputs": [
  1037            {
  1038              "OperatorType": "Route",
  1039              "Variant": "DBA",
  1040              "Keyspace": {
  1041                "Name": "main",
  1042                "Sharded": false
  1043              },
  1044              "FieldQuery": "select x.table_name, x.COLUMN_NAME from (select a.* from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1",
  1045              "Query": "select x.table_name, x.COLUMN_NAME from (select a.* from information_schema.key_column_usage as a) as x",
  1046              "Table": "information_schema.key_column_usage"
  1047            },
  1048            {
  1049              "OperatorType": "Route",
  1050              "Variant": "EqualUnique",
  1051              "Keyspace": {
  1052                "Name": "user",
  1053                "Sharded": true
  1054              },
  1055              "FieldQuery": "select 1 from `user` where 1 != 1",
  1056              "Query": "select 1 from `user` where `user`.id = :x_COLUMN_NAME",
  1057              "Table": "`user`",
  1058              "Values": [
  1059                ":x_COLUMN_NAME"
  1060              ],
  1061              "Vindex": "user_index"
  1062            }
  1063          ]
  1064        }
  1065      },
  1066      "gen4-plan": {
  1067        "QueryType": "SELECT",
  1068        "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id",
  1069        "Instructions": {
  1070          "OperatorType": "Join",
  1071          "Variant": "Join",
  1072          "JoinColumnIndexes": "L:1",
  1073          "JoinVars": {
  1074            "x_COLUMN_NAME": 0
  1075          },
  1076          "TableName": "information_schema.key_column_usage_`user`",
  1077          "Inputs": [
  1078            {
  1079              "OperatorType": "Route",
  1080              "Variant": "DBA",
  1081              "Keyspace": {
  1082                "Name": "main",
  1083                "Sharded": false
  1084              },
  1085              "FieldQuery": "select x.COLUMN_NAME, x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1",
  1086              "Query": "select x.COLUMN_NAME, x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a) as x",
  1087              "Table": "information_schema.key_column_usage"
  1088            },
  1089            {
  1090              "OperatorType": "Route",
  1091              "Variant": "EqualUnique",
  1092              "Keyspace": {
  1093                "Name": "user",
  1094                "Sharded": true
  1095              },
  1096              "FieldQuery": "select 1 from `user` where 1 != 1",
  1097              "Query": "select 1 from `user` where `user`.id = :x_COLUMN_NAME",
  1098              "Table": "`user`",
  1099              "Values": [
  1100                ":x_COLUMN_NAME"
  1101              ],
  1102              "Vindex": "user_index"
  1103            }
  1104          ]
  1105        },
  1106        "TablesUsed": [
  1107          "user.user"
  1108        ]
  1109      }
  1110    },
  1111    {
  1112      "comment": "join of information_schema queries with select stars exprs",
  1113      "query": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS a, information_schema.CHARACTER_SETS b",
  1114      "v3-plan": {
  1115        "QueryType": "SELECT",
  1116        "Original": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS a, information_schema.CHARACTER_SETS b",
  1117        "Instructions": {
  1118          "OperatorType": "Route",
  1119          "Variant": "DBA",
  1120          "Keyspace": {
  1121            "Name": "main",
  1122            "Sharded": false
  1123          },
  1124          "FieldQuery": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS as a, information_schema.CHARACTER_SETS as b where 1 != 1",
  1125          "Query": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS as a, information_schema.CHARACTER_SETS as b",
  1126          "Table": "information_schema.CHECK_CONSTRAINTS, information_schema.CHARACTER_SETS"
  1127        }
  1128      },
  1129      "gen4-plan": {
  1130        "QueryType": "SELECT",
  1131        "Original": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS a, information_schema.CHARACTER_SETS b",
  1132        "Instructions": {
  1133          "OperatorType": "Route",
  1134          "Variant": "DBA",
  1135          "Keyspace": {
  1136            "Name": "main",
  1137            "Sharded": false
  1138          },
  1139          "FieldQuery": "select a.CONSTRAINT_CATALOG as CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA as CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME as CONSTRAINT_NAME, a.CHECK_CLAUSE as CHECK_CLAUSE, b.CHARACTER_SET_NAME as CHARACTER_SET_NAME, b.DEFAULT_COLLATE_NAME as DEFAULT_COLLATE_NAME, b.DESCRIPTION as DESCRIPTION, b.MAXLEN as MAXLEN from information_schema.CHECK_CONSTRAINTS as a, information_schema.CHARACTER_SETS as b where 1 != 1",
  1140          "Query": "select a.CONSTRAINT_CATALOG as CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA as CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME as CONSTRAINT_NAME, a.CHECK_CLAUSE as CHECK_CLAUSE, b.CHARACTER_SET_NAME as CHARACTER_SET_NAME, b.DEFAULT_COLLATE_NAME as DEFAULT_COLLATE_NAME, b.DESCRIPTION as DESCRIPTION, b.MAXLEN as MAXLEN from information_schema.CHECK_CONSTRAINTS as a, information_schema.CHARACTER_SETS as b",
  1141          "Table": "information_schema.CHARACTER_SETS, information_schema.CHECK_CONSTRAINTS"
  1142        }
  1143      }
  1144    },
  1145    {
  1146      "comment": "join two routes with SysTableTableName entries in LHS and RHS",
  1147      "query": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b",
  1148      "v3-plan": {
  1149        "QueryType": "SELECT",
  1150        "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b",
  1151        "Instructions": {
  1152          "OperatorType": "Route",
  1153          "Variant": "DBA",
  1154          "Keyspace": {
  1155            "Name": "main",
  1156            "Sharded": false
  1157          },
  1158          "FieldQuery": "select a.table_name from (select * from information_schema.key_column_usage as a where 1 != 1) as a join (select * from information_schema.referential_constraints where 1 != 1) as b where 1 != 1",
  1159          "Query": "select a.table_name from (select * from information_schema.key_column_usage as a where a.table_name = :a_table_name) as a join (select * from information_schema.referential_constraints where table_name = :table_name) as b",
  1160          "SysTableTableName": "[a_table_name:VARCHAR(\"users\"), table_name:VARCHAR(\"users\")]",
  1161          "Table": "information_schema.key_column_usage, information_schema.referential_constraints"
  1162        }
  1163      },
  1164      "gen4-plan": {
  1165        "QueryType": "SELECT",
  1166        "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b",
  1167        "Instructions": {
  1168          "OperatorType": "Route",
  1169          "Variant": "DBA",
  1170          "Keyspace": {
  1171            "Name": "main",
  1172            "Sharded": false
  1173          },
  1174          "FieldQuery": "select a.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as a, (select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE, TABLE_NAME, REFERENCED_TABLE_NAME from information_schema.referential_constraints where 1 != 1) as b where 1 != 1",
  1175          "Query": "select a.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where a.table_name = :a_table_name) as a, (select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE, TABLE_NAME, REFERENCED_TABLE_NAME from information_schema.referential_constraints where table_name = :table_name) as b",
  1176          "SysTableTableName": "[a_table_name:VARCHAR(\"users\"), table_name:VARCHAR(\"users\")]",
  1177          "Table": "information_schema.key_column_usage, information_schema.referential_constraints"
  1178        }
  1179      }
  1180    },
  1181    {
  1182      "comment": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t",
  1183      "query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t",
  1184      "v3-plan": "VT12001: unsupported: cross-shard query with aggregates",
  1185      "gen4-plan": {
  1186        "QueryType": "SELECT",
  1187        "Original": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t",
  1188        "Instructions": {
  1189          "OperatorType": "Route",
  1190          "Variant": "DBA",
  1191          "Keyspace": {
  1192            "Name": "main",
  1193            "Sharded": false
  1194          },
  1195          "FieldQuery": "select sum(found) from (select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)) as t where 1 != 1",
  1196          "Query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)) as t",
  1197          "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"music\")]",
  1198          "Table": "information_schema.`tables`"
  1199        }
  1200      }
  1201    },
  1202    {
  1203      "comment": "union as a derived table",
  1204      "query": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t",
  1205      "v3-plan": {
  1206        "QueryType": "SELECT",
  1207        "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t",
  1208        "Instructions": {
  1209          "OperatorType": "SimpleProjection",
  1210          "Columns": [
  1211            0
  1212          ],
  1213          "Inputs": [
  1214            {
  1215              "OperatorType": "Concatenate",
  1216              "Inputs": [
  1217                {
  1218                  "OperatorType": "Route",
  1219                  "Variant": "DBA",
  1220                  "Keyspace": {
  1221                    "Name": "main",
  1222                    "Sharded": false
  1223                  },
  1224                  "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1",
  1225                  "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname",
  1226                  "SysTableTableSchema": "[VARCHAR(\"music\")]",
  1227                  "Table": "information_schema.`tables`"
  1228                },
  1229                {
  1230                  "OperatorType": "Route",
  1231                  "Variant": "DBA",
  1232                  "Keyspace": {
  1233                    "Name": "main",
  1234                    "Sharded": false
  1235                  },
  1236                  "FieldQuery": "select 1 as found from information_schema.views where 1 != 1",
  1237                  "Query": "select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1",
  1238                  "SysTableTableSchema": "[VARCHAR(\"music\")]",
  1239                  "Table": "information_schema.views"
  1240                }
  1241              ]
  1242            }
  1243          ]
  1244        }
  1245      },
  1246      "gen4-plan": {
  1247        "QueryType": "SELECT",
  1248        "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t",
  1249        "Instructions": {
  1250          "OperatorType": "Route",
  1251          "Variant": "DBA",
  1252          "Keyspace": {
  1253            "Name": "main",
  1254            "Sharded": false
  1255          },
  1256          "FieldQuery": "select found from (select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)) as t where 1 != 1",
  1257          "Query": "select found from (select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)) as t",
  1258          "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"music\")]",
  1259          "Table": "information_schema.`tables`"
  1260        }
  1261      }
  1262    },
  1263    {
  1264      "comment": "merge system schema queries as long as they have any same table_schema",
  1265      "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)",
  1266      "v3-plan": {
  1267        "QueryType": "SELECT",
  1268        "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)",
  1269        "Instructions": {
  1270          "OperatorType": "Concatenate",
  1271          "Inputs": [
  1272            {
  1273              "OperatorType": "Route",
  1274              "Variant": "DBA",
  1275              "Keyspace": {
  1276                "Name": "main",
  1277                "Sharded": false
  1278              },
  1279              "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1",
  1280              "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname",
  1281              "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\")]",
  1282              "Table": "information_schema.`tables`"
  1283            },
  1284            {
  1285              "OperatorType": "Route",
  1286              "Variant": "DBA",
  1287              "Keyspace": {
  1288                "Name": "main",
  1289                "Sharded": false
  1290              },
  1291              "FieldQuery": "select 1 as found from information_schema.views where 1 != 1",
  1292              "Query": "select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1",
  1293              "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"user\")]",
  1294              "Table": "information_schema.views"
  1295            }
  1296          ]
  1297        }
  1298      },
  1299      "gen4-plan": {
  1300        "QueryType": "SELECT",
  1301        "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)",
  1302        "Instructions": {
  1303          "OperatorType": "Route",
  1304          "Variant": "DBA",
  1305          "Keyspace": {
  1306            "Name": "main",
  1307            "Sharded": false
  1308          },
  1309          "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)",
  1310          "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)",
  1311          "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\"), VARCHAR(\"music\"), VARCHAR(\"user\")]",
  1312          "Table": "information_schema.`tables`"
  1313        }
  1314      }
  1315    },
  1316    {
  1317      "comment": "merge system schema queries as long as they have any same table_name",
  1318      "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)",
  1319      "v3-plan": {
  1320        "QueryType": "SELECT",
  1321        "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)",
  1322        "Instructions": {
  1323          "OperatorType": "Concatenate",
  1324          "Inputs": [
  1325            {
  1326              "OperatorType": "Route",
  1327              "Variant": "DBA",
  1328              "Keyspace": {
  1329                "Name": "main",
  1330                "Sharded": false
  1331              },
  1332              "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1",
  1333              "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname",
  1334              "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\")]",
  1335              "Table": "information_schema.`tables`"
  1336            },
  1337            {
  1338              "OperatorType": "Route",
  1339              "Variant": "DBA",
  1340              "Keyspace": {
  1341                "Name": "main",
  1342                "Sharded": false
  1343              },
  1344              "FieldQuery": "select 1 as found from information_schema.views where 1 != 1",
  1345              "Query": "select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1",
  1346              "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"user\")]",
  1347              "Table": "information_schema.views"
  1348            }
  1349          ]
  1350        }
  1351      },
  1352      "gen4-plan": {
  1353        "QueryType": "SELECT",
  1354        "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)",
  1355        "Instructions": {
  1356          "OperatorType": "Route",
  1357          "Variant": "DBA",
  1358          "Keyspace": {
  1359            "Name": "main",
  1360            "Sharded": false
  1361          },
  1362          "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)",
  1363          "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)",
  1364          "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\"), VARCHAR(\"music\"), VARCHAR(\"user\")]",
  1365          "Table": "information_schema.`tables`"
  1366        }
  1367      }
  1368    },
  1369    {
  1370      "comment": "merge union subquery with outer query referencing the same system schemas",
  1371      "query": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))",
  1372      "v3-plan": {
  1373        "QueryType": "SELECT",
  1374        "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))",
  1375        "Instructions": {
  1376          "OperatorType": "Subquery",
  1377          "Variant": "PulloutExists",
  1378          "PulloutVars": [
  1379            "__sq_has_values1",
  1380            "__sq1"
  1381          ],
  1382          "Inputs": [
  1383            {
  1384              "OperatorType": "Concatenate",
  1385              "Inputs": [
  1386                {
  1387                  "OperatorType": "Route",
  1388                  "Variant": "DBA",
  1389                  "Keyspace": {
  1390                    "Name": "main",
  1391                    "Sharded": false
  1392                  },
  1393                  "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1",
  1394                  "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name2 and table_name = :table_name3",
  1395                  "SysTableTableName": "[table_name2:VARCHAR(\"music\"), table_name3:VARCHAR(\"Music\")]",
  1396                  "Table": "information_schema.`tables`"
  1397                },
  1398                {
  1399                  "OperatorType": "Route",
  1400                  "Variant": "DBA",
  1401                  "Keyspace": {
  1402                    "Name": "main",
  1403                    "Sharded": false
  1404                  },
  1405                  "FieldQuery": "select 1 as found from information_schema.views where 1 != 1",
  1406                  "Query": "select 1 as found from information_schema.views where table_name = :table_name4 and table_name = :table_name5 limit 1",
  1407                  "SysTableTableName": "[table_name4:VARCHAR(\"music\"), table_name5:VARCHAR(\"user\")]",
  1408                  "Table": "information_schema.views"
  1409                }
  1410              ]
  1411            },
  1412            {
  1413              "OperatorType": "Route",
  1414              "Variant": "DBA",
  1415              "Keyspace": {
  1416                "Name": "main",
  1417                "Sharded": false
  1418              },
  1419              "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1",
  1420              "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name and table_name = :table_name1 and :__sq_has_values1",
  1421              "SysTableTableName": "[table_name1:VARCHAR(\"Music\"), table_name:VARCHAR(\"music\")]",
  1422              "Table": "information_schema.`tables`"
  1423            }
  1424          ]
  1425        }
  1426      },
  1427      "gen4-plan": {
  1428        "QueryType": "SELECT",
  1429        "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))",
  1430        "Instructions": {
  1431          "OperatorType": "Route",
  1432          "Variant": "DBA",
  1433          "Keyspace": {
  1434            "Name": "main",
  1435            "Sharded": false
  1436          },
  1437          "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1",
  1438          "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name and table_name = :table_name1 and exists (select 1 as found from information_schema.`tables` where table_name = :table_name2 and table_name = :table_name3 union all (select 1 as found from information_schema.views where table_name = :table_name4 and table_name = :table_name5 limit 1))",
  1439          "SysTableTableName": "[table_name1:VARCHAR(\"Music\"), table_name2:VARCHAR(\"music\"), table_name3:VARCHAR(\"Music\"), table_name4:VARCHAR(\"music\"), table_name5:VARCHAR(\"user\"), table_name:VARCHAR(\"music\")]",
  1440          "Table": "information_schema.`tables`"
  1441        }
  1442      }
  1443    },
  1444    {
  1445      "comment": "merge even one side have schema name in derived table",
  1446      "query": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt",
  1447      "v3-plan": {
  1448        "QueryType": "SELECT",
  1449        "Original": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt",
  1450        "Instructions": {
  1451          "OperatorType": "SimpleProjection",
  1452          "Columns": [
  1453            0
  1454          ],
  1455          "Inputs": [
  1456            {
  1457              "OperatorType": "Distinct",
  1458              "Inputs": [
  1459                {
  1460                  "OperatorType": "Concatenate",
  1461                  "Inputs": [
  1462                    {
  1463                      "OperatorType": "Route",
  1464                      "Variant": "DBA",
  1465                      "Keyspace": {
  1466                        "Name": "main",
  1467                        "Sharded": false
  1468                      },
  1469                      "FieldQuery": "select TABLE_NAME from information_schema.`tables` as t where 1 != 1",
  1470                      "Query": "select TABLE_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname",
  1471                      "SysTableTableSchema": "[VARCHAR(\"a\")]",
  1472                      "Table": "information_schema.`tables`"
  1473                    },
  1474                    {
  1475                      "OperatorType": "Route",
  1476                      "Variant": "DBA",
  1477                      "Keyspace": {
  1478                        "Name": "main",
  1479                        "Sharded": false
  1480                      },
  1481                      "FieldQuery": "select TABLE_NAME from information_schema.`columns` where 1 != 1",
  1482                      "Query": "select TABLE_NAME from information_schema.`columns`",
  1483                      "Table": "information_schema.`columns`"
  1484                    }
  1485                  ]
  1486                }
  1487              ]
  1488            }
  1489          ]
  1490        }
  1491      },
  1492      "gen4-plan": {
  1493        "QueryType": "SELECT",
  1494        "Original": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt",
  1495        "Instructions": {
  1496          "OperatorType": "Route",
  1497          "Variant": "DBA",
  1498          "Keyspace": {
  1499            "Name": "main",
  1500            "Sharded": false
  1501          },
  1502          "FieldQuery": "select dt.TABLE_NAME from (select TABLE_NAME from information_schema.`tables` as t where 1 != 1 union select TABLE_NAME from information_schema.`columns` where 1 != 1) as dt where 1 != 1",
  1503          "Query": "select dt.TABLE_NAME from (select TABLE_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname union select TABLE_NAME from information_schema.`columns`) as dt",
  1504          "SysTableTableSchema": "[VARCHAR(\"a\")]",
  1505          "Table": "information_schema.`tables`"
  1506        }
  1507      }
  1508    },
  1509    {
  1510      "comment": "merge even one side have schema name in subquery",
  1511      "query": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `COLUMN_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)",
  1512      "v3-plan": {
  1513        "QueryType": "SELECT",
  1514        "Original": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `COLUMN_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)",
  1515        "Instructions": {
  1516          "OperatorType": "Subquery",
  1517          "Variant": "PulloutIn",
  1518          "PulloutVars": [
  1519            "__sq_has_values1",
  1520            "__sq1"
  1521          ],
  1522          "Inputs": [
  1523            {
  1524              "OperatorType": "Distinct",
  1525              "Inputs": [
  1526                {
  1527                  "OperatorType": "Concatenate",
  1528                  "Inputs": [
  1529                    {
  1530                      "OperatorType": "Route",
  1531                      "Variant": "DBA",
  1532                      "Keyspace": {
  1533                        "Name": "main",
  1534                        "Sharded": false
  1535                      },
  1536                      "FieldQuery": "select COLUMN_NAME from information_schema.`tables` as t where 1 != 1",
  1537                      "Query": "select COLUMN_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname",
  1538                      "SysTableTableSchema": "[VARCHAR(\"a\")]",
  1539                      "Table": "information_schema.`tables`"
  1540                    },
  1541                    {
  1542                      "OperatorType": "Route",
  1543                      "Variant": "DBA",
  1544                      "Keyspace": {
  1545                        "Name": "main",
  1546                        "Sharded": false
  1547                      },
  1548                      "FieldQuery": "select COLUMN_NAME from information_schema.`columns` where 1 != 1",
  1549                      "Query": "select COLUMN_NAME from information_schema.`columns`",
  1550                      "Table": "information_schema.`columns`"
  1551                    }
  1552                  ]
  1553                }
  1554              ]
  1555            },
  1556            {
  1557              "OperatorType": "Route",
  1558              "Variant": "DBA",
  1559              "Keyspace": {
  1560                "Name": "main",
  1561                "Sharded": false
  1562              },
  1563              "FieldQuery": "select COLLATION_NAME from information_schema.`COLUMNS` as t where 1 != 1",
  1564              "Query": "select COLLATION_NAME from information_schema.`COLUMNS` as t where :__sq_has_values1 = 1 and COLUMN_NAME in ::__sq1",
  1565              "Table": "information_schema.`COLUMNS`"
  1566            }
  1567          ]
  1568        }
  1569      },
  1570      "gen4-plan": {
  1571        "QueryType": "SELECT",
  1572        "Original": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `COLUMN_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)",
  1573        "Instructions": {
  1574          "OperatorType": "Route",
  1575          "Variant": "DBA",
  1576          "Keyspace": {
  1577            "Name": "main",
  1578            "Sharded": false
  1579          },
  1580          "FieldQuery": "select COLLATION_NAME from information_schema.`COLUMNS` as t where 1 != 1",
  1581          "Query": "select COLLATION_NAME from information_schema.`COLUMNS` as t where COLUMN_NAME in (select COLUMN_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname union select COLUMN_NAME from information_schema.`columns`)",
  1582          "SysTableTableSchema": "[VARCHAR(\"a\")]",
  1583          "Table": "information_schema.`COLUMNS`"
  1584        }
  1585      }
  1586    },
  1587    {
  1588      "comment": "table_schema OR predicate\n# It is unsupported because we do not route queries to multiple keyspaces right now",
  1589      "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'",
  1590      "v3-plan": {
  1591        "QueryType": "SELECT",
  1592        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'",
  1593        "Instructions": {
  1594          "OperatorType": "Route",
  1595          "Variant": "DBA",
  1596          "Keyspace": {
  1597            "Name": "main",
  1598            "Sharded": false
  1599          },
  1600          "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
  1601          "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = 'ks' or TABLE_SCHEMA = 'main'",
  1602          "Table": "INFORMATION_SCHEMA.`TABLES`"
  1603        }
  1604      },
  1605      "gen4-plan": {
  1606        "QueryType": "SELECT",
  1607        "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'",
  1608        "Instructions": {
  1609          "OperatorType": "Route",
  1610          "Variant": "DBA",
  1611          "Keyspace": {
  1612            "Name": "main",
  1613            "Sharded": false
  1614          },
  1615          "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
  1616          "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = 'ks' or TABLE_SCHEMA = 'main'",
  1617          "Table": "INFORMATION_SCHEMA.`TABLES`"
  1618        }
  1619      }
  1620    },
  1621    {
  1622      "comment": "select variable, value from sys.sys_config",
  1623      "query": "select variable, value from sys.sys_config",
  1624      "plan": {
  1625        "QueryType": "SELECT",
  1626        "Original": "select variable, value from sys.sys_config",
  1627        "Instructions": {
  1628          "OperatorType": "Route",
  1629          "Variant": "DBA",
  1630          "Keyspace": {
  1631            "Name": "main",
  1632            "Sharded": false
  1633          },
  1634          "FieldQuery": "select variable, value from sys.sys_config where 1 != 1",
  1635          "Query": "select variable, value from sys.sys_config",
  1636          "Table": "sys.sys_config"
  1637        }
  1638      }
  1639    },
  1640    {
  1641      "comment": "select host, db from mysql.`db`",
  1642      "query": "select host, db from mysql.`db`",
  1643      "plan": {
  1644        "QueryType": "SELECT",
  1645        "Original": "select host, db from mysql.`db`",
  1646        "Instructions": {
  1647          "OperatorType": "Route",
  1648          "Variant": "DBA",
  1649          "Keyspace": {
  1650            "Name": "main",
  1651            "Sharded": false
  1652          },
  1653          "FieldQuery": "select host, db from mysql.db where 1 != 1",
  1654          "Query": "select host, db from mysql.db",
  1655          "Table": "mysql.db"
  1656        }
  1657      }
  1658    },
  1659    {
  1660      "comment": "select logged, prio from performance_schema.error_log",
  1661      "query": "select logged, prio from performance_schema.error_log",
  1662      "plan": {
  1663        "QueryType": "SELECT",
  1664        "Original": "select logged, prio from performance_schema.error_log",
  1665        "Instructions": {
  1666          "OperatorType": "Route",
  1667          "Variant": "DBA",
  1668          "Keyspace": {
  1669            "Name": "main",
  1670            "Sharded": false
  1671          },
  1672          "FieldQuery": "select logged, prio from performance_schema.error_log where 1 != 1",
  1673          "Query": "select logged, prio from performance_schema.error_log",
  1674          "Table": "performance_schema.error_log"
  1675        }
  1676      }
  1677    },
  1678    {
  1679      "comment": "Non-existing information_schema table is still OK",
  1680      "query": "select TABLE_NAME from information_schema.apa",
  1681      "plan": {
  1682        "QueryType": "SELECT",
  1683        "Original": "select TABLE_NAME from information_schema.apa",
  1684        "Instructions": {
  1685          "OperatorType": "Route",
  1686          "Variant": "DBA",
  1687          "Keyspace": {
  1688            "Name": "main",
  1689            "Sharded": false
  1690          },
  1691          "FieldQuery": "select TABLE_NAME from information_schema.apa where 1 != 1",
  1692          "Query": "select TABLE_NAME from information_schema.apa",
  1693          "Table": "information_schema.apa"
  1694        }
  1695      }
  1696    }
  1697  ]