github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/deallocate.go (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package sql 12 13 import ( 14 "context" 15 16 "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" 17 "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" 18 "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" 19 ) 20 21 // Deallocate implements the DEALLOCATE statement. 22 // See https://www.postgresql.org/docs/current/static/sql-deallocate.html for details. 23 func (p *planner) Deallocate(ctx context.Context, s *tree.Deallocate) (planNode, error) { 24 if s.Name == "" { 25 p.preparedStatements.DeleteAll(ctx) 26 } else { 27 if found := p.preparedStatements.Delete(ctx, string(s.Name)); !found { 28 return nil, pgerror.Newf(pgcode.InvalidSQLStatementName, 29 "prepared statement %q does not exist", s.Name) 30 } 31 } 32 return newZeroNode(nil /* columns */), nil 33 }