class name in target list

Поиск
Список
Период
Сортировка
Искать

class name in target list

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Here it is.

-- 
  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/20 04:23:24
***************
*** 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/20 04:23:24
***************
*** 154,166 ****
  		}
  		else
  		{
! 			/* Everything else but Attr */
! 			p_target = lappend(p_target,
! 							   transformTargetEntry(pstate,
! 													res->val,
! 													NULL,
! 													res->name,
! 													false));
  		}
  
  		targetlist = lnext(targetlist);
--- 154,186 ----
  		}
  		else
  		{
! 			Node	   *rteorjoin;
! 			int			sublevels_up;
! 			Ident	   *ident = IsA(res->val, Ident) ?
! 									(Ident *) res->val : NULL;
! 
! 			if (ident &&
! 				ident->indirection == NULL &&
! 				(rteorjoin = refnameRangeOrJoinEntry(pstate,
! 												ident->name,
! 												&sublevels_up)) != NULL)
! 			{
! 				/* Expand SELECT tab FROM tab; to SELECT tab.* FROM tab; */
! 				ident->isRel = TRUE;
! 				p_target = nconc(p_target,
! 							expandRelAttrs(pstate,
! 							   (RangeTblEntry *) rteorjoin));
! 			}
! 			else
! 			{
! 				/* Everything else */
! 				p_target = lappend(p_target,
! 								   transformTargetEntry(pstate,
! 														res->val,
! 														NULL,
! 														res->name,
! 														false));
! 			}
  		}
  
  		targetlist = lnext(targetlist);
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/20 04:23:32
***************
*** 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;
  
  /*

Re: class name in target list

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
This still looks to me like it would reverse the behavior in the case
where the Ident name could be either a column or table name.  You should
do transformTargetEntry first, same as the code does now, and *then*
look to see if you still have an Ident with isRel true.

			regards, tom lane
FAQ