Обсуждение: [BUG] PostgreSQL 7.0.3 backend dumps core.

Поиск
Список
Период
Сортировка

[BUG] PostgreSQL 7.0.3 backend dumps core.

От
Alan Turner
Дата:
Hello

I believe have discovered a bug in PostgreSQL version 7.0.3. Here is a quick
bug report. I have tried to include any information which might be useful, but
if I have left anything out, please let me know, and I shall provide it. I
could possibly rebuild PostgreSQL with debugging symbols and do a backtrace on
the core file. If this would be helpful.

1. Bug description
------------------

When provided with certain input via psql, the postgres backend dumps core.
The exact input required to reproduce the bug is attached.

2. Version
-----------
The database was built from the postgresql 7.0.3 source RPM
(postgresql-7.0.3-2.src.rpm).

The psql utility reports thusly:

test=# select version();
                               version
---------------------------------------------------------------------
 PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66
(1 row)

test=#

3. System
----------
System is redhat linux 6.x (officially 6.0, but lots of stuff is upgraded).

freddy:~$ uname -a
Linux freddy.localdomain 2.2.17 #1 Sat Sep 23 20:24:24 EST 2000 i686 unknown
freddy:~$ rpm -qa | grep glibc
glibc-devel-2.1.3-19
glibc-2.1.3-19
freddy:~$
freddy:~$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
freddy:~$

4. Input
--------

freddy:~/phonec$ psql -U postgres -d template1
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=# create database test;
CREATE DATABASE
template1=# \q
freddy:~/phonec$ psql -U postgres -d test
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

test=# CREATE TABLE "magic" (
test(#         "one" int2,
test(#         "two" int2
test(# );
CREATE
test=# CREATE FUNCTION "plpgsql_call_handler" ( ) RETURNS opaque AS '/usr/lib/pgsql/plpgsql.so' LANGUAGE 'C';
CREATE
test=# CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER "plpgsql_call_handler" LANCOMPILER 'PL/pgSQL';
CREATE
test=# CREATE FUNCTION "f2" ( ) RETURNS magic AS '
test'#         DECLARE
test'#                 x RECORD;
test'#         BEGIN
test'#                 x.one := 1;
test'#                 x.two := 2;
test'#                 RETURN x;
test'#         END;
test'# ' LANGUAGE 'plpgsql';
CREATE
test=# select f2();
pqReadData() -- backend closed the channel unexpectedly.
        This probably means the backend terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!#

Thanks!

Cheers,
Alan

--
-----------------------------------------------------------------------------
Alan Turner | Voice: (02) 9481 8223 | Email: alan@suburbia.com.au
-----------------------------------------------------------------------------
Encrypted mail welcome. | Key: http://homepages.tig.com.au/~aturner/alan.gpg
1024D/9F513D15 1999-09-16 Alan Turner <alan@suburbia.com.au>
Key fingerprint = 2CC3 CDB9 7BE2 0585 EA63  19A1 C4EC EA32 9F51 3D15
-----------------------------------------------------------------------------
Whatever you do will be insignificant,
but it is very important that you do it. -- Gandhi
-----------------------------------------------------------------------------

Re: [BUG] PostgreSQL 7.0.3 backend dumps core.

От
Tom Lane
Дата:
Alan Turner <alan@suburbia.com.au> writes:
> test=# CREATE FUNCTION "f2" ( ) RETURNS magic AS '
> test'#         DECLARE
> test'#                 x RECORD;
> test'#         BEGIN
> test'#                 x.one := 1;
> test'#                 x.two := 2;
> test'#                 RETURN x;
> test'#         END;
> test'# ' LANGUAGE 'plpgsql';
> CREATE
> test=# select f2();
> pqReadData() -- backend closed the channel unexpectedly.

I think this coding should be rejected, but evidently it's not.  My
understanding of "record" in plpgsql is that it's just a placeholder
name for a tuple type determined elsewhere.  In this situation the
exact type of x is never determined, and so you shouldn't be able to
assign to fields of x.  Ooops.

In the meantime, it might work if you declare "x magic" instead of
"x record".

            regards, tom lane