Show
Ignore:
Timestamp:
06/08/09 21:47:59 (3 years ago)
Author:
fumanchu
Message:

Fixed to work on PG 8.1.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/epic/test/test_timing.sql

    r25 r34  
    11-- Tests for the timing functions which Epic provides. 
    22-- To run, execute epic.sql, then this script, then test.run_module('test_timing'). 
     3 
     4CREATE OR REPLACE FUNCTION test._sleep(s double precision) RETURNS VOID AS $$ 
     5-- sleep function for Postgres 8.1 
     6DECLARE 
     7  start    timestamp with time zone; 
     8BEGIN 
     9  start := timeofday()::timestamp; 
     10  LOOP 
     11    EXIT WHEN (timeofday()::timestamp - start) > (s || ' second')::interval; 
     12  END LOOP; 
     13END; 
     14$$ LANGUAGE plpgsql; 
    315 
    416CREATE OR REPLACE FUNCTION test.test_timing() RETURNS VOID AS $$ 
     
    820BEGIN 
    921  -- Shame we have to use 0.01 but some platforms don't have finer resolution. 
    10   t := test.timing('SELECT pg_sleep(0.01)', 100); 
     22  t := test.timing('SELECT test._sleep(0.01)', 100); 
    1123   
    1224  -- Let's assume that sleep(0.01) * 100 should never run *under* 1s