mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Don't try to rewrite NEW references in a utility statement in a rule.
There won't be any, and in fact there won't even be an RTE for NEW, which was leading to a core dump in CVS tip. 7.4 and earlier manage not to crash when applying ResolveNew in this scenario, but I think it was just good fortune that they didn't. Per report from Bernd Helmle.
This commit is contained in:
		@@ -7,7 +7,7 @@
 | 
				
			|||||||
 * Portions Copyright (c) 1994, Regents of the University of California
 | 
					 * Portions Copyright (c) 1994, Regents of the University of California
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.140 2004/06/16 01:26:46 tgl Exp $
 | 
					 *	  $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.141 2004/08/07 17:40:49 tgl Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *-------------------------------------------------------------------------
 | 
					 *-------------------------------------------------------------------------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -208,7 +208,8 @@ rewriteRuleAction(Query *parsetree,
 | 
				
			|||||||
	 * apply it to sub_action; we have to remember to update the sublink
 | 
						 * apply it to sub_action; we have to remember to update the sublink
 | 
				
			||||||
	 * inside rule_action, too.
 | 
						 * inside rule_action, too.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (event == CMD_INSERT || event == CMD_UPDATE)
 | 
						if ((event == CMD_INSERT || event == CMD_UPDATE) &&
 | 
				
			||||||
 | 
							sub_action->commandType != CMD_UTILITY)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sub_action = (Query *) ResolveNew((Node *) sub_action,
 | 
							sub_action = (Query *) ResolveNew((Node *) sub_action,
 | 
				
			||||||
										  new_varno,
 | 
															  new_varno,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user