MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / NewUnresolvedObjectName

Function NewUnresolvedObjectName

pkg/sql/sem/tree/name_part.go:230–255  ·  view source on GitHub ↗

NewUnresolvedObjectName creates an unresolved object name, verifying that it is well-formed.

(
	numParts int, parts [3]string, annotationIdx AnnotationIdx,
)

Source from the content-addressed store, hash-verified

228// NewUnresolvedObjectName creates an unresolved object name, verifying that it
229// is well-formed.
230func NewUnresolvedObjectName(
231 numParts int, parts [3]string, annotationIdx AnnotationIdx,
232) (*UnresolvedObjectName, error) {
233 u := &UnresolvedObjectName{
234 NumParts: numParts,
235 Parts: parts,
236 AnnotatedNode: AnnotatedNode{AnnIdx: annotationIdx},
237 }
238 if u.NumParts < 1 {
239 return nil, newInvTableNameError(u)
240 }
241
242 // Check that all the parts specified are not empty.
243 // It's OK if the catalog name is empty.
244 // We allow this in e.g. `select * from "".crdb_internal.tables`.
245 lastCheck := u.NumParts
246 if lastCheck > 2 {
247 lastCheck = 2
248 }
249 for i := 0; i < lastCheck; i++ {
250 if len(u.Parts[i]) == 0 {
251 return nil, newInvTableNameError(u)
252 }
253 }
254 return u, nil
255}
256
257// Resolved returns the resolved name in the annotation for this node (or nil if
258// there isn't one).

Callers 2

ParseMethod · 0.92
classifyColumnItemFunction · 0.85

Calls 1

newInvTableNameErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…