Commit 2ea370a3 authored by Bruce Momjian's avatar Bruce Momjian

New warning code about auto-created range table entries.

parent 58785757
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.81 2000/05/30 00:49:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.82 2000/06/03 04:41:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -307,11 +307,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, ...@@ -307,11 +307,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
rte = addRangeTableEntry(pstate, refname, rte = addRangeTableEntry(pstate, refname,
makeAttr(refname, NULL), makeAttr(refname, NULL),
FALSE, FALSE, TRUE); FALSE, FALSE, TRUE);
#ifdef WARN_FROM warnAutoRange(pstate, refname);
elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
pstate->parentParseState != NULL ? " in subquery" : "",
refname);
#endif
} }
relname = rte->relname; relname = rte->relname;
...@@ -525,11 +521,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, ...@@ -525,11 +521,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
rte = addRangeTableEntry(pstate, refname, rte = addRangeTableEntry(pstate, refname,
makeAttr(refname, NULL), makeAttr(refname, NULL),
FALSE, FALSE, TRUE); FALSE, FALSE, TRUE);
#ifdef WARN_FROM warnAutoRange(pstate, refname);
elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
pstate->parentParseState != NULL ? " in subquery" : "",
refname);
#endif
} }
relname = rte->relname; relname = rte->relname;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.40 2000/04/12 17:15:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.41 2000/06/03 04:41:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -373,11 +373,7 @@ expandAll(ParseState *pstate, char *relname, Attr *ref, int *this_resno) ...@@ -373,11 +373,7 @@ expandAll(ParseState *pstate, char *relname, Attr *ref, int *this_resno)
{ {
rte = addRangeTableEntry(pstate, relname, ref, rte = addRangeTableEntry(pstate, relname, ref,
FALSE, FALSE, TRUE); FALSE, FALSE, TRUE);
#ifdef WARN_FROM warnAutoRange(pstate, ref->relname);
elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
pstate->parentParseState != NULL ? " in subquery" : "",
refname);
#endif
} }
rel = heap_open(rte->relid, AccessShareLock); rel = heap_open(rte->relid, AccessShareLock);
...@@ -526,3 +522,26 @@ attnumTypeId(Relation rd, int attid) ...@@ -526,3 +522,26 @@ attnumTypeId(Relation rd, int attid)
*/ */
return rd->rd_att->attrs[attid - 1]->atttypid; return rd->rd_att->attrs[attid - 1]->atttypid;
} }
void
warnAutoRange(ParseState *pstate, char *refname)
{
List *temp;
bool foundInFromCl = false;
foreach(temp, pstate->p_rtable)
{
RangeTblEntry *rte = lfirst(temp);
if (rte->inFromCl)
{
foundInFromCl = true;
break;
}
}
if (foundInFromCl)
elog(NOTICE, "Adding missing FROM-clause entry%s for table %s",
pstate->parentParseState != NULL ? " in subquery" : "",
refname);
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parse_relation.h,v 1.16 2000/04/12 17:16:45 momjian Exp $ * $Id: parse_relation.h,v 1.17 2000/06/03 04:41:33 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -35,5 +35,6 @@ extern int specialAttNum(char *a); ...@@ -35,5 +35,6 @@ extern int specialAttNum(char *a);
extern bool attnameIsSet(Relation rd, char *name); extern bool attnameIsSet(Relation rd, char *name);
extern int attnumAttNelems(Relation rd, int attid); extern int attnumAttNelems(Relation rd, int attid);
extern Oid attnumTypeId(Relation rd, int attid); extern Oid attnumTypeId(Relation rd, int attid);
extern void warnAutoRange(ParseState *pstate, char *refname);
#endif /* PARSE_RELATION_H */ #endif /* PARSE_RELATION_H */
...@@ -5,9 +5,12 @@ SELECT * ...@@ -5,9 +5,12 @@ SELECT *
INTO TABLE tmp1 INTO TABLE tmp1
FROM tmp FROM tmp
WHERE onek.unique1 < 2; WHERE onek.unique1 < 2;
NOTICE: Adding missing FROM-clause entry for table onek
DROP TABLE tmp1; DROP TABLE tmp1;
SELECT * SELECT *
INTO TABLE tmp1 INTO TABLE tmp1
FROM tmp FROM tmp
WHERE onek2.unique1 < 2; WHERE onek2.unique1 < 2;
DROP TABLE tmp1; DROP TABLE tmp1;
NOTICE: Adding missing FROM-clause entry for table onek
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment