Thread: reltime with NULL fields crashes backend

reltime with NULL fields crashes backend

From
pgsql-bugs@postgresql.org
Date:
Dmitry Tsitelov (cit@tag-ltd.spb.ru) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
reltime with NULL fields crashes backend

Long Description
I use expression like int4(reltime(<interval-field>)) to get interval length in seconds. When <interval-field> is NULL
backendcrashes (psql session): 

organizer=> SELECT reltime(task.duration_real) FROM pmgr_task task WHERE task.id = 5;
pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated abnormally before or while processing the request.

#######
OS: FreeBSD 4.1-RELEASE #2
PostgreSQL ver: PostgreSQL 7.0.2 on i386-unknown-freebsdelf4.1, compiled by gcc 2.95.2

####### Postmaster log:

Server process (pid 37685) exited with status 139 at Wed Apr 11 15:33:18 2001
Terminating any active server processes...
NOTICE:  Message from PostgreSQL backend:
        The Postmaster has informed me that some other backend died abnormally a
nd possibly corrupted shared memory.
        I have rolled back the current transaction and am going to terminate you
r database system connection and exit.
        Please reconnect to the database system and repeat your query.
NOTICE:  Message from PostgreSQL backend:
        The Postmaster has informed me that some other backend died abnormally a
nd possibly corrupted shared memory.
        I have rolled back the current transaction and am going to terminate you
r database system connection and exit.
        Please reconnect to the database system and repeat your query.
NOTICE:  Message from PostgreSQL backend:
        The Postmaster has informed me that some other backend died abnormally a
nd possibly corrupted shared memory.
        I have rolled back the current transaction and am going to terminate you
r database system connection and exit.
        Please reconnect to the database system and repeat your query.
Server processes were terminated at Wed Apr 11 15:33:18 2001
Reinitializing shared memory and semaphores
DEBUG:  Data Base System is starting up at Wed Apr 11 15:33:18 2001
The Data Base System is starting up
DEBUG:  Data Base System was interrupted being in production at Wed Apr 11 15:27
:41 2001
DEBUG:  Data Base System is in production state at Wed Apr 11 15:33:18 2001




Sample Code
CREATE TABLE t ( f interval );         : OK
INSERT INTO t (f) VALUES ('23 s');     : OK
SELECT reltime(f) FROM t;        : OK
SELECT int4(reltime(f)) FROM t;        : OK
DELETE FROM t;                    : OK
INSERT INTO t (f) VALUES (NULL);        : OK
SELECT reltime(f) FROM t;        : Backend crash

SELECT reltime(NULL);                   : OK
SELECT reltime(interval(NULL));         : Backend crash


No file was uploaded with this report

Re: reltime with NULL fields crashes backend

From
Thomas Lockhart
Date:
> Long Description
> I use expression like int4(reltime(<interval-field>)) to get interval length in seconds. When <interval-field> is
NULLbackend crashes (psql session): 

This is likely fixed in the upcoming 7.1, since NULL handling has been
greatly improved for "by value" types like reltime. However, you *could*
be doing this as

  select date_part('epoch', <interval-field>) ...

hth

                           - Thomas