
> True, although there's a certain inconsistency in allowing a whole row
> to be passed to a function by
> 
> 	select foo(pg_class) from pg_class;
> 
> and not allowing the same row to be output by

Imho there is a big difference between the two. The foo(pg_class) calls a function 
with argument type opaque or type pg_class.
I would go so far as to say, that above foo function call would have a
different meaning if written with 'pg_class.*'.

	select foo(pg_class.*) from pg_class;
	 
Could be interpreted as calling a function foo with pg_class ncolumns 
arguments of the corresponding types.

> 
> 	select pg_class from pg_class; 

Probably a valid interpretation would be if type pg_class or opaque had an 
output function.

Andreas

Mon, 21 May 2001 17:20:40 +0200
Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at>
AW: Fix for tablename in targetlist 
Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
>> select pg_class from pg_class; 

> Probably a valid interpretation would be if type pg_class or opaque had an 
> output function.

Hmm, good point.  We shouldn't foreclose the possibility of handling
things that way.  Okay, I'm convinced: allowing .* to be omitted isn't
a good idea.

			regards, tom lane

Mon, 21 May 2001 11:47:54 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: AW: Fix for tablename in targetlist 
> Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> >> select pg_class from pg_class; 
> 
> > Probably a valid interpretation would be if type pg_class or opaque had an 
> > output function.
> 
> Hmm, good point.  We shouldn't foreclose the possibility of handling
> things that way.  Okay, I'm convinced: allowing .* to be omitted isn't
> a good idea.
> 

OK, old patch causing an elog being added now.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Mon, 21 May 2001 13:42:40 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: AW: Fix for tablename in targetlist
Patch applied and attached.  TODO updated.

> Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> >> select pg_class from pg_class; 
> 
> > Probably a valid interpretation would be if type pg_class or opaque had an 
> > output function.
> 
> Hmm, good point.  We shouldn't foreclose the possibility of handling
> things that way.  Okay, I'm convinced: allowing .* to be omitted isn't
> a good idea.
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://www.postgresql.org/search.mpl
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Index: src/backend/parser/parse_expr.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/parse_expr.c,v
retrieving revision 1.95
diff -c -r1.95 parse_expr.c
*** src/backend/parser/parse_expr.c	2001/05/19 00:33:20	1.95
--- src/backend/parser/parse_expr.c	2001/05/21 17:59:13
***************
*** 585,591 ****
--- 585,594 ----
  		Node	   *var = colnameToVar(pstate, ident->name);
  
  		if (var != NULL)
+ 		{
+ 			ident->isRel = FALSE;
  			result = transformIndirection(pstate, var, ident->indirection);
+ 		}
  	}
  
  	if (result == NULL)
Index: src/backend/parser/parse_target.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/parse_target.c,v
retrieving revision 1.66
diff -c -r1.66 parse_target.c
*** src/backend/parser/parse_target.c	2001/03/22 03:59:41	1.66
--- src/backend/parser/parse_target.c	2001/05/21 17:59:14
***************
*** 55,60 ****
--- 55,63 ----
  	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);
  
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.127
diff -c -r1.127 parsenodes.h
*** src/include/nodes/parsenodes.h	2001/05/07 00:43:25	1.127
--- src/include/nodes/parsenodes.h	2001/05/21 17:59:19
***************
*** 1080,1087 ****
  	NodeTag		type;
  	char	   *name;			/* its name */
  	List	   *indirection;	/* array references */
! 	bool		isRel;			/* is a relation - filled in by
! 								 * transformExpr() */
  } Ident;
  
  /*
--- 1080,1086 ----
  	NodeTag		type;
  	char	   *name;			/* its name */
  	List	   *indirection;	/* array references */
! 	bool		isRel;			/* is this a relation or a column? */
  } Ident;
  
  /*
Mon, 21 May 2001 14:36:01 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: AW: [HACKERS] Fix for tablename in targetlist