88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.126 2003/02/03 21:15:44 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.127 2003/02/04 00:50:00 tgl Exp $
1212 *
1313 * HISTORY
1414 * AUTHORDATEMAJOR EVENT
@@ -51,10 +51,9 @@ typedef struct
5151
5252static bool contain_agg_clause_walker (Node * node ,void * context );
5353static bool contain_distinct_agg_clause_walker (Node * node ,void * context );
54- static bool pull_agg_clause_walker (Node * node ,List * * listptr );
54+ static bool count_agg_clause_walker (Node * node ,int * count );
5555static bool expression_returns_set_walker (Node * node ,void * context );
5656static bool contain_subplans_walker (Node * node ,void * context );
57- static bool pull_subplans_walker (Node * node ,List * * listptr );
5857static bool contain_mutable_functions_walker (Node * node ,void * context );
5958static bool contain_volatile_functions_walker (Node * node ,void * context );
6059static bool contain_nonstrict_functions_walker (Node * node ,void * context );
@@ -373,31 +372,28 @@ contain_distinct_agg_clause_walker(Node *node, void *context)
373372}
374373
375374/*
376- * pull_agg_clause
377- * Recursively pulls all Aggref nodes from an expression tree.
378- *
379- * Returns list of Aggref nodes found. Note the nodes themselves are not
380- * copied, only referenced.
375+ * count_agg_clause
376+ * Recursively count the Aggref nodes in an expression tree.
381377 *
382378 * Note: this also checks for nested aggregates, which are an error.
383379 */
384- List *
385- pull_agg_clause (Node * clause )
380+ int
381+ count_agg_clause (Node * clause )
386382{
387- List * result = NIL ;
383+ int result = 0 ;
388384
389- pull_agg_clause_walker (clause ,& result );
385+ count_agg_clause_walker (clause ,& result );
390386return result ;
391387}
392388
393389static bool
394- pull_agg_clause_walker (Node * node ,List * * listptr )
390+ count_agg_clause_walker (Node * node ,int * count )
395391{
396392if (node == NULL )
397393return false;
398394if (IsA (node ,Aggref ))
399395{
400- * listptr = lappend ( * listptr , node ) ;
396+ ( * count ) ++ ;
401397
402398/*
403399 * Complain if the aggregate's argument contains any aggregates;
@@ -411,8 +407,8 @@ pull_agg_clause_walker(Node *node, List **listptr)
411407 */
412408return false;
413409}
414- return expression_tree_walker (node ,pull_agg_clause_walker ,
415- (void * )listptr );
410+ return expression_tree_walker (node ,count_agg_clause_walker ,
411+ (void * )count );
416412}
417413
418414
@@ -511,36 +507,6 @@ contain_subplans_walker(Node *node, void *context)
511507return expression_tree_walker (node ,contain_subplans_walker ,context );
512508}
513509
514- /*
515- * pull_subplans
516- * Recursively pulls all subplans from an expression tree.
517- *
518- * Returns list of SubPlan nodes found. Note the nodes themselves
519- * are not copied, only referenced.
520- */
521- List *
522- pull_subplans (Node * clause )
523- {
524- List * result = NIL ;
525-
526- pull_subplans_walker (clause ,& result );
527- return result ;
528- }
529-
530- static bool
531- pull_subplans_walker (Node * node ,List * * listptr )
532- {
533- if (node == NULL )
534- return false;
535- if (is_subplan (node ))
536- {
537- * listptr = lappend (* listptr ,node );
538- /* fall through to check args to subplan */
539- }
540- return expression_tree_walker (node ,pull_subplans_walker ,
541- (void * )listptr );
542- }
543-
544510
545511/*****************************************************************************
546512 *Check clauses for mutable functions