10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.143 2003/05/28 16:03:56 tgl Exp $
13
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.144 2003/05/28 23:06:16 tgl Exp $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
@@ -681,7 +681,7 @@ create_indexscan_plan(Query *root,
681
681
Expr * indxqual_or_expr = NULL ;
682
682
List * fixed_indxqual ;
683
683
List * recheck_indxqual ;
684
- List * indexids ;
684
+ FastList indexids ;
685
685
List * ixinfo ;
686
686
IndexScan * scan_plan ;
687
687
@@ -692,12 +692,12 @@ create_indexscan_plan(Query *root,
692
692
/*
693
693
* Build list of index OIDs.
694
694
*/
695
- indexids = NIL ;
695
+ FastListInit ( & indexids ) ;
696
696
foreach (ixinfo , best_path -> indexinfo )
697
697
{
698
698
IndexOptInfo * index = (IndexOptInfo * ) lfirst (ixinfo );
699
699
700
- indexids = lappendo ( indexids , index -> indexoid );
700
+ FastAppendo ( & indexids , index -> indexoid );
701
701
}
702
702
703
703
/*
@@ -719,15 +719,15 @@ create_indexscan_plan(Query *root,
719
719
* the implicit OR and AND semantics of the first- and
720
720
* second-level lists.
721
721
*/
722
- List * orclauses = NIL ;
722
+ FastList orclauses ;
723
723
List * orclause ;
724
724
725
+ FastListInit (& orclauses );
725
726
foreach (orclause , indxqual )
726
727
{
727
- orclauses = lappend (orclauses ,
728
- make_ands_explicit (lfirst (orclause )));
728
+ FastAppend (& orclauses , make_ands_explicit (lfirst (orclause )));
729
729
}
730
- indxqual_or_expr = make_orclause (orclauses );
730
+ indxqual_or_expr = make_orclause (FastListValue ( & orclauses ) );
731
731
732
732
qpqual = set_difference (scan_clauses , makeList1 (indxqual_or_expr ));
733
733
}
@@ -778,7 +778,7 @@ create_indexscan_plan(Query *root,
778
778
scan_plan = make_indexscan (tlist ,
779
779
qpqual ,
780
780
baserelid ,
781
- indexids ,
781
+ FastListValue ( & indexids ) ,
782
782
fixed_indxqual ,
783
783
indxqual ,
784
784
best_path -> indexscandir );
@@ -1091,13 +1091,15 @@ static void
1091
1091
fix_indxqual_references (List * indexquals , IndexPath * index_path ,
1092
1092
List * * fixed_indexquals , List * * recheck_indexquals )
1093
1093
{
1094
- List * fixed_quals = NIL ;
1095
- List * recheck_quals = NIL ;
1094
+ FastList fixed_quals ;
1095
+ FastList recheck_quals ;
1096
1096
Relids baserelids = index_path -> path .parent -> relids ;
1097
1097
int baserelid = index_path -> path .parent -> relid ;
1098
1098
List * ixinfo = index_path -> indexinfo ;
1099
1099
List * i ;
1100
1100
1101
+ FastListInit (& fixed_quals );
1102
+ FastListInit (& recheck_quals );
1101
1103
foreach (i , indexquals )
1102
1104
{
1103
1105
List * indexqual = lfirst (i );
@@ -1107,15 +1109,15 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path,
1107
1109
1108
1110
fix_indxqual_sublist (indexqual , baserelids , baserelid , index ,
1109
1111
& fixed_qual , & recheck_qual );
1110
- fixed_quals = lappend ( fixed_quals , fixed_qual );
1112
+ FastAppend ( & fixed_quals , fixed_qual );
1111
1113
if (recheck_qual != NIL )
1112
- recheck_quals = lappend ( recheck_quals , recheck_qual );
1114
+ FastAppend ( & recheck_quals , recheck_qual );
1113
1115
1114
1116
ixinfo = lnext (ixinfo );
1115
1117
}
1116
1118
1117
- * fixed_indexquals = fixed_quals ;
1118
- * recheck_indexquals = recheck_quals ;
1119
+ * fixed_indexquals = FastListValue ( & fixed_quals ) ;
1120
+ * recheck_indexquals = FastListValue ( & recheck_quals ) ;
1119
1121
}
1120
1122
1121
1123
/*
@@ -1136,10 +1138,12 @@ fix_indxqual_sublist(List *indexqual,
1136
1138
IndexOptInfo * index ,
1137
1139
List * * fixed_quals , List * * recheck_quals )
1138
1140
{
1139
- List * fixed_qual = NIL ;
1140
- List * recheck_qual = NIL ;
1141
+ FastList fixed_qual ;
1142
+ FastList recheck_qual ;
1141
1143
List * i ;
1142
1144
1145
+ FastListInit (& fixed_qual );
1146
+ FastListInit (& recheck_qual );
1143
1147
foreach (i , indexqual )
1144
1148
{
1145
1149
OpExpr * clause = (OpExpr * ) lfirst (i );
@@ -1178,19 +1182,18 @@ fix_indxqual_sublist(List *indexqual,
1178
1182
index ,
1179
1183
& opclass );
1180
1184
1181
- fixed_qual = lappend ( fixed_qual , newclause );
1185
+ FastAppend ( & fixed_qual , newclause );
1182
1186
1183
1187
/*
1184
1188
* Finally, check to see if index is lossy for this operator. If
1185
1189
* so, add (a copy of) original form of clause to recheck list.
1186
1190
*/
1187
1191
if (op_requires_recheck (newclause -> opno , opclass ))
1188
- recheck_qual = lappend (recheck_qual ,
1189
- copyObject ((Node * ) clause ));
1192
+ FastAppend (& recheck_qual , copyObject ((Node * ) clause ));
1190
1193
}
1191
1194
1192
- * fixed_quals = fixed_qual ;
1193
- * recheck_quals = recheck_qual ;
1195
+ * fixed_quals = FastListValue ( & fixed_qual ) ;
1196
+ * recheck_quals = FastListValue ( & recheck_qual ) ;
1194
1197
}
1195
1198
1196
1199
static Node *
@@ -1327,26 +1330,28 @@ get_switched_clauses(List *clauses, Relids outerrelids)
1327
1330
static List *
1328
1331
order_qual_clauses (Query * root , List * clauses )
1329
1332
{
1330
- List * nosubplans ;
1331
- List * withsubplans ;
1333
+ FastList nosubplans ;
1334
+ FastList withsubplans ;
1332
1335
List * l ;
1333
1336
1334
1337
/* No need to work hard if the query is subselect-free */
1335
1338
if (!root -> hasSubLinks )
1336
1339
return clauses ;
1337
1340
1338
- nosubplans = withsubplans = NIL ;
1341
+ FastListInit (& nosubplans );
1342
+ FastListInit (& withsubplans );
1339
1343
foreach (l , clauses )
1340
1344
{
1341
1345
Node * clause = lfirst (l );
1342
1346
1343
1347
if (contain_subplans (clause ))
1344
- withsubplans = lappend ( withsubplans , clause );
1348
+ FastAppend ( & withsubplans , clause );
1345
1349
else
1346
- nosubplans = lappend ( nosubplans , clause );
1350
+ FastAppend ( & nosubplans , clause );
1347
1351
}
1348
1352
1349
- return nconc (nosubplans , withsubplans );
1353
+ FastConcFast (& nosubplans , & withsubplans );
1354
+ return FastListValue (& nosubplans );
1350
1355
}
1351
1356
1352
1357
/*
0 commit comments