diff --git a/go.mod b/go.mod index 66ec3bb024..db3bae0b0a 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.20241114235619-0995efed23b9 + github.com/dolthub/dolt/go v0.40.5-0.20241115201116-e5d3dcc32851 github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241104143128-c2bb78c109df 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.20241114232015-87d29acb3d67 + github.com/dolthub/go-mysql-server v0.18.2-0.20241115193357-2d21230229d1 github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216 github.com/dolthub/vitess v0.0.0-20241111235433-a20a5ab9d7c9 github.com/fatih/color v1.13.0 diff --git a/go.sum b/go.sum index f35d3fe881..489a3ad96d 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.20241114235619-0995efed23b9 h1:9B26h5cfQMDZvEw2ZrQN1+MYqPZMNXJzgdSXdT+VgzM= -github.com/dolthub/dolt/go v0.40.5-0.20241114235619-0995efed23b9/go.mod h1:AJRhYyewJAejq+sd74zLcL3piCOBkkUwwp4iR6E+aPs= +github.com/dolthub/dolt/go v0.40.5-0.20241115201116-e5d3dcc32851 h1:YXtt75Ea8vubxjZaaFapZOvTk/QAInRpBf6k7zdZKhQ= +github.com/dolthub/dolt/go v0.40.5-0.20241115201116-e5d3dcc32851/go.mod h1:i3nULz7I2VgZuWdGgSJo+SsCJdz1ftjjSOPMAuV0uNk= github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241104143128-c2bb78c109df h1:xafyaNR+hSk5TwOhmNkhhrmOZKIOkxAOCiIEUzlIybc= github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241104143128-c2bb78c109df/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.20241114232015-87d29acb3d67 h1:bl9C66VxMQVd3cyS6Owy4IE9XeSvFbm2/PaJreWI1eA= -github.com/dolthub/go-mysql-server v0.18.2-0.20241114232015-87d29acb3d67/go.mod h1:sOMQzWUvHvJECzpcUxjDgV5BR/A7U+hOh596PUO2NPI= +github.com/dolthub/go-mysql-server v0.18.2-0.20241115193357-2d21230229d1 h1:FfUUxob0uurW8D8z25GfgEmBwL+dl1zWWkf85iCsnUI= +github.com/dolthub/go-mysql-server v0.18.2-0.20241115193357-2d21230229d1/go.mod h1:sOMQzWUvHvJECzpcUxjDgV5BR/A7U+hOh596PUO2NPI= 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= diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index b1533be026..b7de7da181 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -1576,6 +1576,76 @@ func TestUserSpaceDoltTables(t *testing.T) { Query: `SELECT * FROM DOCS`, Expected: []sql.Row{{1}}, }, + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `DELETE FROM dolt.docs WHERE doc_name = 'README.md'`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM dolt.docs`, + Expected: []sql.Row{}, + }, + { + Query: `DELETE FROM dolt_docs WHERE doc_name = 'README.md'`, + Expected: []sql.Row{}, + }, + // TODO: Test dolt.docs in diffs + }, + }, + { + Name: "dolt procedures", + SetUpScript: []string{ + // TODO: Create procedure when supported + }, + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM dolt_procedures`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM public.dolt_procedures`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT dolt_procedures.name FROM public.dolt_procedures`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM other.dolt_procedures`, + ExpectedErr: "database schema not found", + }, + // TODO: Add diff tests when create procedure works + { + Query: `CREATE SCHEMA newschema`, + Expected: []sql.Row{}, + }, + { + Query: "SET search_path = 'newschema'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM newschema.dolt_procedures`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM dolt_procedures`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM public.dolt_procedures`, + Expected: []sql.Row{}, + }, + { + Query: "SET search_path = 'newschema,public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM dolt_procedures`, + Expected: []sql.Row{}, + }, }, }, { @@ -1831,6 +1901,7 @@ func TestUserSpaceDoltTables(t *testing.T) { Name: "dolt schemas", SetUpScript: []string{ "create view myView as select 2 + 2", + // TODO: Add more tests when triggers and events work in doltgres }, Assertions: []ScriptTestAssertion{ { @@ -1845,6 +1916,201 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, + { + Query: `SELECT * FROM public.dolt_schemas`, + Expected: []sql.Row{ + { + "view", + "myview", + "create view myView as select 2 + 2", + "{\"CreatedAt\":0}", + "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES", + }, + }, + }, + { + Query: `SELECT dolt_schemas.name FROM public.dolt_schemas`, + Expected: []sql.Row{{"myview"}}, + }, + { + Query: `SELECT * FROM public.myview`, + Expected: []sql.Row{{4}}, + }, + { + Query: `SELECT name FROM other.dolt_schemas`, + ExpectedErr: "database schema not found", + }, + { + Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING')`, + Expected: []sql.Row{ + {"", "public.dolt_schemas", "added", 1, 1}, + }, + }, + { + Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt_schemas')`, + Expected: []sql.Row{ + {"", "public.dolt_schemas", "added", 1, 1}, + }, + }, + { + Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt_schemas')`, + Expected: []sql.Row{ + {"", "public.dolt_schemas", "added", 1, 1}, + }, + }, + { + Query: `SELECT diff_type, from_name, to_name FROM dolt_diff('main', 'WORKING', 'dolt_schemas')`, + Expected: []sql.Row{ + {"added", nil, "myview"}, + }, + }, + { + Query: `SELECT diff_type, from_name, to_name FROM dolt_diff('main', 'WORKING', 'dolt_schemas')`, + Expected: []sql.Row{ + {"added", nil, "myview"}, + }, + }, + { + Query: `CREATE SCHEMA newschema`, + Expected: []sql.Row{}, + }, + { + Query: "SET search_path = 'newschema'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM myview`, + ExpectedErr: "table not found: myview", + }, + { + Query: `SELECT * FROM public.myview`, + Expected: []sql.Row{{4}}, + }, + { + Query: `CREATE VIEW testView AS SELECT 1 + 1`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT * FROM newschema.dolt_schemas`, + Expected: []sql.Row{ + { + "view", + "testview", + "CREATE VIEW testView AS SELECT 1 + 1", + "{\"CreatedAt\":0}", + "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES", + }, + }, + }, + { + Query: `SELECT name FROM dolt_schemas`, + Expected: []sql.Row{{"testview"}}, + }, + { + Query: "SELECT table_schema, table_name FROM information_schema.views", + Expected: []sql.Row{ + {"newschema", "testview"}, + {"public", "myview"}, + }, + }, + { + Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt_schemas')`, + Expected: []sql.Row{ + {"", "newschema.dolt_schemas", "added", 1, 1}, + }, + }, + { + Skip: true, // TODO: Should be able to specify schema + Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'public.dolt_schemas')`, + Expected: []sql.Row{ + {"", "public.dolt_schemas", "added", 1, 1}, + }, + }, + { + Query: `SELECT name FROM public.dolt_schemas`, + Expected: []sql.Row{{"myview"}}, + }, + { + Query: "DROP VIEW myView", + ExpectedErr: "the view postgres.myview does not exist", + }, + { + Query: "DROP VIEW public.myView", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM public.dolt_schemas`, + Expected: []sql.Row{}, + }, + { + Query: "create view public.myNewView as select 3 + 3", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM public.dolt_schemas`, + Expected: []sql.Row{{"mynewview"}}, + }, + { + Query: `SELECT name FROM dolt_schemas`, + Expected: []sql.Row{{"testview"}}, + }, + { + Query: "SET search_path = 'newschema,public'", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM dolt_schemas`, + Expected: []sql.Row{{"testview"}}, + }, + { + Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt_schemas')`, + Expected: []sql.Row{ + {"", "newschema.dolt_schemas", "added", 1, 1}, + }, + }, + // Test same view name on different schemas + { + Query: "SET search_path = 'public'", + Expected: []sql.Row{}, + }, + { + Query: `CREATE VIEW testView AS SELECT 4 + 4`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT name, fragment FROM dolt_schemas`, + Expected: []sql.Row{ + {"mynewview", "create view public.myNewView as select 3 + 3"}, + {"testview", "CREATE VIEW testView AS SELECT 4 + 4"}, + }, + }, + { + Query: `SELECT name, fragment FROM newschema.dolt_schemas`, + Expected: []sql.Row{{"testview", "CREATE VIEW testView AS SELECT 1 + 1"}}, + }, + { + Query: `SELECT name, fragment FROM dolt_schemas`, + Expected: []sql.Row{ + {"mynewview", "create view public.myNewView as select 3 + 3"}, + {"testview", "CREATE VIEW testView AS SELECT 4 + 4"}, + }, + }, + { + Query: "DROP VIEW IF EXISTS noexist.testView", + Expected: []sql.Row{}, + }, + { + Query: "DROP VIEW IF EXISTS newschema.testView", + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM newschema.dolt_schemas`, + Expected: []sql.Row{}, + }, + { + Query: `SELECT name FROM dolt_schemas`, + Expected: []sql.Row{{"mynewview"}, {"testview"}}, + }, }, }, {