MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / ParseTableName

Function ParseTableName

pkg/sql/parser/parse.go:291–303  ·  view source on GitHub ↗

ParseTableName parses a table name. The table name must contain one or more name parts, using the full input SQL syntax: each name part containing special characters, or non-lowercase characters, must be enclosed in double quote. The name may not be an invalid table name (the caller is responsible f

(sql string)

Source from the content-addressed store, hash-verified

289// table name (the caller is responsible for guaranteeing that only
290// valid table names are provided as input).
291func ParseTableName(sql string) (*tree.UnresolvedObjectName, error) {
292 // We wrap the name we want to parse into a dummy statement since our parser
293 // can only parse full statements.
294 stmt, err := ParseOne(fmt.Sprintf("ALTER TABLE %s RENAME TO x", sql))
295 if err != nil {
296 return nil, err
297 }
298 rename, ok := stmt.AST.(*tree.RenameTable)
299 if !ok {
300 return nil, errors.AssertionFailedf("expected an ALTER TABLE statement, but found %T", stmt)
301 }
302 return rename.Name, nil
303}
304
305// ParseFunctionName parses a function name. The function name must contain one
306// or more name parts, using the full input SQL syntax: each name

Callers 1

ParseQualifiedTableNameFunction · 0.85

Calls 1

ParseOneFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…