* helper routine for delivering "column does not exist" error message * * (Usually we don't have to work this hard, but the general case of field * selection from an arbitrary node needs it.) */
| 353 | * selection from an arbitrary node needs it.) |
| 354 | */ |
| 355 | static void |
| 356 | unknown_attribute(ParseState *pstate, Node *relref, const char *attname, |
| 357 | int location) |
| 358 | { |
| 359 | RangeTblEntry *rte; |
| 360 | |
| 361 | if (IsA(relref, Var) && |
| 362 | ((Var *) relref)->varattno == InvalidAttrNumber) |
| 363 | { |
| 364 | /* Reference the RTE by alias not by actual table name */ |
| 365 | rte = GetRTEByRangeTablePosn(pstate, |
| 366 | ((Var *) relref)->varno, |
| 367 | ((Var *) relref)->varlevelsup); |
| 368 | ereport(ERROR, |
| 369 | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| 370 | errmsg("column %s.%s does not exist", |
| 371 | rte->eref->aliasname, attname), |
| 372 | parser_errposition(pstate, location))); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | /* Have to do it by reference to the type of the expression */ |
| 377 | Oid relTypeId = exprType(relref); |
| 378 | |
| 379 | if (ISCOMPLEX(relTypeId)) |
| 380 | ereport(ERROR, |
| 381 | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| 382 | errmsg("column \"%s\" not found in data type %s", |
| 383 | attname, format_type_be(relTypeId)), |
| 384 | parser_errposition(pstate, location))); |
| 385 | else if (relTypeId == RECORDOID) |
| 386 | ereport(ERROR, |
| 387 | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| 388 | errmsg("could not identify column \"%s\" in record data type", |
| 389 | attname), |
| 390 | parser_errposition(pstate, location))); |
| 391 | else |
| 392 | ereport(ERROR, |
| 393 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 394 | errmsg("column notation .%s applied to type %s, " |
| 395 | "which is not a composite type", |
| 396 | attname, format_type_be(relTypeId)), |
| 397 | parser_errposition(pstate, location))); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | static Node * |
| 402 | transformIndirection(ParseState *pstate, A_Indirection *ind) |
no test coverage detected