Skip to content

Commit 07071cb

Browse files
committed
Merge branch 'main' into fulghum/mutual_tls
2 parents 4e6d96b + 7f4380b commit 07071cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5251
-1013
lines changed

enginetest/queries/create_table_queries.go

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,148 @@ var CreateTableQueries = []WriteQueryTest{
327327
}
328328

329329
var CreateTableScriptTests = []ScriptTest{
330+
{
331+
// https://github.com/dolthub/dolt/issues/9316
332+
Name: "CREATE TABLE with constraints AS SELECT osticket repro",
333+
SkipPrepared: true, // SHOW KEYS with WHERE clause doesn't work with prepared statements
334+
SetUpScript: []string{
335+
"CREATE TABLE ost_form_entry (id INT PRIMARY KEY, object_id INT, object_type VARCHAR(1))",
336+
"CREATE TABLE ost_form_entry_values (entry_id INT, field_id INT, value VARCHAR(100), value_id INT)",
337+
"CREATE TABLE ost_form_field (id INT PRIMARY KEY)",
338+
"INSERT INTO ost_form_entry VALUES (1, 100, 'U'), (2, 101, 'U'), (3, 102, 'X')",
339+
"INSERT INTO ost_form_entry_values VALUES (1, 1, 'user100@example.com', 1000), (2, 1, 'user101@example.com', 1001), (3, 2, 'other', 2000)",
340+
"INSERT INTO ost_form_field VALUES (1), (2)",
341+
},
342+
Assertions: []ScriptTestAssertion{
343+
{
344+
Query: `CREATE TABLE IF NOT EXISTS ost_user__cdata (
345+
PRIMARY KEY (user_id)
346+
) DEFAULT CHARSET=utf8 AS
347+
SELECT
348+
entry.object_id as user_id,
349+
MAX(IF(field.id='1',coalesce(ans.value_id, ans.value),NULL)) as email
350+
FROM ost_form_entry entry
351+
JOIN ost_form_entry_values ans
352+
ON ans.entry_id = entry.id
353+
JOIN ost_form_field field
354+
ON field.id=ans.field_id
355+
WHERE entry.object_type='U' GROUP BY entry.object_id`,
356+
},
357+
{
358+
Query: "SELECT * FROM ost_user__cdata ORDER BY user_id",
359+
Expected: []sql.Row{
360+
{100, "1000"},
361+
{101, "1001"},
362+
},
363+
},
364+
{
365+
Query: "SHOW KEYS FROM ost_user__cdata WHERE Key_name = 'PRIMARY'",
366+
Expected: []sql.Row{
367+
{"ost_user__cdata", 0, "PRIMARY", 1, "user_id", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
368+
},
369+
},
370+
},
371+
},
372+
{
373+
// https://github.com/dolthub/dolt/issues/9316
374+
Name: "CREATE TABLE with constraints AS SELECT",
375+
SkipPrepared: true,
376+
SetUpScript: []string{
377+
"CREATE TABLE t1 (a int not null, b varchar(10))",
378+
"INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three')",
379+
"CREATE TABLE source (id int, name varchar(20))",
380+
"INSERT INTO source VALUES (1, 'alice'), (2, 'bob'), (3, 'charlie')",
381+
"CREATE TABLE override_src (a bigint, b int)",
382+
"INSERT INTO override_src VALUES (100, 200)",
383+
"CREATE TABLE base (a int, b varchar(10))",
384+
"INSERT INTO base VALUES (1, 'alpha'), (2, 'beta')",
385+
"CREATE TABLE multi_src (id int, email varchar(50), age int)",
386+
"INSERT INTO multi_src VALUES (1, 'a@test.com', 25), (2, 'b@test.com', 30)",
387+
},
388+
Assertions: []ScriptTestAssertion{
389+
{
390+
Query: "CREATE TABLE t2 (PRIMARY KEY(a)) SELECT * FROM t1",
391+
},
392+
{
393+
Query: "SELECT * FROM t2 ORDER BY a",
394+
Expected: []sql.Row{
395+
{1, "one"},
396+
{2, "two"},
397+
{3, "three"},
398+
},
399+
},
400+
{
401+
Query: "SHOW KEYS FROM t2 WHERE Key_name = 'PRIMARY'",
402+
Expected: []sql.Row{
403+
{"t2", 0, "PRIMARY", 1, "a", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
404+
},
405+
},
406+
{
407+
Query: "CREATE TABLE indexed (KEY(name)) SELECT * FROM source",
408+
},
409+
{
410+
Query: "SELECT * FROM indexed ORDER BY id",
411+
Expected: []sql.Row{
412+
{1, "alice"},
413+
{2, "bob"},
414+
{3, "charlie"},
415+
},
416+
},
417+
{
418+
Query: "SHOW KEYS FROM indexed WHERE Key_name = 'name'",
419+
Expected: []sql.Row{
420+
{"indexed", 1, "name", 1, "name", nil, 0, nil, nil, "YES", "BTREE", "", "", "YES", nil},
421+
},
422+
},
423+
{
424+
Query: "CREATE TABLE override (a TINYINT NOT NULL) SELECT a, b FROM override_src",
425+
},
426+
{
427+
Query: "SELECT * FROM override",
428+
Expected: []sql.Row{
429+
{int8(100), 200},
430+
},
431+
},
432+
{
433+
Query: "SHOW CREATE TABLE override",
434+
Expected: []sql.Row{
435+
{"override", "CREATE TABLE `override` (\n `a` tinyint NOT NULL,\n `b` int\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
436+
},
437+
},
438+
{
439+
Query: "CREATE TABLE uniq (UNIQUE KEY(a)) SELECT * FROM base",
440+
},
441+
{
442+
Query: "SELECT * FROM uniq ORDER BY a",
443+
Expected: []sql.Row{
444+
{1, "alpha"},
445+
{2, "beta"},
446+
},
447+
},
448+
{
449+
Query: "SHOW KEYS FROM uniq WHERE Key_name = 'a'",
450+
Expected: []sql.Row{
451+
{"uniq", 0, "a", 1, "a", nil, 0, nil, nil, "YES", "BTREE", "", "", "YES", nil},
452+
},
453+
},
454+
{
455+
Query: "CREATE TABLE multi_idx (PRIMARY KEY(id), KEY(email), KEY(age)) SELECT * FROM multi_src",
456+
},
457+
{
458+
Query: "SELECT * FROM multi_idx ORDER BY id",
459+
Expected: []sql.Row{
460+
{1, "a@test.com", 25},
461+
{2, "b@test.com", 30},
462+
},
463+
},
464+
{
465+
Query: "SELECT COUNT(*) FROM information_schema.statistics WHERE table_name = 'multi_idx'",
466+
Expected: []sql.Row{
467+
{3},
468+
},
469+
},
470+
},
471+
},
330472
{
331473
// https://github.com/dolthub/dolt/issues/6682
332474
Name: "display width for numeric types",

enginetest/queries/queries.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5031,6 +5031,8 @@ SELECT * FROM cte WHERE d = 2;`,
50315031
{"gtid_next", "AUTOMATIC"},
50325032
{"gtid_owned", ""},
50335033
{"gtid_purged", ""},
5034+
{"gtid_domain_id", 0},
5035+
{"gtid_seq_no", 0},
50345036
},
50355037
},
50365038
{

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ require (
66
github.com/dolthub/go-icu-regex v0.0.0-20250916051405-78a38d478790
77
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71
88
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
9-
github.com/dolthub/vitess v0.0.0-20251031205214-d09b65bd77b0
9+
github.com/dolthub/vitess v0.0.0-20251107003339-843d10a6a8d4
1010
github.com/go-sql-driver/mysql v1.9.3
1111
github.com/gocraft/dbr/v2 v2.7.2
1212
github.com/google/uuid v1.3.0
1313
github.com/hashicorp/golang-lru v0.5.4
1414
github.com/lestrrat-go/strftime v1.0.4
1515
github.com/pkg/errors v0.9.1
1616
github.com/pmezard/go-difflib v1.0.0
17-
github.com/shopspring/decimal v1.3.1
17+
github.com/shopspring/decimal v1.4.0
1818
github.com/sirupsen/logrus v1.8.1
1919
github.com/stretchr/testify v1.9.0
2020
go.opentelemetry.io/otel v1.31.0

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ github.com/dolthub/vitess v0.0.0-20250930230441-70c2c6a98e33 h1:ScHTwNbcVC6JH1OS
2222
github.com/dolthub/vitess v0.0.0-20250930230441-70c2c6a98e33/go.mod h1:8pvvk5OLaLN9LLxghyczUapn/97l+mBgIb10qC1LG84=
2323
github.com/dolthub/vitess v0.0.0-20251031205214-d09b65bd77b0 h1:RXopPQP1bwb5fsnXAC89joqk/3pIgQnQSU8lAHJhue0=
2424
github.com/dolthub/vitess v0.0.0-20251031205214-d09b65bd77b0/go.mod h1:FLWqdXsAeeBQyFwDjmBVu0GnbjI2MKeRf3tRVdJEKlI=
25+
github.com/dolthub/vitess v0.0.0-20251105091622-b08b393fd9b1 h1:2uiHo4gkf2n/Cw9uCBDkCWj35Vz48Uhif2B9P+DqgCg=
26+
github.com/dolthub/vitess v0.0.0-20251105091622-b08b393fd9b1/go.mod h1:FLWqdXsAeeBQyFwDjmBVu0GnbjI2MKeRf3tRVdJEKlI=
27+
github.com/dolthub/vitess v0.0.0-20251107003339-843d10a6a8d4 h1:vOF5qPLC0Yd4BN/FKJlRLNELIZZlev40TrckORQqzhA=
28+
github.com/dolthub/vitess v0.0.0-20251107003339-843d10a6a8d4/go.mod h1:FLWqdXsAeeBQyFwDjmBVu0GnbjI2MKeRf3tRVdJEKlI=
2529
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
2630
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
2731
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@@ -66,8 +70,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
6670
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
6771
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6872
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
69-
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
70-
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
73+
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
74+
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
7175
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
7276
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
7377
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

0 commit comments

Comments
 (0)