diff --git a/pkg/sql/explain_test.go b/pkg/sql/explain_test.go index d1ecceed43ab..2438a50a794d 100644 --- a/pkg/sql/explain_test.go +++ b/pkg/sql/explain_test.go @@ -37,6 +37,7 @@ func TestStatementReuses(t *testing.T) { `CREATE SEQUENCE s`, `CREATE INDEX woo ON a(b)`, `CREATE USER woo`, + `CREATE TYPE test as ENUM('a')`, } for _, s := range initStmts { @@ -54,6 +55,7 @@ func TestStatementReuses(t *testing.T) { `DROP SEQUENCE s`, `DROP VIEW v`, `DROP USER woo`, + `DROP TYPE test`, // Ditto ALTER first, so that erroneous side effects bork what's // below. diff --git a/pkg/sql/logictest/testdata/logic_test/prepare b/pkg/sql/logictest/testdata/logic_test/prepare index 2e0f639bc4c0..8fb45ae9b91a 100644 --- a/pkg/sql/logictest/testdata/logic_test/prepare +++ b/pkg/sql/logictest/testdata/logic_test/prepare @@ -1355,6 +1355,10 @@ CREATE TABLE greeting_table (x greeting NOT NULL, y INT, INDEX (x, y)) statement ok PREPARE enum_query AS SELECT x, y FROM greeting_table WHERE y = 2 +# Create prepared statement to drop type. +statement ok +PREPARE enum_drop AS DROP TYPE greeting + # Now alter the enum to have a new value. statement ok ALTER TYPE greeting ADD VALUE 'howdy' @@ -1368,3 +1372,11 @@ query TI EXECUTE enum_query ---- howdy 2 + +# drop table +statement ok +DROP TABLE greeting_table + +# drop the type using prepared statement. +statement ok +EXECUTE enum_drop diff --git a/pkg/sql/plan_opt.go b/pkg/sql/plan_opt.go index 55688430cc87..3c30b9175a17 100644 --- a/pkg/sql/plan_opt.go +++ b/pkg/sql/plan_opt.go @@ -61,8 +61,8 @@ func (p *planner) prepareUsingOptimizer(ctx context.Context) (planFlags, error) *tree.CreateSequence, *tree.CreateStats, *tree.Deallocate, *tree.Discard, *tree.DropDatabase, *tree.DropIndex, - *tree.DropTable, *tree.DropView, *tree.DropSequence, - *tree.Execute, + *tree.DropTable, *tree.DropView, *tree.DropSequence, *tree.DropType, + *tree.Execute, *tree.Explain, *tree.Grant, *tree.GrantRole, *tree.Prepare, *tree.ReleaseSavepoint, *tree.RenameColumn, *tree.RenameDatabase,