apecloud / myduckserver

MySQL & Postgres Analytics, Reimagined
184 stars 8 forks source link

Support prefix index #85

Open GaoYusong opened 2 months ago

GaoYusong commented 2 months ago
{
        Name: "Prefix index with same columns as another index",
        SetUpScript: []string{
            "CREATE table t (pk int primary key, col1 varchar(100));",
            "INSERT into t values (1, '100'), (2, '200');",
            "alter table t add unique index idx1 (col1);",
        },
        Assertions: []ScriptTestAssertion{
            {
                Query:    "alter table t add index idx2 (col1(10));",
                Expected: []sql.Row{{types.NewOkResult(0)}},
            },
            {
                Query: "show create table t",
                Expected: []sql.Row{{"t",
                    "CREATE TABLE `t` (\n" +
                        "  `pk` int NOT NULL,\n" +
                        "  `col1` varchar(100),\n" +
                        "  PRIMARY KEY (`pk`),\n" +
                        "  UNIQUE KEY `idx1` (`col1`),\n" +
                        "  KEY `idx2` (`col1`(10))\n" +
                        ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
            },
        },
    }
--- FAIL: TestAlterTable (4.95s)
    --- FAIL: TestAlterTable/Prefix_index_with_same_columns_as_another_index (0.03s)
        --- FAIL: TestAlterTable/Prefix_index_with_same_columns_as_another_index/show_create_table_t (0.01s)
            /Users/shannon/code/myduckserver/evaluation.go:726: 
                    Error Trace:    /Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:726
                                                /Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:357
                    Error:          Not equal: 
                                    expected: []sql.Row{sql.Row{"t", "CREATE TABLE `t` (\n  `pk` int NOT NULL,\n  `col1` varchar(100),\n  PRIMARY KEY (`pk`),\n  UNIQUE KEY `idx1` (`col1`),\n  KEY `idx2` (`col1`(10))\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}}
                                    actual  : []sql.Row{sql.Row{"t", "CREATE TABLE `t` (\n  `pk` int NOT NULL,\n  `col1` varchar(100),\n  PRIMARY KEY (`pk`),\n  UNIQUE KEY `idx1` (`col1`),\n  KEY `idx2` (`col1`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}}

                                    Diff:
                                    --- Expected
                                    +++ Actual
                                    @@ -3,3 +3,3 @@
                                       (string) (len=1) "t",
                                    -  (string) (len=205) "CREATE TABLE `t` (\n  `pk` int NOT NULL,\n  `col1` varchar(100),\n  PRIMARY KEY (`pk`),\n  UNIQUE KEY `idx1` (`col1`),\n  KEY `idx2` (`col1`(10))\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"
                                    +  (string) (len=201) "CREATE TABLE `t` (\n  `pk` int NOT NULL,\n  `col1` varchar(100),\n  PRIMARY KEY (`pk`),\n  UNIQUE KEY `idx1` (`col1`),\n  KEY `idx2` (`col1`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"
                                      }
                    Test:           TestAlterTable/Prefix_index_with_same_columns_as_another_index/show_create_table_t
                    Messages:       Unexpected result for query show create