summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-05-31 16:57:34 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-05-31 16:57:34 +0000
commit10f719af331b0248f532fb1eeee642f93ed981a9 (patch)
treecde09eb1585a3a2e7861517b68a0ac0859d99a09 /src/backend/optimizer/util
parent7ce9b3683ea76233c33e550110c5a63ecd8add89 (diff)
Change build_index_pathkeys() so that the expressions it builds to represent
index key columns always have the type expected by the index's associated operators, ie, we add RelabelType nodes when dealing with binary-compatible index opclasses. This is needed to get varchar indexes to play nicely with the new EquivalenceClass machinery, as per recent gripe from Josh Berkus that CVS HEAD was failing to match a varchar index column to a constant restriction in the query. It seems likely that this change will allow removal of a lot of ugly ad-hoc RelabelType-stripping that the planner has traditionally done while matching expressions to other expressions, but I'll worry about that some other day.
Diffstat (limited to 'src/backend/optimizer/util')
-rw-r--r--src/backend/optimizer/util/plancat.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 605e7f64eed..70b3d7d43f5 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.135 2007/05/25 17:54:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.136 2007/05/31 16:57:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -171,20 +171,23 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
info->ncolumns = ncolumns = index->indnatts;
/*
- * Need to make opfamily array large enough to put a terminating
- * zero at the end.
+ * Allocate per-column info arrays. To save a few palloc cycles
+ * we allocate all the Oid-type arrays in one request. Note that
+ * the opfamily array needs an extra, terminating zero at the end.
+ * We pre-zero the ordering info in case the index is unordered.
*/
info->indexkeys = (int *) palloc(sizeof(int) * ncolumns);
- info->opfamily = (Oid *) palloc0(sizeof(Oid) * (ncolumns + 1));
- /* initialize these to zeroes in case index is unordered */
- info->fwdsortop = (Oid *) palloc0(sizeof(Oid) * ncolumns);
- info->revsortop = (Oid *) palloc0(sizeof(Oid) * ncolumns);
+ info->opfamily = (Oid *) palloc0(sizeof(Oid) * (4 * ncolumns + 1));
+ info->opcintype = info->opfamily + (ncolumns + 1);
+ info->fwdsortop = info->opcintype + ncolumns;
+ info->revsortop = info->fwdsortop + ncolumns;
info->nulls_first = (bool *) palloc0(sizeof(bool) * ncolumns);
for (i = 0; i < ncolumns; i++)
{
- info->opfamily[i] = indexRelation->rd_opfamily[i];
info->indexkeys[i] = index->indkey.values[i];
+ info->opfamily[i] = indexRelation->rd_opfamily[i];
+ info->opcintype[i] = indexRelation->rd_opcintype[i];
}
info->relam = indexRelation->rd_rel->relam;