strange infinite loop in plpgsql - Mailing list pgsql-general

From rihad
Subject strange infinite loop in plpgsql
Date
Msg-id 4735E512.4010504@mail.ru
Whole thread Raw
Responses Re: strange infinite loop in plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: strange infinite loop in plpgsql  ("Vyacheslav Kalinin" <vka@mgcp.com>)
List 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.

pgsql-general by date:

Previous
From: Christian Schröder
Date:
Subject: Re: (Never?) Kill Postmaster?
Next
From: Tom Lane
Date:
Subject: Re: strange infinite loop in plpgsql