Re: [PATCHES] Patch that deals with that AtCommit_Portals encounters

2005-03-16 Thread Thomas Hallgren
Tom Lane wrote:
Thomas Hallgren [EMAIL PROTECTED] writes:
 

I'm not sure what you mean. Earlier you rejected my bug-report on the 
iterator because you it was the callers responsability to deal with it 
(hence this patch). Are you now suggesting that we fix that bug instead?
   

Quite honestly, I dunno.  I agree that there's something lacking in this
stack of behaviors, but I don't think any of the solutions suggested so
far actually fix it ...
 

Ok, in that case, please allow this patch to go through. It will not 
cause any harm and until a better solution is architected, it does solve 
my immediate problem.

Regards,
Thomas Hallgren


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests to fail

2005-03-16 Thread Nicolai Tufar
On Wed, 16 Mar 2005 01:00:21 -0500 (EST), Bruce Momjian
pgman@candle.pha.pa.us wrote:
 
 I have applied a modified version of your patch, attached.

I am so sorry, I sent untested patch again.  Thank you very
much for patience in fixing it. The patch looks perfectly
fine and works under Solaris. 

Under win32 I am still struggling with build environment.
In many directories link fails with undefined reference to
`pg_snprintf' in other it fails with  undefined reference to
`_imp__libintl_sprintf'. In yet another directory it fails with
both, like in src/interfaces/ecpg/pgtypeslib:

dlltool --export-all  --output-def pgtypes.def numeric.o datetime.o
common.o dt_common.o timestamp.o interval.o pgstrcasecmp.o
dllwrap  -o libpgtypes.dll --dllname libpgtypes.dll  --def pgtypes.def
numeric.o datetime.o common.o dt_common.o timestamp.o interval.o
pgstrcasecmp.o  -L../../../../src/port -lm
numeric.o(.text+0x19ea):numeric.c: undefined reference to
`_imp__libintl_sprintf'
datetime.o(.text+0x476):datetime.c: undefined reference to `pg_snprintf'
common.o(.text+0x1cd):common.c: undefined reference to `pg_snprintf'
common.o(.text+0x251):common.c: undefined reference to `pg_snprintf'
dt_common.o(.text+0x538):dt_common.c: undefined reference to
`_imp__libintl_sprintf'
dt_common.o(.text+0x553):dt_common.c: undefined reference to
`_imp__libintl_sprintf'
dt_common.o(.text+0x597):dt_common.c: undefined reference to
`_imp__libintl_sprintf'
dt_common.o(.text+0x5d5):dt_common.c: undefined reference to
`_imp__libintl_sprintf'
dt_common.o(.text+0x628):dt_common.c: undefined reference to
`_imp__libintl_sprintf'
dt_common.o(.text+0x7e8):dt_common.c: more undefined references to
`_imp__libintl_sprintf' follow
c:\MinGW\bin\dllwrap.exe: c:\MinGW\bin\gcc exited with status 1
make: *** [libpgtypes.a] Error 1

Could someone with a better grasp of configure and 
win32 environment check it? Aparently no one regularily 
compiles source code under win32 during development cycle
these days.


Best regards,
Nicolai

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [PATCHES] COPY CSV header line feature

2005-03-16 Thread Andrew Dunstan

ammended patch attached. sorry for the oversight. I agree with Tom's
remark - it's far too easy to miss this.

cheers

andrew

Alvaro Herrera wrote:

On Tue, Mar 15, 2005 at 08:55:36PM -0600, Andrew Dunstan wrote:
  

Alvaro Herrera said:


On Sun, Mar 13, 2005 at 06:32:20PM -0500, Andrew Dunstan wrote:

  

The attached patch implements the previously discussed header line
feature for CSV mode COPY. It is triggered by the keyword HEADER
(blame Bruce - he chose it ;-) ).


I think you should add the new reserved keyword to the
unreserved_keywords list or some other.
  

Please be more specific. I'll be happy to add in anything I've missed.



The Postgres grammar classifies keywords in one of several lists, in
order to make them available as names to users (column names, function
names, etc).  So each time you create a new keyword and add it to the
keywords.c list, you have to add it to one of the lists on gram.y too.
See gram.y line 7669 ff.

I'd add a comment on this on gram.y:

Index: gram.y
===
RCS file: /home/alvherre/cvs/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.484
diff -c -w -b -B -c -r2.484 gram.y
*** gram.y 14 Mar 2005 00:19:36 -  2.484
--- gram.y 16 Mar 2005 03:12:48 -
***
*** 327,333 
  /*
   * If you make any token changes, update the keyword table in
   * parser/keywords.c and add new keywords to the appropriate one of
!  * the reserved-or-not-so-reserved keyword lists, below.
   */
  
  /* ordinary key words in alphabetical order */
--- 327,334 
  /*
   * If you make any token changes, update the keyword table in
   * parser/keywords.c and add new keywords to the appropriate one of
!  * the reserved-or-not-so-reserved keyword lists, below; search this
!  * file for Name classification hierarchy.
   */
  
  /* ordinary key words in alphabetical order */

  

Index: src/backend/commands/copy.c
===
RCS file: /home/cvsmirror/pgsql/src/backend/commands/copy.c,v
retrieving revision 1.237
diff -c -r1.237 copy.c
*** src/backend/commands/copy.c	12 Mar 2005 05:41:34 -	1.237
--- src/backend/commands/copy.c	16 Mar 2005 12:37:20 -
***
*** 131,143 
  /* non-export function prototypes */
  static void DoCopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
  		 char *delim, char *null_print, bool csv_mode, char *quote,
! 		 char *escape, List *force_quote_atts, bool fe_copy);
  static void CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
   char *delim, char *null_print, bool csv_mode, char *quote, char *escape,
! 	   List *force_quote_atts);
  static void CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
   char *delim, char *null_print, bool csv_mode, char *quote, char *escape,
! 		 List *force_notnull_atts);
  static bool CopyReadLine(char * quote, char * escape);
  static char *CopyReadAttribute(const char *delim, const char *null_print,
    CopyReadResult *result, bool *isnull);
--- 131,143 
  /* non-export function prototypes */
  static void DoCopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
  		 char *delim, char *null_print, bool csv_mode, char *quote,
! 		 char *escape, List *force_quote_atts, bool header_line, bool fe_copy);
  static void CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
   char *delim, char *null_print, bool csv_mode, char *quote, char *escape,
! 	   List *force_quote_atts, bool header_line);
  static void CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
   char *delim, char *null_print, bool csv_mode, char *quote, char *escape,
! 		 List *force_notnull_atts, bool header_line);
  static bool CopyReadLine(char * quote, char * escape);
  static char *CopyReadAttribute(const char *delim, const char *null_print,
    CopyReadResult *result, bool *isnull);
***
*** 695,700 
--- 695,701 
  	bool		binary = false;
  	bool		oids = false;
  	bool		csv_mode = false;
+ 	boolheader_line = false;
  	char	   *delim = NULL;
  	char	   *quote = NULL;
  	char	   *escape = NULL;
***
*** 752,757 
--- 753,766 
  		 errmsg(conflicting or redundant options)));
  			csv_mode = intVal(defel-arg);
  		}
+ 		else if (strcmp(defel-defname, header) == 0)
+ 		{
+ 			if (header_line)
+ ereport(ERROR,
+ 		(errcode(ERRCODE_SYNTAX_ERROR),
+ 		 errmsg(conflicting or redundant options)));
+ 			header_line = intVal(defel-arg);
+ 		}
  		else if (strcmp(defel-defname, quote) == 0)
  		{
  			if (quote)
***
*** 828,833 
--- 837,850 
   errmsg(COPY delimiter must be a single character)));
  
  	/*
+ 	 * Check header
+ 	 */
+ 	if (!csv_mode  header_line)
+ 		ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+  errmsg(COPY HEADER available only in CSV mode)));
+ 
+ 	/*
  	 * Check quote
  	 */
  	if 

Re: [PATCHES] [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests

2005-03-16 Thread Bruce Momjian
Nicolai Tufar wrote:
 On Wed, 16 Mar 2005 01:00:21 -0500 (EST), Bruce Momjian
 pgman@candle.pha.pa.us wrote:
  
  I have applied a modified version of your patch, attached.
 

Here is a patch that fixes the %*$ case.

FYI, I am going to pgindent snprintf.c to make it consistent so please
us CVS for your next patch.

I will work on your Win32 compile problem next.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: src/port/snprintf.c
===
RCS file: /cvsroot/pgsql/src/port/snprintf.c,v
retrieving revision 1.20
diff -c -c -r1.20 snprintf.c
*** src/port/snprintf.c 16 Mar 2005 06:00:58 -  1.20
--- src/port/snprintf.c 16 Mar 2005 14:59:00 -
***
*** 467,481 
fmtparptr[i]-charvalue = va_arg(args, int);
break;
case FMTLEN:
!   if (i + 1  fmtpos  fmtpar[i + 1].func != FMTWIDTH)
!   fmtpar[i + 1].len = va_arg(args, int);
/* For %*.*f, use the second arg */
!   if (i + 2  fmtpos  fmtpar[i + 1].func == FMTWIDTH)
!   fmtpar[i + 2].len = va_arg(args, int);
break;
case FMTWIDTH:
if (i + 1  fmtpos)
!   fmtpar[i + 1].maxwidth = fmtpar[i + 
1].precision =

va_arg(args, int);
break;
}
--- 467,481 
fmtparptr[i]-charvalue = va_arg(args, int);
break;
case FMTLEN:
!   if (i + 1  fmtpos  fmtparptr[i + 1]-func != 
FMTWIDTH)
!   fmtparptr[i + 1]-len = va_arg(args, int);
/* For %*.*f, use the second arg */
!   if (i + 2  fmtpos  fmtparptr[i + 1]-func == 
FMTWIDTH)
!   fmtparptr[i + 2]-len = va_arg(args, int);
break;
case FMTWIDTH:
if (i + 1  fmtpos)
!   fmtparptr[i + 1]-maxwidth = fmtparptr[i + 
1]-precision =

va_arg(args, int);
break;
}

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] [INTERFACES] libecpg (8.0 and CVS) hits a gcc bug on powerpc

2005-03-16 Thread Christof Petig
Christof Petig schrieb:
So I propose the following hack (feel free to improve it!) to go into
mainline. Since only powerpc and amd64 are affected (and the old method
does not work at all here at all) the patch should not be controversial.
I failed to mention that call by reference is the default for va_list on
these platforms (that's actually the cause of the bug).
   Christof


signature.asc
Description: OpenPGP digital signature


Re: [PATCHES] [pgsql-hackers-win32] [HACKERS] snprintf causes regression

2005-03-16 Thread Bruce Momjian
Nicolai Tufar wrote:
 On Wed, 16 Mar 2005 01:00:21 -0500 (EST), Bruce Momjian
 pgman@candle.pha.pa.us wrote:
  
  I have applied a modified version of your patch, attached.
 
 I am so sorry, I sent untested patch again.  Thank you very
 much for patience in fixing it. The patch looks perfectly
 fine and works under Solaris. 
 

Here is another patch that adds sprintf() support, and support for '+',
'h', and fixes '%*s' support.

Applied.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: src/bin/psql/command.c
===
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.141
diff -c -c -r1.141 command.c
*** src/bin/psql/command.c  11 Mar 2005 17:20:34 -  1.141
--- src/bin/psql/command.c  16 Mar 2005 21:17:50 -
***
*** 1574,1584 
shellName = DEFAULT_SHELL;
  
sys = pg_malloc(strlen(shellName) + 16);
sprintf(sys,
/* See EDITOR handling comment for an explaination */
- #ifndef WIN32
exec %s, shellName);
  #else
%s\%s\%s, SYSTEMQUOTE, shellName, 
SYSTEMQUOTE);
  #endif
result = system(sys);
--- 1574,1586 
shellName = DEFAULT_SHELL;
  
sys = pg_malloc(strlen(shellName) + 16);
+ #ifndef WIN32
sprintf(sys,
/* See EDITOR handling comment for an explaination */
exec %s, shellName);
  #else
+   sprintf(sys,
+   /* See EDITOR handling comment for an explaination */
%s\%s\%s, SYSTEMQUOTE, shellName, 
SYSTEMQUOTE);
  #endif
result = system(sys);
Index: src/include/port.h
===
RCS file: /cvsroot/pgsql/src/include/port.h,v
retrieving revision 1.72
diff -c -c -r1.72 port.h
*** src/include/port.h  11 Mar 2005 19:13:42 -  1.72
--- src/include/port.h  16 Mar 2005 21:17:50 -
***
*** 112,117 
--- 112,120 
  extern int pg_snprintf(char *str, size_t count, const char *fmt,...)
  /* This extension allows gcc to check the format string */
  __attribute__((format(printf, 3, 4)));
+ extern int pg_sprintf(char *str, const char *fmt,...)
+ /* This extension allows gcc to check the format string */
+ __attribute__((format(printf, 2, 3)));
  extern int pg_fprintf(FILE *stream, const char *fmt,...)
  /* This extension allows gcc to check the format string */
  __attribute__((format(printf, 2, 3)));
***
*** 127,137 
--- 130,142 
  #ifdef __GNUC__
  #define   vsnprintf(...)  pg_vsnprintf(__VA_ARGS__)
  #define snprintf(...) pg_snprintf(__VA_ARGS__)
+ #define sprintf(...)  pg_sprintf(__VA_ARGS__)
  #define fprintf(...)  pg_fprintf(__VA_ARGS__)
  #define printf(...)   pg_printf(__VA_ARGS__)
  #else
  #define vsnprintf pg_vsnprintf
  #define snprintf  pg_snprintf
+ #define sprintf   pg_sprintf
  #define fprintf   pg_fprintf
  #define printfpg_printf
  #endif
Index: src/port/snprintf.c
===
RCS file: /cvsroot/pgsql/src/port/snprintf.c,v
retrieving revision 1.22
diff -c -c -r1.22 snprintf.c
*** src/port/snprintf.c 16 Mar 2005 15:12:18 -  1.22
--- src/port/snprintf.c 16 Mar 2005 21:17:51 -
***
*** 67,80 
  
  /*static char _id[] = $PostgreSQL: pgsql/src/port/snprintf.c,v 1.22 
2005/03/16 15:12:18 momjian Exp $;*/
  
- int   pg_snprintf(char *str, size_t count, const char 
*fmt,...);
- int   pg_vsnprintf(char *str, size_t count, const char *fmt, 
va_list args);
- int   pg_printf(const char *format,...);
  static void dopr(char *buffer, const char *format, va_list args, char *end);
  
  /* Prevent recursion */
  #undefvsnprintf
  #undefsnprintf
  #undeffprintf
  #undefprintf
  
--- 67,78 
  
  /*static char _id[] = $PostgreSQL: pgsql/src/port/snprintf.c,v 1.22 
2005/03/16 15:12:18 momjian Exp $;*/
  
  static void dopr(char *buffer, const char *format, va_list args, char *end);
  
  /* Prevent recursion */
  #undefvsnprintf
  #undefsnprintf
+ #undefsprintf
  #undeffprintf
  #undefprintf
  
***
*** 104,121 
  }
  
  int
  pg_fprintf(FILE *stream, const char *fmt,...)
  {
int len;
va_list args;
!   char   *buffer[4096];
char   *p;
  
va_start(args, fmt);
!   len = pg_vsnprintf((char 

Re: [PATCHES] Sort psql output

2005-03-16 Thread Neil Conway
Christopher Kings-Lynne wrote:
This patch makes \d on tables and views sort fk constraints, triggers 
and rules alphabetically in the output.  This makes it the same as for 
indexes and stops the irritating random or reverse ordering it currently 
has.
Thanks, applied.
-Neil
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [PATCHES] Improvement to charset docs

2005-03-16 Thread Neil Conway
Christopher Kings-Lynne wrote:
This just adds a link to the pattern_ops operator class section from the 
part of the locale docs that mentions that indexes don't work for LIKE 
under a non-C locale.
Patch applied, with some changes. We can't assume that the reader can 
follow hyperlinks, since they won't be available in every format (e.g. 
printouts of a PDF). So the text should be written with an explicit 
section reference as well as a link.

-Neil
---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] [HACKERS] contrib/pg_buffercache

2005-03-16 Thread Mark Kirkwood
Andrew Dunstan wrote:
It fixes the build error on Windows - haven't tried because i don't have
time, but I know it won't work on Cygwin, because WIN32 isn't (usually)
defined on Cygwin - see previous almost endless discussions.
Yes - I recall that discussion a while ago.
This patch should sort the issue.
One question, should I be using defined(__MINGW32__) as opposed to
defined(WIN32)? I figured I didn't as in this case it is not necessary
to distinguish between native and cygwin.
regards
Mark


*** pg_buffercache_pages.h.orig Thu Mar 17 10:12:20 2005
--- pg_buffercache_pages.h  Thu Mar 17 13:44:45 2005
***
*** 15,18 
--- 15,24 
  
  extern Datum pg_buffercache_pages(PG_FUNCTION_ARGS);
  
+ /* A little hackery for Windows and Cygwin */
+ #if defined (WIN32) || defined (__CYGWIN__)
+ extern DLLIMPORT BufferDesc   *BufferDescriptors;
+ extern DLLIMPORT volatile uint32  InterruptHoldoffCount;
+ #endif
+ 
  #endif  /* PG_BUFFERCACHE_PAGES_H */


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] [HACKERS] contrib/pg_buffercache

2005-03-16 Thread Andrew Dunstan


Mark Kirkwood wrote:

 Andrew Dunstan wrote:

 It fixes the build error on Windows - haven't tried because i don't have
 time, but I know it won't work on Cygwin, because WIN32 isn't (usually)
 defined on Cygwin - see previous almost endless discussions.


 Yes - I recall that discussion a while ago.

 This patch should sort the issue.

 One question, should I be using defined(__MINGW32__) as opposed to
 defined(WIN32)? I figured I didn't as in this case it is not necessary
 to distinguish between native and cygwin.



You figured correctly.

cheers

andrew

---(end of broadcast)---
TIP 8: explain analyze is your friend


[PATCHES] refactor preprocess_targetlist

2005-03-16 Thread Neil Conway
This patch moves some code for preprocessing FOR UPDATE from 
grouping_planner() to preprocess_targetlist(), according to a comment in 
grouping_planner(). I think the refactoring makes sense, and moves some 
extraneous details out of grouping_planner().

Barring any objections, I'll apply this to HEAD tonight or tomorrow.
-Neil
Index: src/backend/optimizer/plan/planner.c
===
RCS file: /var/lib/cvs/pgsql/src/backend/optimizer/plan/planner.c,v
retrieving revision 1.179
diff -c -r1.179 planner.c
*** src/backend/optimizer/plan/planner.c	10 Mar 2005 23:21:22 -	1.179
--- src/backend/optimizer/plan/planner.c	17 Mar 2005 06:33:03 -
***
*** 36,42 
  #include optimizer/subselect.h
  #include optimizer/tlist.h
  #include optimizer/var.h
- #include parser/analyze.h
  #include parser/parsetree.h
  #include parser/parse_expr.h
  #include parser/parse_oper.h
--- 36,41 
***
*** 698,762 
  
  		MemSet(agg_counts, 0, sizeof(AggClauseCounts));
  
! 		/* Preprocess targetlist in case we are inside an INSERT/UPDATE. */
! 		tlist = preprocess_targetlist(tlist,
! 	  parse-commandType,
! 	  parse-resultRelation,
! 	  parse-rtable);
! 
! 		/*
! 		 * Add TID targets for rels selected FOR UPDATE (should this be
! 		 * done in preprocess_targetlist?).  The executor uses the TID to
! 		 * know which rows to lock, much as for UPDATE or DELETE.
! 		 */
! 		if (parse-rowMarks)
! 		{
! 			ListCell   *l;
! 
! 			/*
! 			 * We've got trouble if the FOR UPDATE appears inside
! 			 * grouping, since grouping renders a reference to individual
! 			 * tuple CTIDs invalid.  This is also checked at parse time,
! 			 * but that's insufficient because of rule substitution, query
! 			 * pullup, etc.
! 			 */
! 			CheckSelectForUpdate(parse);
! 
! 			/*
! 			 * Currently the executor only supports FOR UPDATE at top
! 			 * level
! 			 */
! 			if (PlannerQueryLevel  1)
! ereport(ERROR,
! 		(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
! 		 errmsg(SELECT FOR UPDATE is not allowed in subqueries)));
! 
! 			foreach(l, parse-rowMarks)
! 			{
! Index		rti = lfirst_int(l);
! char	   *resname;
! Resdom	   *resdom;
! Var		   *var;
! TargetEntry *ctid;
! 
! resname = (char *) palloc(32);
! snprintf(resname, 32, ctid%u, rti);
! resdom = makeResdom(list_length(tlist) + 1,
! 	TIDOID,
! 	-1,
! 	resname,
! 	true);
! 
! var = makeVar(rti,
! 			  SelfItemPointerAttributeNumber,
! 			  TIDOID,
! 			  -1,
! 			  0);
! 
! ctid = makeTargetEntry(resdom, (Expr *) var);
! tlist = lappend(tlist, ctid);
! 			}
! 		}
  
  		/*
  		 * Generate appropriate target list for subplan; may be different
--- 697,704 
  
  		MemSet(agg_counts, 0, sizeof(AggClauseCounts));
  
! 		/* Preprocess targetlist */
! 		tlist = preprocess_targetlist(parse, tlist);
  
  		/*
  		 * Generate appropriate target list for subplan; may be different
Index: src/backend/optimizer/prep/preptlist.c
===
RCS file: /var/lib/cvs/pgsql/src/backend/optimizer/prep/preptlist.c,v
retrieving revision 1.72
diff -c -r1.72 preptlist.c
*** src/backend/optimizer/prep/preptlist.c	31 Dec 2004 22:00:20 -	1.72
--- src/backend/optimizer/prep/preptlist.c	17 Mar 2005 06:34:37 -
***
*** 26,31 
--- 26,33 
  #include catalog/pg_type.h
  #include nodes/makefuncs.h
  #include optimizer/prep.h
+ #include optimizer/subselect.h
+ #include parser/analyze.h
  #include parser/parsetree.h
  #include parser/parse_coerce.h
  
***
*** 41,51 
   *	  Returns the new targetlist.
   */
  List *
! preprocess_targetlist(List *tlist,
! 	  int command_type,
! 	  Index result_relation,
! 	  List *range_table)
  {
  	/*
  	 * Sanity check: if there is a result relation, it'd better be a real
  	 * relation not a subquery.  Else parser or rewriter messed up.
--- 43,54 
   *	  Returns the new targetlist.
   */
  List *
! preprocess_targetlist(Query *parse, List *tlist)
  {
+ 	int		result_relation = parse-resultRelation;
+ 	List   *range_table = parse-rtable;
+ 	CmdType	command_type = parse-commandType;
+ 
  	/*
  	 * Sanity check: if there is a result relation, it'd better be a real
  	 * relation not a subquery.  Else parser or rewriter messed up.
***
*** 99,104 
--- 102,161 
  		tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) var));
  	}
  
+ 	/*
+ 	 * Add TID targets for rels selected FOR UPDATE.  The executor
+ 	 * uses the TID to know which rows to lock, much as for UPDATE or
+ 	 * DELETE.
+ 	 */
+ 	if (parse-rowMarks)
+ 	{
+ 		ListCell   *l;
+ 
+ 		/*
+ 		 * We've got trouble if the FOR UPDATE appears inside
+ 		 * grouping, since grouping renders a reference to individual
+ 		 * tuple CTIDs invalid.  This is also checked at parse time,
+ 		 * but that's