github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/logictest/testdata/logic_test/name_escapes (about)

     1  # LogicTest: !3node-tenant
     2  # Check that the various things in a table definition are properly escaped when
     3  # printed out.
     4  statement ok
     5  CREATE table "woo; DROP USER humpty;" (x INT PRIMARY KEY); CREATE TABLE ";--notbetter" (
     6    x INT, y INT,
     7    "welp INT); -- concerning much
     8  DROP USER dumpty;
     9  CREATE TABLE unused (x " INT,
    10    INDEX "helpme ON (x)); -- this must stop!
    11  DROP USER alice;
    12  CREATE TABLE unused2(x INT, INDEX woo ON " (x ASC),
    13    FAMILY "nonotagain (x)); -- welp!
    14  DROP USER queenofhearts;
    15  CREATE TABLE unused3(x INT, y INT, FAMILY woo " (x, y),
    16    CONSTRAINT "getmeoutofhere PRIMARY KEY (x ASC)); -- saveme!
    17  DROP USER madhatter;
    18  CREATE TABLE unused4(x INT, CONSTRAINT woo " PRIMARY KEY (x)
    19  ) INTERLEAVE IN PARENT "woo; DROP USER humpty;" (x);
    20  
    21  query TT
    22  SHOW CREATE TABLE ";--notbetter"
    23  ----
    24  ";--notbetter"  CREATE TABLE ";--notbetter" (
    25                  x INT8 NOT NULL,
    26                  y INT8 NULL,
    27                  "welp INT); -- concerning much
    28  DROP USER dumpty;
    29  CREATE TABLE unused (x " INT8 NULL,
    30    CONSTRAINT "getmeoutofhere PRIMARY KEY (x ASC)); -- saveme!
    31  DROP USER madhatter;
    32  CREATE TABLE unused4(x INT, CONSTRAINT woo " PRIMARY KEY (x ASC),
    33    INDEX "helpme ON (x)); -- this must stop!
    34  DROP USER alice;
    35  CREATE TABLE unused2(x INT, INDEX woo ON " (x ASC),
    36    FAMILY "nonotagain (x)); -- welp!
    37  DROP USER queenofhearts;
    38  CREATE TABLE unused3(x INT, y INT, FAMILY woo " (x, y, "welp INT); -- concerning much
    39  DROP USER dumpty;
    40  CREATE TABLE unused (x ")
    41  ) INTERLEAVE IN PARENT "woo; DROP USER humpty;" (x)
    42  
    43  # Check that view creates handle strange things properly.
    44  statement ok
    45  CREATE VIEW ";--alsoconcerning" AS SELECT @1 AS a, @2 AS b, @3 AS c FROM ";--notbetter"
    46  
    47  query TT
    48  SHOW CREATE VIEW ";--alsoconcerning"
    49  ----
    50  ";--alsoconcerning"  CREATE VIEW ";--alsoconcerning" (a, b, c) AS SELECT @1 AS a, @2 AS b, @3 AS c FROM test.public.";--notbetter"
    51  
    52  # Check that "create table as" handles strange things properly.
    53  statement ok
    54  CREATE TABLE ";--dontask" AS SELECT @1 AS a, @2 AS b, @3 AS c FROM ";--notbetter"
    55  
    56  query TT
    57  SHOW CREATE TABLE ";--dontask"
    58  ----
    59  ";--dontask"  CREATE TABLE ";--dontask" (
    60                a INT8 NULL,
    61                b INT8 NULL,
    62                c INT8 NULL,
    63                FAMILY "primary" (a, b, c, rowid)
    64  )