github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/delegate/show_sequences.go (about) 1 // Copyright 2019 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 delegate 12 13 import ( 14 "fmt" 15 16 "github.com/cockroachdb/cockroach/pkg/sql/lex" 17 "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" 18 ) 19 20 // ShowSequences returns all the schemas in the given or current database. 21 // Privileges: None. 22 // Notes: postgres does not have a SHOW SEQUENCES statement. 23 func (d *delegator) delegateShowSequences(n *tree.ShowSequences) (tree.Statement, error) { 24 name, err := d.getSpecifiedOrCurrentDatabase(n.Database) 25 if err != nil { 26 return nil, err 27 } 28 29 getSequencesQuery := fmt.Sprintf(` 30 SELECT sequence_name 31 FROM %[1]s.information_schema.sequences 32 WHERE sequence_catalog = %[2]s 33 AND sequence_schema = 'public' 34 ORDER BY sequence_name`, 35 name.String(), // note: (tree.Name).String() != string(name) 36 lex.EscapeSQLString(string(name)), 37 ) 38 return parse(getSequencesQuery) 39 }