MCPcopy Create free account
hub / github.com/dolthub/doltgresql / ParseTableNameWithQualifiedNames

Function ParseTableNameWithQualifiedNames

postgres/parser/parser/parse.go:329–341  ·  view source on GitHub ↗

ParseTableNameWithQualifiedNames can be used to parse an input table name that might be prefixed with an unquoted qualified name. The standard ParseTableName cannot do this due to limitations with our parser. In particular, the parser can't parse different productions individually -- it must parse t

(sql string)

Source from the content-addressed store, hash-verified

327// with a fake non-keyword prefix, and then shifting the result down into an
328// UnresolvedObjectName.
329func ParseTableNameWithQualifiedNames(sql string) (*tree.UnresolvedObjectName, error) {
330 stmt, err := ParseOne(fmt.Sprintf("SELECT fakeprefix.%s", sql))
331 if err != nil {
332 return nil, err
333 }
334 un := stmt.AST.(*tree.Select).Select.(*tree.SelectClause).Exprs[0].Expr.(*tree.UnresolvedName)
335 var nameParts [3]string
336 numParts := un.NumParts - 1
337 for i := 0; i < numParts; i++ {
338 nameParts[i] = un.Parts[i]
339 }
340 return tree.NewUnresolvedObjectName(numParts, nameParts, 0 /* annotationIdx */)
341}
342
343// parseExprs parses one or more sql expressions.
344func parseExprs(exprs []string) (tree.Exprs, error) {

Callers

nothing calls this directly

Calls 2

NewUnresolvedObjectNameFunction · 0.92
ParseOneFunction · 0.85

Tested by

no test coverage detected