From 819136d699a3df3aa4ce74d26bb2957e2a3bbfd0 Mon Sep 17 00:00:00 2001 From: Aaron Son Date: Wed, 29 Jan 2025 09:45:36 -0800 Subject: [PATCH] go: dtables: help_table: Manually specify that dolt_gc exists for now. --- go/libraries/doltcore/sqle/dtables/help_table.go | 5 +++++ go/libraries/doltcore/sqle/enginetest/dolt_harness.go | 2 ++ go/libraries/doltcore/sqle/sqlddl_test.go | 3 +++ go/libraries/doltcore/sqle/testutil.go | 3 +++ 4 files changed, 13 insertions(+) diff --git a/go/libraries/doltcore/sqle/dtables/help_table.go b/go/libraries/doltcore/sqle/dtables/help_table.go index b10e96e6dc..00defe3436 100644 --- a/go/libraries/doltcore/sqle/dtables/help_table.go +++ b/go/libraries/doltcore/sqle/dtables/help_table.go @@ -217,6 +217,11 @@ func generateProcedureHelpRows(cmdStr string, cmd cli.Command) ([]sql.Row, error // procedureExists returns whether |procedureName| is the name of a dolt procedure. func procedureExists(procedureName string) bool { + // "dolt_gc" is dynamically registered because it has state (a safepoint controller). + // For now, special case it here. + if procedureName == "dolt_gc" { + return true + } for _, procedure := range dprocedures.DoltProcedures { if procedure.Name == procedureName { return true diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_harness.go b/go/libraries/doltcore/sqle/enginetest/dolt_harness.go index 2992593e92..8eb582ee8f 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_harness.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_harness.go @@ -485,6 +485,8 @@ func (d *DoltHarness) NewReadOnlyEngine(provider sql.DatabaseProvider) (enginete if err != nil { return nil, err } + gcSafepointController := dsess.NewGCSafepointController() + readOnlyProvider.RegisterProcedure(dprocedures.NewDoltGCProcedure(gcSafepointController)) // reset the session as well since we have swapped out the database provider, which invalidates caching assumptions d.session, err = dsess.NewDoltSession(enginetest.NewBaseSession(), readOnlyProvider, d.multiRepoEnv.Config(), d.branchControl, d.statsPro, writer.NewWriteSession, nil) diff --git a/go/libraries/doltcore/sqle/sqlddl_test.go b/go/libraries/doltcore/sqle/sqlddl_test.go index aadb2fb946..a7c457b551 100644 --- a/go/libraries/doltcore/sqle/sqlddl_test.go +++ b/go/libraries/doltcore/sqle/sqlddl_test.go @@ -33,6 +33,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/env" "github.com/dolthub/dolt/go/libraries/doltcore/row" "github.com/dolthub/dolt/go/libraries/doltcore/schema" + "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dprocedures" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil" @@ -1107,6 +1108,8 @@ func newTestEngine(ctx context.Context, dEnv *env.DoltEnv) (*gms.Engine, *sql.Co if err != nil { panic(err) } + gcSafepointController := dsess.NewGCSafepointController() + pro.RegisterProcedure(dprocedures.NewDoltGCProcedure(gcSafepointController)) mrEnv, err := env.MultiEnvForDirectory(ctx, dEnv.Config.WriteableConfig(), dEnv.FS, dEnv.Version, dEnv) if err != nil { diff --git a/go/libraries/doltcore/sqle/testutil.go b/go/libraries/doltcore/sqle/testutil.go index c46495d4ac..85842ff82f 100644 --- a/go/libraries/doltcore/sqle/testutil.go +++ b/go/libraries/doltcore/sqle/testutil.go @@ -31,6 +31,7 @@ import ( "github.com/dolthub/dolt/go/libraries/doltcore/env" "github.com/dolthub/dolt/go/libraries/doltcore/row" "github.com/dolthub/dolt/go/libraries/doltcore/schema" + "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dprocedures" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil" "github.com/dolthub/dolt/go/libraries/doltcore/sqle/writer" @@ -135,6 +136,8 @@ func NewTestEngine(dEnv *env.DoltEnv, ctx context.Context, db dsess.SqlDatabase) if err != nil { return nil, nil, err } + gcSafepointController := dsess.NewGCSafepointController() + pro.Register(dprocedures.NewDoltGCProcedure(gcSafepointController)) engine := sqle.NewDefault(pro)