From 19248772ff66bb15c0813256dd1f019645ea4389 Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Mon, 31 Mar 2025 17:42:00 -0700 Subject: [PATCH 1/5] turn off stats by default for doltgres launch --- server/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/server.go b/server/server.go index 25b150ed4b..a0efbc3ecf 100644 --- a/server/server.go +++ b/server/server.go @@ -95,6 +95,8 @@ func runServer(ctx context.Context, cfg *servercfg.DoltgresConfig, dEnv *env.Dol defer tempfiles.MovableTempFileProvider.Clean() + sql.SystemVariables.SetGlobal(dsess.DoltStatsEnabled, false) + err := dsess.InitPersistedSystemVars(dEnv) if err != nil { return nil, errors.Errorf("failed to load persisted system variables: %w", err) From f66d1486a1bc4df0d4c002466bbe23eae616156b Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Mon, 31 Mar 2025 17:48:41 -0700 Subject: [PATCH 2/5] fmt --- server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index a0efbc3ecf..d95931678b 100644 --- a/server/server.go +++ b/server/server.go @@ -96,7 +96,7 @@ func runServer(ctx context.Context, cfg *servercfg.DoltgresConfig, dEnv *env.Dol defer tempfiles.MovableTempFileProvider.Clean() sql.SystemVariables.SetGlobal(dsess.DoltStatsEnabled, false) - + err := dsess.InitPersistedSystemVars(dEnv) if err != nil { return nil, errors.Errorf("failed to load persisted system variables: %w", err) From 6248ae6e296b3181be85155566c7db101cdd214b Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Mon, 31 Mar 2025 18:56:22 -0700 Subject: [PATCH 3/5] disable tests --- testing/go/dolt_tables_test.go | 265 +++++++++++++++++---------------- 1 file changed, 133 insertions(+), 132 deletions(-) diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index ed5592d6c8..53fa57c0cb 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -1748,137 +1748,138 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, - { - Name: "dolt statistics", - SetUpScript: []string{ - "CREATE TABLE horses (id int primary key, name varchar(10));", - "CREATE INDEX horses_name_idx ON horses(name);", - "insert into horses select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;", - }, - Assertions: []ScriptTestAssertion{ - { - Query: `ANALYZE horses;`, - Expected: []sql.Row{}, - }, - { - Query: `SELECT database_name, table_name, index_name, row_count, distinct_count, columns, upper_bound, upper_bound_cnt FROM dolt_statistics ORDER BY index_name, row_count`, - Expected: []sql.Row{ - {"postgres", "horses", "horses_name_idx", 70, 1, "name", "Steve", 70}, - {"postgres", "horses", "horses_name_idx", 126, 1, "name", "Steve", 126}, - {"postgres", "horses", "horses_name_idx", 141, 1, "name", "Steve", 141}, - {"postgres", "horses", "horses_name_idx", 146, 1, "name", "Steve", 146}, - {"postgres", "horses", "horses_name_idx", 160, 1, "name", "Steve", 160}, - {"postgres", "horses", "horses_name_idx", 165, 1, "name", "Steve", 165}, - {"postgres", "horses", "horses_name_idx", 192, 1, "name", "Steve", 192}, - {"postgres", "horses", "primary", 46, 46, "id", "1000", 1}, - {"postgres", "horses", "primary", 76, 76, "id", "954", 1}, - {"postgres", "horses", "primary", 89, 89, "id", "547", 1}, - {"postgres", "horses", "primary", 117, 117, "id", "117", 1}, - {"postgres", "horses", "primary", 149, 149, "id", "458", 1}, - {"postgres", "horses", "primary", 162, 162, "id", "709", 1}, - {"postgres", "horses", "primary", 169, 169, "id", "878", 1}, - {"postgres", "horses", "primary", 192, 192, "id", "309", 1}, - }, - }, - { - Query: `SELECT count(*) FROM dolt_statistics`, - Expected: []sql.Row{{15}}, - }, - { - Query: `SELECT count(*) FROM public.dolt_statistics`, - Expected: []sql.Row{{15}}, - }, - { - Query: `SELECT dolt_statistics.index_name FROM public.dolt_statistics GROUP BY index_name ORDER BY index_name`, - Expected: []sql.Row{{"horses_name_idx"}, {"primary"}}, - }, - { - Query: `SELECT name FROM other.dolt_statistics`, - ExpectedErr: "database schema not found", - }, - { - Query: `CREATE SCHEMA newschema`, - Expected: []sql.Row{}, - }, - { - Query: "SET search_path = 'newschema'", - Expected: []sql.Row{}, - }, - { - Query: `SELECT count(*) FROM dolt_statistics`, - Expected: []sql.Row{{0}}, - }, - { - Query: "CREATE TABLE horses2 (id int primary key, name varchar(10));", - Expected: []sql.Row{}, - }, - { - Query: "CREATE INDEX horses2_name_idx ON horses2(name);", - Expected: []sql.Row{}, - }, - { - Query: "insert into horses2 select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;", - Expected: []sql.Row{}, - }, - { - Query: `ANALYZE horses2;`, - Expected: []sql.Row{}, - }, - { - Query: `SELECT dolt_statistics.index_name FROM dolt_statistics GROUP BY index_name ORDER BY index_name`, - Expected: []sql.Row{{"horses2_name_idx"}, {"primary"}}, - }, - { - Query: `SELECT dolt_statistics.index_name FROM newschema.dolt_statistics GROUP BY index_name ORDER BY index_name`, - Expected: []sql.Row{{"horses2_name_idx"}, {"primary"}}, - }, - { - Query: `SELECT dolt_statistics.index_name FROM public.dolt_statistics GROUP BY index_name ORDER BY index_name`, - Expected: []sql.Row{{"horses_name_idx"}, {"primary"}}, - }, - // Same table name, different schema - { - Query: "CREATE TABLE horses (id int primary key, name varchar(10));", - Expected: []sql.Row{}, - }, - { - Query: "CREATE INDEX horses3_name_idx ON horses(name);", - Expected: []sql.Row{}, - }, - { - Query: "insert into horses select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;", - Expected: []sql.Row{}, - }, - { - Query: `ANALYZE horses;`, - Expected: []sql.Row{}, - }, - { - Query: `SELECT table_name, index_name FROM dolt_statistics GROUP BY table_name, index_name ORDER BY table_name, index_name`, - Skip: true, // TODO: seems to be flaky on CI, works locally no matter how many times it's run - Expected: []sql.Row{ - {"horses", "horses3_name_idx"}, - {"horses", "primary"}, - {"horses2", "horses2_name_idx"}, - {"horses2", "primary"}, - }, - }, - { - Query: `SELECT table_name, index_name FROM newschema.dolt_statistics GROUP BY table_name, index_name ORDER BY table_name, index_name`, - Skip: true, // TODO: seems to be flaky on CI, works locally no matter how many times it's run - Expected: []sql.Row{ - {"horses", "horses3_name_idx"}, - {"horses", "primary"}, - {"horses2", "horses2_name_idx"}, - {"horses2", "primary"}, - }, - }, - { - Query: `SELECT table_name, index_name FROM public.dolt_statistics GROUP BY index_name ORDER BY index_name`, - Expected: []sql.Row{{"horses", "horses_name_idx"}, {"horses", "primary"}}, - }, - }, - }, + // TODO: turn stats back on + //{ + // Name: "dolt statistics", + // SetUpScript: []string{ + // "CREATE TABLE horses (id int primary key, name varchar(10));", + // "CREATE INDEX horses_name_idx ON horses(name);", + // "insert into horses select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;", + // }, + // Assertions: []ScriptTestAssertion{ + // { + // Query: `ANALYZE horses;`, + // Expected: []sql.Row{}, + // }, + // { + // Query: `SELECT database_name, table_name, index_name, row_count, distinct_count, columns, upper_bound, upper_bound_cnt FROM dolt_statistics ORDER BY index_name, row_count`, + // Expected: []sql.Row{ + // {"postgres", "horses", "horses_name_idx", 70, 1, "name", "Steve", 70}, + // {"postgres", "horses", "horses_name_idx", 126, 1, "name", "Steve", 126}, + // {"postgres", "horses", "horses_name_idx", 141, 1, "name", "Steve", 141}, + // {"postgres", "horses", "horses_name_idx", 146, 1, "name", "Steve", 146}, + // {"postgres", "horses", "horses_name_idx", 160, 1, "name", "Steve", 160}, + // {"postgres", "horses", "horses_name_idx", 165, 1, "name", "Steve", 165}, + // {"postgres", "horses", "horses_name_idx", 192, 1, "name", "Steve", 192}, + // {"postgres", "horses", "primary", 46, 46, "id", "1000", 1}, + // {"postgres", "horses", "primary", 76, 76, "id", "954", 1}, + // {"postgres", "horses", "primary", 89, 89, "id", "547", 1}, + // {"postgres", "horses", "primary", 117, 117, "id", "117", 1}, + // {"postgres", "horses", "primary", 149, 149, "id", "458", 1}, + // {"postgres", "horses", "primary", 162, 162, "id", "709", 1}, + // {"postgres", "horses", "primary", 169, 169, "id", "878", 1}, + // {"postgres", "horses", "primary", 192, 192, "id", "309", 1}, + // }, + // }, + // { + // Query: `SELECT count(*) FROM dolt_statistics`, + // Expected: []sql.Row{{15}}, + // }, + // { + // Query: `SELECT count(*) FROM public.dolt_statistics`, + // Expected: []sql.Row{{15}}, + // }, + // { + // Query: `SELECT dolt_statistics.index_name FROM public.dolt_statistics GROUP BY index_name ORDER BY index_name`, + // Expected: []sql.Row{{"horses_name_idx"}, {"primary"}}, + // }, + // { + // Query: `SELECT name FROM other.dolt_statistics`, + // ExpectedErr: "database schema not found", + // }, + // { + // Query: `CREATE SCHEMA newschema`, + // Expected: []sql.Row{}, + // }, + // { + // Query: "SET search_path = 'newschema'", + // Expected: []sql.Row{}, + // }, + // { + // Query: `SELECT count(*) FROM dolt_statistics`, + // Expected: []sql.Row{{0}}, + // }, + // { + // Query: "CREATE TABLE horses2 (id int primary key, name varchar(10));", + // Expected: []sql.Row{}, + // }, + // { + // Query: "CREATE INDEX horses2_name_idx ON horses2(name);", + // Expected: []sql.Row{}, + // }, + // { + // Query: "insert into horses2 select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;", + // Expected: []sql.Row{}, + // }, + // { + // Query: `ANALYZE horses2;`, + // Expected: []sql.Row{}, + // }, + // { + // Query: `SELECT dolt_statistics.index_name FROM dolt_statistics GROUP BY index_name ORDER BY index_name`, + // Expected: []sql.Row{{"horses2_name_idx"}, {"primary"}}, + // }, + // { + // Query: `SELECT dolt_statistics.index_name FROM newschema.dolt_statistics GROUP BY index_name ORDER BY index_name`, + // Expected: []sql.Row{{"horses2_name_idx"}, {"primary"}}, + // }, + // { + // Query: `SELECT dolt_statistics.index_name FROM public.dolt_statistics GROUP BY index_name ORDER BY index_name`, + // Expected: []sql.Row{{"horses_name_idx"}, {"primary"}}, + // }, + // // Same table name, different schema + // { + // Query: "CREATE TABLE horses (id int primary key, name varchar(10));", + // Expected: []sql.Row{}, + // }, + // { + // Query: "CREATE INDEX horses3_name_idx ON horses(name);", + // Expected: []sql.Row{}, + // }, + // { + // Query: "insert into horses select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;", + // Expected: []sql.Row{}, + // }, + // { + // Query: `ANALYZE horses;`, + // Expected: []sql.Row{}, + // }, + // { + // Query: `SELECT table_name, index_name FROM dolt_statistics GROUP BY table_name, index_name ORDER BY table_name, index_name`, + // Skip: true, // TODO: seems to be flaky on CI, works locally no matter how many times it's run + // Expected: []sql.Row{ + // {"horses", "horses3_name_idx"}, + // {"horses", "primary"}, + // {"horses2", "horses2_name_idx"}, + // {"horses2", "primary"}, + // }, + // }, + // { + // Query: `SELECT table_name, index_name FROM newschema.dolt_statistics GROUP BY table_name, index_name ORDER BY table_name, index_name`, + // Skip: true, // TODO: seems to be flaky on CI, works locally no matter how many times it's run + // Expected: []sql.Row{ + // {"horses", "horses3_name_idx"}, + // {"horses", "primary"}, + // {"horses2", "horses2_name_idx"}, + // {"horses2", "primary"}, + // }, + // }, + // { + // Query: `SELECT table_name, index_name FROM public.dolt_statistics GROUP BY index_name ORDER BY index_name`, + // Expected: []sql.Row{{"horses", "horses_name_idx"}, {"horses", "primary"}}, + // }, + // }, + //}, { Name: "dolt status", SetUpScript: []string{ @@ -2075,7 +2076,7 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, { - Name: "dolt procedures", + Name: "dolt procedures", SetUpScript: []string{ // TODO: Create procedure when supported }, From 9b8f68e278af374bbc78b7562b7349771b6a64c8 Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Mon, 31 Mar 2025 18:59:20 -0700 Subject: [PATCH 4/5] fmt --- testing/go/dolt_tables_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index 53fa57c0cb..c14f8ade53 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -2076,7 +2076,7 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, { - Name: "dolt procedures", + Name: "dolt procedures", SetUpScript: []string{ // TODO: Create procedure when supported }, From 0bc595b9ecaa885ad66c72ce5313618e1d39e329 Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Tue, 15 Apr 2025 10:07:12 -0700 Subject: [PATCH 5/5] fmt --- server/server.go | 2 +- testing/go/dolt_tables_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/server.go b/server/server.go index 2613f9dc27..1c9ce9b7d6 100644 --- a/server/server.go +++ b/server/server.go @@ -95,7 +95,7 @@ func runServer(ctx context.Context, cfg *servercfg.DoltgresConfig, dEnv *env.Dol defer tempfiles.MovableTempFileProvider.Clean() - sql.SystemVariables.SetGlobal(dsess.DoltStatsEnabled, false) + sql.SystemVariables.SetGlobal(sql.NewContext(ctx), dsess.DoltStatsEnabled, false) err := dsess.InitPersistedSystemVars(dEnv) if err != nil { diff --git a/testing/go/dolt_tables_test.go b/testing/go/dolt_tables_test.go index f3a2a3bd43..9f2b82883d 100755 --- a/testing/go/dolt_tables_test.go +++ b/testing/go/dolt_tables_test.go @@ -1753,7 +1753,7 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, }, - //TODO: turn on statistics + //TODO: turn on statistics //{ // Name: "dolt statistics", // SetUpScript: []string{ @@ -2077,7 +2077,7 @@ func TestUserSpaceDoltTables(t *testing.T) { }, }, { - Name: "dolt procedures", + Name: "dolt procedures", SetUpScript: []string{ // TODO: Create procedure when supported },