recursive function needs static variable

From: Nabil Sayegh <postgresql(at)e-trolley(dot)de>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: recursive function needs static variable
Date: 2003-06-25 01:55:08
Message-ID: 1056506107.3449.61.camel@billy
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all,

I just changed connectby() to order siblings and return an additional
serial column.

Everything is working fine so far, but I think there could be a problem
due to the static definition of the serial variable.

I need the variable to be static, because the function itself is
recursive.

What will happen if 2 processes concurrently use the function ? will
they conflict ?

I guess, that if I set the variable to 1 at each beginning of the
function, it will conflict.

If I do _not_ reset the serial at each function call, that would lead to
an overflow sooner or later.

Any idea ?

--
e-Trolley Sayegh & John, Nabil Sayegh
Tel.: 0700 etrolley /// 0700 38765539
Fax.: +49 69 8299381-8
PGP : http://www.e-trolley.de

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Joe Conway 2003-06-25 02:34:19 Re: recursive function needs static variable
Previous Message Nabil Sayegh 2003-06-25 00:56:41 connectby() minor bug in errormessage