mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-28 11:55:03 +03:00 
			
		
		
		
	Fix oversight in recent changes to enable the 'physical tlist'
optimization for subquery and function scan nodes: we can't just do it unconditionally, we still have to check whether there is any need for a whole-row Var. I had been thinking that these node types couldn't have any system columns, which is true, but that loop is also checking for attno zero, ie, whole-row Var. Fix comment to not be so misleading. Per test case from Richard Huxton.
This commit is contained in:
		| @@ -10,7 +10,7 @@ | |||||||
|  * |  * | ||||||
|  * |  * | ||||||
|  * IDENTIFICATION |  * IDENTIFICATION | ||||||
|  *	  $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.201 2005/10/15 02:49:20 momjian Exp $ |  *	  $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.202 2005/10/19 17:31:20 tgl Exp $ | ||||||
|  * |  * | ||||||
|  *------------------------------------------------------------------------- |  *------------------------------------------------------------------------- | ||||||
|  */ |  */ | ||||||
| @@ -308,17 +308,13 @@ use_physical_tlist(RelOptInfo *rel) | |||||||
| 	int			i; | 	int			i; | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * OK for subquery and function scans; otherwise, can't do it for anything | 	 * We can do this for real relation scans, subquery scans, and function | ||||||
| 	 * except real relations. | 	 * scans (but not for, eg, joins). | ||||||
| 	 */ | 	 */ | ||||||
| 	if (rel->rtekind != RTE_RELATION) | 	if (rel->rtekind != RTE_RELATION && | ||||||
| 	{ | 		rel->rtekind != RTE_SUBQUERY && | ||||||
| 		if (rel->rtekind == RTE_SUBQUERY) | 		rel->rtekind != RTE_FUNCTION) | ||||||
| 			return true; |  | ||||||
| 		if (rel->rtekind == RTE_FUNCTION) |  | ||||||
| 			return true; |  | ||||||
| 		return false; | 		return false; | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Can't do it with inheritance cases either (mainly because Append | 	 * Can't do it with inheritance cases either (mainly because Append | ||||||
| @@ -328,15 +324,16 @@ use_physical_tlist(RelOptInfo *rel) | |||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Can't do it if any system columns are requested, either.  (This could | 	 * Can't do it if any system columns or whole-row Vars are requested, | ||||||
| 	 * possibly be fixed but would take some fragile assumptions in setrefs.c, | 	 * either.  (This could possibly be fixed but would take some fragile | ||||||
| 	 * I think.) | 	 * assumptions in setrefs.c, I think.) | ||||||
| 	 */ | 	 */ | ||||||
| 	for (i = rel->min_attr; i <= 0; i++) | 	for (i = rel->min_attr; i <= 0; i++) | ||||||
| 	{ | 	{ | ||||||
| 		if (!bms_is_empty(rel->attr_needed[i - rel->min_attr])) | 		if (!bms_is_empty(rel->attr_needed[i - rel->min_attr])) | ||||||
| 			return false; | 			return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user