Re: recursive function needs static variable

From: Joe Conway <mail(at)joeconway(dot)com>
To: Nabil Sayegh <postgresql(at)e-trolley(dot)de>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: recursive function needs static variable
Date: 2003-06-25 04:35:19
Message-ID: 3EF92687.3040704@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Nabil Sayegh wrote:
> Am Mit, 2003-06-25 um 04.34 schrieb Joe Conway:
>
>>Nabil Sayegh wrote:
>
>>Each backend connection is a single threaded process, so there should be
>>no problem. But I don't think it needs to be static anyway (see below).
>
> Is this also true for several function calls in 1 query ?

Yes. Each call to connectby_text() will run to completion and return the
results as a tuplestore.

>>>I guess, that if I set the variable to 1 at each beginning of the
>>>function, it will conflict.
>
> So, this is okay ?

Should be fine.

>
>>Add the counter variable to build_tuplestore_recursively()'s arguments.
>>Initialize it in connectby(), and increment it every time
>>BuildTupleFromCStrings() is called.
>
> Already tried that, but due to the recursion the incrementation steps
> get undone each time the build_tuplestore_recursively returns :).
> => The serial is nomore UNIQUE

Not if you pass it by reference.

Joe

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Kaarel 2003-06-25 11:53:24 Re: Name limitation question
Previous Message wei wang 2003-06-25 03:15:37 set up windows client to connect via SSL