From d0bb4e3246bb64270784be7457cc6bdd6091da14 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Tue, 29 Oct 2024 15:46:18 -0700 Subject: [PATCH 1/3] More system tables, unskip some tests --- server/tables/dtables/init.go | 43 +- testing/go/dolt_tables_test.go | 608 +++++++++++++++++- testing/go/enginetest/doltgres_engine_test.go | 1 - 3 files changed, 645 insertions(+), 7 deletions(-) diff --git a/server/tables/dtables/init.go b/server/tables/dtables/init.go index e76c558abd..84ef41b107 100644 --- a/server/tables/dtables/init.go +++ b/server/tables/dtables/init.go @@ -21,12 +21,21 @@ import ( // Init handles initialization of all Postgres-specific and Doltgres-specific Dolt system tables. func Init() { - dtables.GetDocsSchema = getDocsSchema - doltdb.GetDocTableName = getDocTableName + // Table names doltdb.GetBranchesTableName = getBranchesTableName + doltdb.GetDocTableName = getDocTableName + doltdb.GetColumnDiffTableName = getColumnDiffTableName + doltdb.GetCommitAncestorsTableName = getCommitAncestorsTableName + doltdb.GetCommitsTableName = getCommitsTableName + doltdb.GetDiffTableName = getDiffTableName doltdb.GetLogTableName = getLogTableName + doltdb.GetRemoteBranchesTableName = getRemoteBranchesTableName + doltdb.GetRemotesTableName = getRemotesTableName doltdb.GetStatusTableName = getStatusTableName doltdb.GetTagsTableName = getTagsTableName + + // Schemas + dtables.GetDocsSchema = getDocsSchema } // getBranchesTableName returns the name of the branches table. @@ -34,11 +43,41 @@ func getBranchesTableName() string { return "branches" } +// getColumnDiffTableName returns the name of the column diff table. +func getColumnDiffTableName() string { + return "column_diff" +} + +// getCommitAncestorsTableName returns the name of the commit ancestors table. +func getCommitAncestorsTableName() string { + return "commit_ancestors" +} + +// getCommitsTableName returns the name of the commits table. +func getCommitsTableName() string { + return "commits" +} + +// getDiffTableName returns the name of the diff table. +func getDiffTableName() string { + return "diff" +} + // getLogTableName returns the name of the branches table. func getLogTableName() string { return "log" } +// getRemoteBranchesTableName returns the name of the remote branches table. +func getRemoteBranchesTableName() string { + return "remote_branches" +} + +// getRemotesTableName returns the name of the remotes table. +func getRemotesTableName() string { + return "remotes" +} + // getStatusTableName returns the name of the status table. func getStatusTableName() string { return "status" diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index 32b3136624..0f807b5361 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -39,7 +39,6 @@ func TestUserSpaceDoltTables(t *testing.T) { Expected: []sql.Row{{"main"}}, }, { - Skip: true, // TODO: ERROR: table not found: dolt_branches Query: `SELECT dolt_branches.name FROM dolt_branches`, Expected: []sql.Row{{"main"}}, }, @@ -105,6 +104,326 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, + { + Name: "dolt column diff", + SetUpScript: []string{ + "CREATE TABLE test (id INT PRIMARY KEY)", + "SELECT dolt_commit('-Am', 'test commit')", + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT table_name, column_name FROM dolt.column_diff`, + Expected: []sql.Row{{"public.test", "id"}}, + }, + { + Query: `SELECT table_name, column_name FROM dolt_column_diff`, + Expected: []sql.Row{{"public.test", "id"}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.column_diff.commit_hash FROM dolt.column_diff`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT dolt_column_diff.table_name, dolt_column_diff.column_name FROM dolt_column_diff`, + Expected: []sql.Row{{"public.test", "id"}}, + }, + { + Query: `SELECT * FROM public.column_diff`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM column_diff`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE column_diff (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO column_diff VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM column_diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT table_name, column_name FROM dolt.column_diff WHERE table_name = 'public.test'`, + Expected: []sql.Row{{"public.test", "id"}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT table_name, column_name FROM column_diff WHERE table_name = 'public.test'`, + Expected: []sql.Row{{"public.test", "id"}}, + }, + { + Query: `SELECT * FROM public.column_diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM column_diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM column_diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM COLUMN_DIFF`, + Expected: []sql.Row{{1}}, + }, + }, + }, + { + Name: "dolt commit ancestors", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT count(*) FROM dolt.commit_ancestors`, + Expected: []sql.Row{{2}}, + }, + { + Query: `SELECT count(*) FROM dolt_commit_ancestors`, + Expected: []sql.Row{{2}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.commit_ancestors.parent_index FROM dolt.commit_ancestors`, + Expected: []sql.Row{{0}, {0}}, + }, + { + Query: `SELECT dolt_commit_ancestors.parent_index FROM dolt_commit_ancestors`, + Expected: []sql.Row{{0}, {0}}, + }, + { + Query: `SELECT * FROM public.commit_ancestors`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM commit_ancestors`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE commit_ancestors (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO commit_ancestors VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM commit_ancestors`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT count(*) FROM dolt.commit_ancestors`, + Expected: []sql.Row{{2}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT count(*) FROM commit_ancestors`, + Expected: []sql.Row{{2}}, + }, + { + Query: `SELECT * FROM public.commit_ancestors`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM commit_ancestors`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM commit_ancestors`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM COMMIT_ANCESTORS`, + Expected: []sql.Row{{1}}, + }, + }, + }, + { + Name: "dolt commits", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT count(*) FROM dolt.commits`, + Expected: []sql.Row{{2}}, + }, + { + Query: `SELECT count(*) FROM dolt_commits`, + Expected: []sql.Row{{2}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.commits.message FROM dolt.commits`, + Expected: []sql.Row{{"CREATE DATABASE"}, {"Initialize data repository"}}, + }, + { + Query: `SELECT dolt_commits.message FROM dolt_commits`, + Expected: []sql.Row{{"CREATE DATABASE"}, {"Initialize data repository"}}, + }, + { + Query: `SELECT * FROM public.commits`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM commits`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE commits (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO commits VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM commits`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT count(*) FROM dolt.commits`, + Expected: []sql.Row{{2}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT count(*) FROM commits`, + Expected: []sql.Row{{2}}, + }, + { + Query: `SELECT * FROM public.commits`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM commits`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM commits`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM COMMITS`, + Expected: []sql.Row{{1}}, + }, + }, + }, + { + Name: "dolt diff", + SetUpScript: []string{ + "CREATE TABLE test (id INT PRIMARY KEY)", + "SELECT dolt_commit('-Am', 'test commit')", + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT table_name FROM dolt.diff`, + Expected: []sql.Row{{"public.test"}}, + }, + { + Query: `SELECT table_name FROM dolt_diff`, + Expected: []sql.Row{{"public.test"}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.diff.table_name FROM dolt.diff`, + Expected: []sql.Row{{"public.test"}}, + }, + { + Query: `SELECT dolt_diff.table_name FROM dolt_diff`, + Expected: []sql.Row{{"public.test"}}, + }, + { + Query: `SELECT * FROM public.diff`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM diff`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE diff (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO diff VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT table_name FROM dolt.diff WHERE table_name = 'public.test'`, + Expected: []sql.Row{{"public.test"}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT table_name FROM diff WHERE table_name = 'public.test'`, + Expected: []sql.Row{{"public.test"}}, + }, + { + Query: `SELECT * FROM public.diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM diff`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM DIFF`, + Expected: []sql.Row{{1}}, + }, + }, + }, { Name: "dolt log", Assertions: []ScriptTestAssertion{ @@ -164,14 +483,26 @@ func TestUserSpaceDoltTables(t *testing.T) { }, { Name: "dolt tags", + SetUpScript: []string{ + "SELECT dolt_tag('v1')", + }, Assertions: []ScriptTestAssertion{ { Query: `SELECT tag_name FROM dolt.tags`, - Expected: []sql.Row{}, + Expected: []sql.Row{{"v1"}}, }, { - Query: `SELECT * FROM dolt_tags`, - Expected: []sql.Row{}, + Query: `SELECT tag_name FROM dolt_tags`, + Expected: []sql.Row{{"v1"}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.tags.tag_name FROM dolt.tags`, + Expected: []sql.Row{{"v1"}}, + }, + { + Query: `SELECT dolt_tags.tag_name FROM dolt_tags`, + Expected: []sql.Row{{"v1"}}, }, { Query: `SELECT * FROM public.tags`, @@ -181,6 +512,58 @@ func TestUserSpaceDoltTables(t *testing.T) { Query: `SELECT * FROM tags`, ExpectedErr: "table not found", }, + { + Query: `CREATE TABLE tags (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO tags VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM tags`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT tag_name FROM dolt.tags`, + Expected: []sql.Row{{"v1"}}, + }, + { + Query: `CREATE SCHEMA dolt`, + ExpectedErr: "schema exists", + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT tag_name FROM tags`, + Expected: []sql.Row{{"v1"}}, + }, + { + Query: `SELECT * FROM public.tags`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM tags`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM tags`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM TAGS`, + Expected: []sql.Row{{1}}, + }, }, }, { @@ -201,6 +584,16 @@ func TestUserSpaceDoltTables(t *testing.T) { {"README.md", "testing"}, }, }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.docs.doc_name FROM dolt.docs`, + Expected: []sql.Row{{"README.md"}}, + }, + { + Skip: true, // TODO: table not found: dolt_docs + Query: `SELECT dolt_docs.doc_name FROM dolt_docs`, + Expected: []sql.Row{{"README.md"}}, + }, { Query: `SELECT * FROM public.docs`, ExpectedErr: "table not found", @@ -209,6 +602,213 @@ func TestUserSpaceDoltTables(t *testing.T) { Query: `SELECT * FROM docs`, ExpectedErr: "table not found", }, + { + Query: `CREATE TABLE docs (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO docs VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM docs`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT doc_name FROM dolt.docs`, + Expected: []sql.Row{{"README.md"}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT doc_name FROM docs`, + Expected: []sql.Row{{"README.md"}}, + }, + { + Query: `SELECT * FROM public.docs`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM docs`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM docs`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM DOCS`, + Expected: []sql.Row{{1}}, + }, + }, + }, + { + Name: "dolt remote branches", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT name FROM dolt.remote_branches`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM dolt_remote_branches`, + Expected: []sql.Row{}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.remote_branches.name FROM dolt.remote_branches`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT dolt_remote_branches.name FROM dolt_remote_branches`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM public.remote_branches`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM remote_branches`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE remote_branches (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO remote_branches VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM remote_branches`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT name FROM dolt.remote_branches`, + Expected: []sql.Row{}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM remote_branches`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM public.remote_branches`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM remote_branches`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM remote_branches`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM REMOTE_BRANCHES`, + Expected: []sql.Row{{1}}, + }, + }, + }, + { + Name: "dolt remotes", + SetUpScript: []string{ + "SELECT dolt_remote('add', 'origin', 'https://doltremoteapi.dolthub.com/dolthub/test')", + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT name FROM dolt.remotes`, + Expected: []sql.Row{{"origin"}}, + }, + { + Query: `SELECT name FROM dolt_remotes`, + Expected: []sql.Row{{"origin"}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.remotes.name FROM dolt.remotes`, + Expected: []sql.Row{{"origin"}}, + }, + { + Query: `SELECT dolt_remotes.name FROM dolt_remotes`, + Expected: []sql.Row{{"origin"}}, + }, + { + Query: `SELECT * FROM public.remotes`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM remotes`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE remotes (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO remotes VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM remotes`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT name FROM dolt.remotes`, + Expected: []sql.Row{{"origin"}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM remotes`, + Expected: []sql.Row{{"origin"}}, + }, + { + Query: `SELECT * FROM public.remotes`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM remotes`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM remotes`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM REMOTES`, + Expected: []sql.Row{{1}}, + }, }, }, { diff --git a/testing/go/enginetest/doltgres_engine_test.go b/testing/go/enginetest/doltgres_engine_test.go index d9d9d829e1..ca59ff8f98 100755 --- a/testing/go/enginetest/doltgres_engine_test.go +++ b/testing/go/enginetest/doltgres_engine_test.go @@ -1261,7 +1261,6 @@ func TestHistorySystemTable(t *testing.T) { "dolt_history table with AS OF", // AS OF "dolt_history table with enums", // enums "can sort by dolt_log.commit", // more commits - "select dolt_log.commit_hash", // table name }).WithParallelism(2) denginetest.RunHistorySystemTableTests(t, harness) } From 6a1b9b2ceba6951245d2d5eeb45b1bc6f185280e Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Wed, 30 Oct 2024 12:14:36 -0700 Subject: [PATCH 2/3] More system tables --- server/tables/dtables/init.go | 24 ++ testing/go/dolt_functions_test.go | 8 +- testing/go/dolt_tables_test.go | 356 ++++++++++++++++++++++++++++++ 3 files changed, 384 insertions(+), 4 deletions(-) diff --git a/server/tables/dtables/init.go b/server/tables/dtables/init.go index 84ef41b107..ef786ce73c 100644 --- a/server/tables/dtables/init.go +++ b/server/tables/dtables/init.go @@ -29,9 +29,13 @@ func Init() { doltdb.GetCommitsTableName = getCommitsTableName doltdb.GetDiffTableName = getDiffTableName doltdb.GetLogTableName = getLogTableName + doltdb.GetMergeStatusTableName = getMergeStatusTableName doltdb.GetRemoteBranchesTableName = getRemoteBranchesTableName doltdb.GetRemotesTableName = getRemotesTableName + doltdb.GetSchemaConflictsTableName = getSchemaConflictsTableName doltdb.GetStatusTableName = getStatusTableName + doltdb.GetTableOfTablesInConflictName = getTableOfTablesInConflictName + doltdb.GetTableOfTablesWithViolationsName = getTableOfTablesWithViolationsName doltdb.GetTagsTableName = getTagsTableName // Schemas @@ -68,6 +72,11 @@ func getLogTableName() string { return "log" } +// getMergeStatusTableName returns the name of the merge status table. +func getMergeStatusTableName() string { + return "merge_status" +} + // getRemoteBranchesTableName returns the name of the remote branches table. func getRemoteBranchesTableName() string { return "remote_branches" @@ -78,11 +87,26 @@ func getRemotesTableName() string { return "remotes" } +// getSchemaConflictsTableName returns the name of the schema conflicts table. +func getSchemaConflictsTableName() string { + return "schema_conflicts" +} + // getStatusTableName returns the name of the status table. func getStatusTableName() string { return "status" } +// getTableOfTablesInConflictName returns the name of the conflicts table. +func getTableOfTablesInConflictName() string { + return "conflicts" +} + +// getTableOfTablesWithViolationsName returns the name of the constraint violations table. +func getTableOfTablesWithViolationsName() string { + return "constraint_violations" +} + // getTagsTableName returns the name of the tags table. func getTagsTableName() string { return "tags" diff --git a/testing/go/dolt_functions_test.go b/testing/go/dolt_functions_test.go index ca9e482e6e..9417cfe76e 100755 --- a/testing/go/dolt_functions_test.go +++ b/testing/go/dolt_functions_test.go @@ -270,7 +270,7 @@ func TestDoltFunctions(t *testing.T) { }, }, { - Name: "smoke test select dolt_diff functions and tables", + Name: "smoke test select dolt diff functions and tables", SetUpScript: []string{ "CREATE TABLE t1 (pk int primary key);", "INSERT INTO t1 VALUES (1);", @@ -320,7 +320,7 @@ func TestDoltFunctions(t *testing.T) { }, }, { - Query: "SELECT * FROM dolt_diff", + Query: "SELECT * FROM dolt.diff", Expected: []sql.Row{ {"WORKING", "public.t1", nil, nil, nil, nil, 1, 1}, }, @@ -361,7 +361,7 @@ func TestDoltFunctions(t *testing.T) { }, }, { - Name: "smoke test select dolt_diff functions and tables for multiple schemas", + Name: "smoke test select dolt diff functions and tables for multiple schemas", SetUpScript: []string{ "CREATE TABLE t1 (pk int primary key);", "INSERT INTO t1 VALUES (1);", @@ -436,7 +436,7 @@ func TestDoltFunctions(t *testing.T) { }, }, { - Query: "SELECT * FROM dolt_diff", + Query: "SELECT * FROM dolt.diff", Expected: []sql.Row{ {"WORKING", "public.t1", nil, nil, nil, nil, 1, 1}, {"WORKING", "testschema.t2", nil, nil, nil, nil, 1, 1}, diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index 0f807b5361..29c0e97ad2 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -33,6 +33,10 @@ func TestUserSpaceDoltTables(t *testing.T) { Query: `SELECT name FROM dolt_branches`, Expected: []sql.Row{{"main"}}, }, + { + Query: `SELECT branches.name FROM dolt.branches`, + Expected: []sql.Row{{"main"}}, + }, { Skip: true, // TODO: referencing items outside the schema or database is not yet supported Query: `SELECT dolt.branches.name FROM dolt.branches`, @@ -342,6 +346,190 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, + { + Name: "dolt conflicts", + SetUpScript: []string{ + "START TRANSACTION", + "CREATE TABLE test (id INT PRIMARY KEY, col1 TEXT)", + "SELECT dolt_commit('-Am', 'first commit')", + "SELECT dolt_branch('b1')", + "SELECT dolt_checkout('-b', 'b2')", + "INSERT INTO test VALUES (1, 'a')", + "SELECT dolt_commit('-Am', 'commit b2')", + "SELECT dolt_checkout('b1')", + "INSERT INTO test VALUES (1, 'b')", + "SELECT dolt_commit('-Am', 'commit b1')", + "SELECT dolt_checkout('main')", + "SELECT dolt_merge('b1')", + "SELECT dolt_merge('b2')", + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM dolt.conflicts`, + Expected: []sql.Row{{"test", Numeric("1")}}, + }, + { + Query: `SELECT * FROM dolt_conflicts`, + Expected: []sql.Row{{"test", Numeric("1")}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.conflicts.table FROM dolt.conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT dolt_conflicts.table FROM dolt_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT * FROM public.conflicts`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM conflicts`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE conflicts (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO conflicts VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM dolt.conflicts`, + Expected: []sql.Row{{"test", Numeric("1")}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM conflicts`, + Expected: []sql.Row{{"test", Numeric("1")}}, + }, + { + Query: `SELECT * FROM public.conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM CONFLICTS`, + Expected: []sql.Row{{1}}, + }, + }, + }, + { + Name: "dolt constraint violations", + SetUpScript: []string{ + "CREATE TABLE otherTable (pk int primary key);", + "CREATE TABLE test (pk int primary key, col1 int unique);", + "SELECT dolt_commit('-Am', 'initial commit');", + "SELECT dolt_branch('branch1');", + "INSERT INTO test (pk, col1) VALUES (1, 1);", + "SELECT dolt_commit('-am', 'insert on main');", + "SELECT dolt_checkout('branch1');", + "INSERT INTO test (pk, col1) VALUES (2, 1);", + "SELECT dolt_commit('-am', 'insert on branch1');", + "START TRANSACTION", + "SELECT dolt_merge('main', '--squash')", + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM dolt.constraint_violations`, + Expected: []sql.Row{{"test", Numeric("2")}}, + }, + { + Query: `SELECT * FROM dolt_constraint_violations`, + Expected: []sql.Row{{"test", Numeric("2")}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.constraint_violations.table FROM dolt.constraint_violations`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT dolt_constraint_violations.table FROM dolt_constraint_violations`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT * FROM public.constraint_violations`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM constraint_violations`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE constraint_violations (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO constraint_violations VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM constraint_violations`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM dolt.constraint_violations`, + Expected: []sql.Row{{"test", Numeric("2")}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM constraint_violations`, + Expected: []sql.Row{{"test", Numeric("2")}}, + }, + { + Query: `SELECT * FROM public.constraint_violations`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM constraint_violations`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM constraint_violations`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM CONSTRAINT_VIOLATIONS`, + Expected: []sql.Row{{1}}, + }, + }, + }, { Name: "dolt diff", SetUpScript: []string{ @@ -481,6 +669,84 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, + { + Name: "dolt merge status", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT is_merging FROM dolt.merge_status`, + Expected: []sql.Row{{0}}, + }, + { + Query: `SELECT is_merging FROM dolt_merge_status`, + Expected: []sql.Row{{0}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.merge_status.is_merging FROM dolt.merge_status`, + Expected: []sql.Row{{0}}, + }, + { + Query: `SELECT dolt_merge_status.is_merging FROM dolt_merge_status`, + Expected: []sql.Row{{0}}, + }, + { + Query: `SELECT * FROM public.merge_status`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM merge_status`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE merge_status (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO merge_status VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM merge_status`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT is_merging FROM dolt.merge_status`, + Expected: []sql.Row{{0}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT is_merging FROM merge_status`, + Expected: []sql.Row{{0}}, + }, + { + Query: `SELECT * FROM public.merge_status`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM merge_status`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM merge_status`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM MERGE_STATUS`, + Expected: []sql.Row{{1}}, + }, + }, + }, { Name: "dolt tags", SetUpScript: []string{ @@ -811,6 +1077,96 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, + { + Name: "dolt schema conflicts", + SetUpScript: []string{ + "CREATE TABLE test (pk int primary key, c0 varchar(20))", + "SELECT dolt_commit('-Am', 'added table t')", + "SELECT dolt_checkout('-b', 'other')", + "ALTER TABLE test ALTER COLUMN c0 TYPE int", + "SELECT dolt_commit('-am', 'altered t on branch other')", + "SELECT dolt_checkout('main')", + "ALTER TABLE test ALTER COLUMN c0 TYPE date", + "SELECT dolt_commit('-am', 'altered t on branch main')", + "START TRANSACTION", + "SELECT dolt_merge('other')", + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT table_name FROM dolt.schema_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT table_name FROM dolt_schema_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Skip: true, // TODO: referencing items outside the schema or database is not yet supported + Query: `SELECT dolt.schema_conflicts.table_name FROM dolt.schema_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT dolt_schema_conflicts.table_name FROM dolt_schema_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT * FROM public.schema_conflicts`, + ExpectedErr: "table not found", + }, + { + Query: `SELECT * FROM schema_conflicts`, + ExpectedErr: "table not found", + }, + { + Query: `CREATE TABLE schema_conflicts (id INT PRIMARY KEY)`, + Expected: []sql.Row{}, + }, + { + Query: `INSERT INTO schema_conflicts VALUES (1)`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM schema_conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT table_name FROM dolt.schema_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: "SET search_path = 'dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT table_name FROM schema_conflicts`, + Expected: []sql.Row{{"test"}}, + }, + { + Query: `SELECT * FROM public.schema_conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM schema_conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: "SET search_path = 'public,dolt'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM schema_conflicts`, + Expected: []sql.Row{{1}}, + }, + { + Query: `SELECT * FROM SCHEMA_CONFLICTS`, + Expected: []sql.Row{{1}}, + }, + }, + }, { Name: "dolt schemas", SetUpScript: []string{ From e6d6a19a7a43ee8062c43a4b8207b8191251dc5a Mon Sep 17 00:00:00 2001 From: tbantle22 Date: Wed, 30 Oct 2024 22:31:17 +0000 Subject: [PATCH 3/3] [ga-bump-dep] Bump dependency in Doltgres by tbantle22 --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 177aba7557..96232e3462 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,11 @@ require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a github.com/cockroachdb/errors v1.7.5 - github.com/dolthub/dolt/go v0.40.5-0.20241028195925-746ebc613846 + github.com/dolthub/dolt/go v0.40.5-0.20241030222313-1035f4fe0f65 github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240827111219-e4bb9ca3442d github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 - github.com/dolthub/go-mysql-server v0.18.2-0.20241028220705-fc9e96ed4c1d + github.com/dolthub/go-mysql-server v0.18.2-0.20241029221022-84d576aadba3 github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216 github.com/dolthub/vitess v0.0.0-20241028204000-267861bc75a0 github.com/fatih/color v1.13.0 diff --git a/go.sum b/go.sum index 001248ce5e..56068cf8c0 100644 --- a/go.sum +++ b/go.sum @@ -214,8 +214,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dolthub/dolt/go v0.40.5-0.20241028195925-746ebc613846 h1:IYbgv29ClfGVj/vM4qxQpZJQnw9XdrW8UZxNaVYJjKc= -github.com/dolthub/dolt/go v0.40.5-0.20241028195925-746ebc613846/go.mod h1:sZ612KergPWZQkkCL5uVi6BV15YH08HlBXOyRzEccg8= +github.com/dolthub/dolt/go v0.40.5-0.20241030222313-1035f4fe0f65 h1:M+mytO/63y6/1/izuKKn6WQ+bvHSARHOq+3m4nHYEsw= +github.com/dolthub/dolt/go v0.40.5-0.20241030222313-1035f4fe0f65/go.mod h1:i8wcX6lhfFfRt5SR9YzL6l4rHMguTOaz+uvQBTjoykE= github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240827111219-e4bb9ca3442d h1:RZkQeYOrDrOWzCxaP2ttkvg4E2TM9n8lnEsIBLKjqkM= github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240827111219-e4bb9ca3442d/go.mod h1:L5RDYZbC9BBWmoU2+TjTekeqqhFXX5EqH9ln00O0stY= github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww= @@ -224,8 +224,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U= github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0= github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA= github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168= -github.com/dolthub/go-mysql-server v0.18.2-0.20241028220705-fc9e96ed4c1d h1:FLs7/W5OmRnp/UPRw5PEa+PrcvtVk5ZV+C9RCQ78CnE= -github.com/dolthub/go-mysql-server v0.18.2-0.20241028220705-fc9e96ed4c1d/go.mod h1:jlzVUA+tsjDw6YKbhRsCLHT3OVO6nn4BWrUanECTo3s= +github.com/dolthub/go-mysql-server v0.18.2-0.20241029221022-84d576aadba3 h1:+8/lCQN28l+a14+b/RX3DfkWU5eZMKTqIt8ATKWEQ7c= +github.com/dolthub/go-mysql-server v0.18.2-0.20241029221022-84d576aadba3/go.mod h1:jlzVUA+tsjDw6YKbhRsCLHT3OVO6nn4BWrUanECTo3s= github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI= github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q= github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=