Re: sleep function

From: John DeSoi <jd(at)icx(dot)net>
To: PostgreSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: sleep function
Date: 2004-08-11 19:47:28
Message-ID: 46D44C5D-EBCF-11D8-A1CD-000A95B03262@icx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Aug 10, 2004, at 10:57 AM, Bruce Momjian wrote:

> I can't think of one, no. I think you will have to use one of the
> server-side languages and call a sleep in there.

This is no good in the real world since it pounds the CPU, but it
worked well enough for my testing purposes.

Best,

John DeSoi, Ph.D.

create or replace function sleep (integer) returns time as '
declare
seconds alias for $1;
later time;
thetime time;
begin
thetime := timeofday()::timestamp;
later := thetime + (seconds::text || '' seconds'')::interval;
loop
if thetime >= later then
exit;
else
thetime := timeofday()::timestamp;
end if;
end loop;

return later;
end;
' language plpgsql;

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gaetano Mendola 2004-08-11 20:15:51 Re: Displaying two tables side by side
Previous Message Bruno Wolff III 2004-08-11 19:13:21 Re: reply to setting