9
9
*
10
10
*
11
11
* IDENTIFICATION
12
- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.160 2004/05/30 23:40:28 neilc Exp $
12
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.161 2004/06/01 04:47:45 tgl Exp $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
@@ -237,22 +237,20 @@ create_index_paths(Query *root, RelOptInfo *rel)
237
237
static List *
238
238
group_clauses_by_indexkey (RelOptInfo * rel , IndexOptInfo * index )
239
239
{
240
- FastList clausegroup_list ;
240
+ List * clausegroup_list = NIL ;
241
241
List * restrictinfo_list = rel -> baserestrictinfo ;
242
242
int indexcol = 0 ;
243
243
Oid * classes = index -> classlist ;
244
244
245
245
if (restrictinfo_list == NIL )
246
246
return NIL ;
247
247
248
- FastListInit (& clausegroup_list );
249
248
do
250
249
{
251
250
Oid curClass = classes [0 ];
252
- FastList clausegroup ;
251
+ List * clausegroup = NIL ;
253
252
ListCell * l ;
254
253
255
- FastListInit (& clausegroup );
256
254
foreach (l , restrictinfo_list )
257
255
{
258
256
RestrictInfo * rinfo = (RestrictInfo * ) lfirst (l );
@@ -262,24 +260,24 @@ group_clauses_by_indexkey(RelOptInfo *rel, IndexOptInfo *index)
262
260
indexcol ,
263
261
curClass ,
264
262
rinfo ))
265
- FastAppend ( & clausegroup , rinfo );
263
+ clausegroup = lappend ( clausegroup , rinfo );
266
264
}
267
265
268
266
/*
269
267
* If no clauses match this key, we're done; we don't want to look
270
268
* at keys to its right.
271
269
*/
272
- if (FastListValue ( & clausegroup ) == NIL )
270
+ if (clausegroup == NIL )
273
271
break ;
274
272
275
- FastAppend ( & clausegroup_list , FastListValue ( & clausegroup ) );
273
+ clausegroup_list = lappend ( clausegroup_list , clausegroup );
276
274
277
275
indexcol ++ ;
278
276
classes ++ ;
279
277
280
278
} while (!DoneMatchingIndexKeys (classes ));
281
279
282
- return FastListValue ( & clausegroup_list ) ;
280
+ return clausegroup_list ;
283
281
}
284
282
285
283
/*
@@ -301,21 +299,18 @@ group_clauses_by_indexkey_for_join(Query *root,
301
299
Relids outer_relids ,
302
300
JoinType jointype , bool isouterjoin )
303
301
{
304
- FastList clausegroup_list ;
302
+ List * clausegroup_list = NIL ;
305
303
bool jfound = false;
306
304
int indexcol = 0 ;
307
305
Oid * classes = index -> classlist ;
308
306
309
- FastListInit (& clausegroup_list );
310
307
do
311
308
{
312
309
Oid curClass = classes [0 ];
313
- FastList clausegroup ;
310
+ List * clausegroup = NIL ;
314
311
int numsources ;
315
312
ListCell * l ;
316
313
317
- FastListInit (& clausegroup );
318
-
319
314
/*
320
315
* We can always use plain restriction clauses for the rel. We scan
321
316
* these first because we want them first in the clausegroup list
@@ -337,11 +332,11 @@ group_clauses_by_indexkey_for_join(Query *root,
337
332
indexcol ,
338
333
curClass ,
339
334
rinfo ))
340
- FastAppend ( & clausegroup , rinfo );
335
+ clausegroup = lappend ( clausegroup , rinfo );
341
336
}
342
337
343
338
/* found anything in base restrict list? */
344
- numsources = (FastListValue ( & clausegroup ) != NIL ) ? 1 : 0 ;
339
+ numsources = (clausegroup != NIL ) ? 1 : 0 ;
345
340
346
341
/* Look for joinclauses that are usable with given outer_relids */
347
342
foreach (l , rel -> joininfo )
@@ -367,7 +362,7 @@ group_clauses_by_indexkey_for_join(Query *root,
367
362
curClass ,
368
363
rinfo ))
369
364
{
370
- FastAppend ( & clausegroup , rinfo );
365
+ clausegroup = lappend ( clausegroup , rinfo );
371
366
if (!jfoundhere )
372
367
{
373
368
jfoundhere = true;
@@ -384,22 +379,19 @@ group_clauses_by_indexkey_for_join(Query *root,
384
379
*/
385
380
if (numsources > 1 )
386
381
{
387
- List * nl ;
388
-
389
- nl = remove_redundant_join_clauses (root ,
390
- FastListValue (& clausegroup ),
391
- jointype );
392
- FastListFromList (& clausegroup , nl );
382
+ clausegroup = remove_redundant_join_clauses (root ,
383
+ clausegroup ,
384
+ jointype );
393
385
}
394
386
395
387
/*
396
388
* If no clauses match this key, we're done; we don't want to look
397
389
* at keys to its right.
398
390
*/
399
- if (FastListValue ( & clausegroup ) == NIL )
391
+ if (clausegroup == NIL )
400
392
break ;
401
393
402
- FastAppend ( & clausegroup_list , FastListValue ( & clausegroup ) );
394
+ clausegroup_list = lappend ( clausegroup_list , clausegroup );
403
395
404
396
indexcol ++ ;
405
397
classes ++ ;
@@ -410,7 +402,7 @@ group_clauses_by_indexkey_for_join(Query *root,
410
402
if (!jfound )
411
403
return NIL ;
412
404
413
- return FastListValue ( & clausegroup_list ) ;
405
+ return clausegroup_list ;
414
406
}
415
407
416
408
@@ -438,28 +430,25 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
438
430
IndexOptInfo * index ,
439
431
Expr * orsubclause )
440
432
{
441
- FastList clausegroup_list ;
433
+ List * clausegroup_list = NIL ;
442
434
bool matched = false;
443
435
int indexcol = 0 ;
444
436
Oid * classes = index -> classlist ;
445
437
446
- FastListInit (& clausegroup_list );
447
438
do
448
439
{
449
440
Oid curClass = classes [0 ];
450
- FastList clausegroup ;
441
+ List * clausegroup = NIL ;
451
442
ListCell * item ;
452
443
453
- FastListInit (& clausegroup );
454
-
455
444
/* Try to match the OR subclause to the index key */
456
445
if (IsA (orsubclause , RestrictInfo ))
457
446
{
458
447
if (match_clause_to_indexcol (rel , index ,
459
448
indexcol , curClass ,
460
449
(RestrictInfo * ) orsubclause ))
461
450
{
462
- FastAppend ( & clausegroup , orsubclause );
451
+ clausegroup = lappend ( clausegroup , orsubclause );
463
452
matched = true;
464
453
}
465
454
}
@@ -474,7 +463,7 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
474
463
indexcol , curClass ,
475
464
subsubclause ))
476
465
{
477
- FastAppend ( & clausegroup , subsubclause );
466
+ clausegroup = lappend ( clausegroup , subsubclause );
478
467
matched = true;
479
468
}
480
469
}
@@ -487,7 +476,7 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
487
476
* XXX should we always search the top-level list? Slower but
488
477
* could sometimes yield a better plan.
489
478
*/
490
- if (FastListValue ( & clausegroup ) == NIL )
479
+ if (clausegroup == NIL )
491
480
{
492
481
foreach (item , rel -> baserestrictinfo )
493
482
{
@@ -496,18 +485,18 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
496
485
if (match_clause_to_indexcol (rel , index ,
497
486
indexcol , curClass ,
498
487
rinfo ))
499
- FastAppend ( & clausegroup , rinfo );
488
+ clausegroup = lappend ( clausegroup , rinfo );
500
489
}
501
490
}
502
491
503
492
/*
504
493
* If still no clauses match this key, we're done; we don't want
505
494
* to look at keys to its right.
506
495
*/
507
- if (FastListValue ( & clausegroup ) == NIL )
496
+ if (clausegroup == NIL )
508
497
break ;
509
498
510
- FastAppend ( & clausegroup_list , FastListValue ( & clausegroup ) );
499
+ clausegroup_list = lappend ( clausegroup_list , clausegroup );
511
500
512
501
indexcol ++ ;
513
502
classes ++ ;
@@ -517,7 +506,7 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
517
506
if (!matched )
518
507
return NIL ;
519
508
520
- return FastListValue ( & clausegroup_list ) ;
509
+ return clausegroup_list ;
521
510
}
522
511
523
512
@@ -2011,14 +2000,13 @@ match_special_index_operator(Expr *clause, Oid opclass,
2011
2000
List *
2012
2001
expand_indexqual_conditions (IndexOptInfo * index , List * clausegroups )
2013
2002
{
2014
- FastList resultquals ;
2003
+ List * resultquals = NIL ;
2015
2004
ListCell * clausegroup_item ;
2016
2005
Oid * classes = index -> classlist ;
2017
2006
2018
2007
if (clausegroups == NIL )
2019
2008
return NIL ;
2020
2009
2021
- FastListInit (& resultquals );
2022
2010
clausegroup_item = list_head (clausegroups );
2023
2011
do
2024
2012
{
@@ -2029,17 +2017,18 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
2029
2017
{
2030
2018
RestrictInfo * rinfo = (RestrictInfo * ) lfirst (l );
2031
2019
2032
- FastConc (& resultquals ,
2033
- expand_indexqual_condition (rinfo , curClass ));
2020
+ resultquals = list_concat (resultquals ,
2021
+ expand_indexqual_condition (rinfo ,
2022
+ curClass ));
2034
2023
}
2035
2024
2036
2025
clausegroup_item = lnext (clausegroup_item );
2037
2026
classes ++ ;
2038
2027
} while (clausegroup_item != NULL && !DoneMatchingIndexKeys (classes ));
2039
2028
2040
- Assert (clausegroup_item == NULL ); /* else more groups than indexkeys... */
2029
+ Assert (clausegroup_item == NULL ); /* else more groups than indexkeys */
2041
2030
2042
- return FastListValue ( & resultquals ) ;
2031
+ return resultquals ;
2043
2032
}
2044
2033
2045
2034
/*
0 commit comments