aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeIndexscan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-05-17 21:22:12 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-05-17 21:22:12 -0400
commit424661913c06af76a46fdff9cc24cc57abf14fb3 (patch)
tree5d27c01f805aaf3cce92844344e51f37670573a4 /src/backend/executor/nodeIndexscan.c
parentb14cf229f4bd7238be2e31d873dc5dd241d3871e (diff)
downloadpostgresql-424661913c06af76a46fdff9cc24cc57abf14fb3.tar.gz
postgresql-424661913c06af76a46fdff9cc24cc57abf14fb3.zip
Fix failure to copy IndexScan.indexorderbyops in copyfuncs.c.
This oversight results in a crash at executor startup if the plan has been copied. outfuncs.c was missed as well. While we could probably have taught both those files to cope with the originally chosen representation of an Oid array, it would have been painful, not least because there'd be no easy way to verify the array length. An Oid List is far easier to work with. And AFAICS, there is no particular notational benefit to using an array rather than a list in the existing parts of the patch either. So just change it to a list. Error in commit 35fcb1b3d038a501f3f4c87c05630095abaaadab, which is new, so no need for back-patch.
Diffstat (limited to 'src/backend/executor/nodeIndexscan.c')
-rw-r--r--src/backend/executor/nodeIndexscan.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 434a1d95f01..60cb42b4540 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -793,7 +793,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
IndexScanState *indexstate;
Relation currentRelation;
bool relistarget;
- int i;
/*
* create state structure
@@ -917,35 +916,40 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
if (indexstate->iss_NumOrderByKeys > 0)
{
int numOrderByKeys = indexstate->iss_NumOrderByKeys;
+ int i;
+ ListCell *lc;
/*
* Prepare sort support, and look up the distance type for each ORDER
* BY expression.
*/
+ Assert(numOrderByKeys == list_length(node->indexorderbyops));
indexstate->iss_SortSupport =
palloc0(numOrderByKeys * sizeof(SortSupportData));
indexstate->iss_OrderByTypByVals =
palloc(numOrderByKeys * sizeof(bool));
indexstate->iss_OrderByTypLens =
palloc(numOrderByKeys * sizeof(int16));
- for (i = 0; i < indexstate->iss_NumOrderByKeys; i++)
+ i = 0;
+ foreach(lc, node->indexorderbyops)
{
+ Oid orderbyop = lfirst_oid(lc);
Oid orderbyType;
Oid opfamily;
int16 strategy;
- PrepareSortSupportFromOrderingOp(node->indexorderbyops[i],
+ PrepareSortSupportFromOrderingOp(orderbyop,
&indexstate->iss_SortSupport[i]);
- if (!get_ordering_op_properties(node->indexorderbyops[i],
+ if (!get_ordering_op_properties(orderbyop,
&opfamily, &orderbyType, &strategy))
- {
- elog(LOG, "operator %u is not a valid ordering operator",
- node->indexorderbyops[i]);
- }
+ elog(ERROR, "operator %u is not a valid ordering operator",
+ orderbyop);
+
get_typlenbyval(orderbyType,
&indexstate->iss_OrderByTypLens[i],
&indexstate->iss_OrderByTypByVals[i]);
+ i++;
}
/* allocate arrays to hold the re-calculated distances */