NewUnresolvedObjectName creates an unresolved object name, verifying that it is well-formed.
( numParts int, parts [3]string, annotationIdx AnnotationIdx, )
| 228 | // NewUnresolvedObjectName creates an unresolved object name, verifying that it |
| 229 | // is well-formed. |
| 230 | func 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). |
no test coverage detected
searching dependent graphs…