strange infinite loop in plpgsql

From: rihad <rihad(at)mail(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: strange infinite loop in plpgsql
Date: 2007-11-10 17:06:26
Message-ID: 4735E512.4010504@mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've been reading the online docs, but... code like this somehow ends up
in an indefinite loop:

CREATE OR REPLACE FUNCTION foo() RETURNS int AS $$
DECLARE
timeout int;
day date;
BEGIN
day := current_date + 1;
LOOP
SELECT date+1 INTO day FROM days WHERE date=day OR EXTRACT(dow
FROM day) IN (0,6);
EXIT WHEN NOT FOUND;
timeout := timeout + 86400;
END LOOP;
END; $$ LANGUAGE plpgsql;

It's Saturday at our place, and the "days" table has only one record for
tomorrow's date.

I hope it's been a very very long day for me :-) Thank you for your help.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vyacheslav Kalinin 2007-11-10 17:21:48 Re: strange infinite loop in plpgsql
Previous Message Christian Schröder 2007-11-10 09:33:50 Re: (Never?) Kill Postmaster?