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)
| 289 | // table name (the caller is responsible for guaranteeing that only |
| 290 | // valid table names are provided as input). |
| 291 | func 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 |
no test coverage detected
searching dependent graphs…