From 66e9ee79c75e2b684d47fd791a4a08f777eb731a Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 21 May 2001 18:42:08 +0000 Subject: [PATCH] Print error on SELECT tab FROM tab: You can't use relation names alone in the target list, try relation.* --- doc/TODO | 2 +- src/backend/parser/parse_expr.c | 5 ++++- src/backend/parser/parse_target.c | 5 ++++- src/include/nodes/parsenodes.h | 5 ++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/TODO b/doc/TODO index b4f32d3c6a..cd52a83393 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,6 +1,6 @@ TODO list for PostgreSQL ======================== -Last updated: Mon May 21 14:36:45 EDT 2001 +Last updated: Mon May 21 14:40:08 EDT 2001 Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 08a2f5f203..4cbbc1c980 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.95 2001/05/19 00:33:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.96 2001/05/21 18:42:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -585,7 +585,10 @@ transformIdent(ParseState *pstate, Ident *ident, int precedence) Node *var = colnameToVar(pstate, ident->name); if (var != NULL) + { + ident->isRel = FALSE; result = transformIndirection(pstate, var, ident->indirection); + } } if (result == NULL) diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 8f8ea4e168..be48c899dd 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.66 2001/03/22 03:59:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.67 2001/05/21 18:42:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,6 +55,9 @@ transformTargetEntry(ParseState *pstate, if (expr == NULL) expr = transformExpr(pstate, node, EXPR_COLUMN_FIRST); + if (IsA(expr, Ident) && ((Ident *)expr)->isRel) + elog(ERROR,"You can't use relation names alone in the target list, try relation.*."); + type_id = exprType(expr); type_mod = exprTypmod(expr); diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index cfea522296..ff4cc27831 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.128 2001/05/20 20:28:20 tgl Exp $ + * $Id: parsenodes.h,v 1.129 2001/05/21 18:42:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1081,8 +1081,7 @@ typedef struct Ident NodeTag type; char *name; /* its name */ List *indirection; /* array references */ - bool isRel; /* is a relation - filled in by - * transformExpr() */ + bool isRel; /* is this a relation or a column? */ } Ident; /* -- 2.11.0