pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John DeSoi <jd@icx.net>
To: PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: sleep function
Date: Wed, 11 Aug 2004 15:47:28 -0400
Message-ID: <46D44C5D-EBCF-11D8-A1CD-000A95B03262@icx.net> (raw)
In-Reply-To: <200408101457.i7AEvvc15187@candle.pha.pa.us>
References: <200408101457.i7AEvvc15187@candle.pha.pa.us>


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;




view thread (6+ messages)  latest in thread

Message-ID: <46D44C5D-EBCF-11D8-A1CD-000A95B03262@icx.net>
Permalink:  ../46D44C5D-EBCF-11D8-A1CD-000A95B03262@icx.net/
Also on:    postgresql.org/message-id/46D44C5D-EBCF-11D8-A1CD-000A95B03262@icx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jd@icx.net
  Subject: Re: sleep function
  In-Reply-To: <46D44C5D-EBCF-11D8-A1CD-000A95B03262@icx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox