Обсуждение: BUG #2101: Postmaster Crash Using PL/PgSQL With %TYPE on Non-Exisiting Column
BUG #2101: Postmaster Crash Using PL/PgSQL With %TYPE on Non-Exisiting Column
От
"Will Szopko"
Дата:
The following bug has been logged online:
Bug reference: 2101
Logged by: Will Szopko
Email address: dba@vilaj.com
PostgreSQL version: 8.1.0
Operating system: Debain Linux (Sarge)/Mac OS X 10.3.9 (Panther)
Description: Postmaster Crash Using PL/PgSQL With %TYPE on
Non-Exisiting Column
Details:
The postmaster in 8.1.0 crashes when creating or replacing a PL/PgSQL
function containing an invalid variable declaration. The invalid declaration
triggering the bug combines a schema with a %TYPE applied to a non-existing
column. When a schema is not involved an appropriate error message is given.
I was able to reproduce the problem on both Mac OS X 10.3.9 and Debian Sarge
on x86.
The following illustrates the bug.
wszopko@fortress-curry:~$ createdb trash
CREATE DATABASE
wszopko@fortress-curry:~$ cat test.sql
CREATE SCHEMA junk;
SELECT version();
CREATE TABLE junk.my_table (
my_table_id SERIAL NOT NULL PRIMARY KEY,
my_column INTEGER NOT NULL DEFAULT 0);
CREATE OR REPLACE FUNCTION show_bug()
RETURNS BOOLEAN AS $PROC$
DECLARE
myColumn junk.my_table.bad_column%TYPE;
BEGIN
RETURN true;
END;
$PROC$ LANGUAGE 'plpgsql';
wszopko@fortress-curry:~$ psql -f ./test.sql trash
CREATE SCHEMA
version
----------------------------------------------------------------------------
----------------
PostgreSQL 8.1.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5
(Debian 1:3.3.5-13)
(1 row)
psql:./test.sql:7: NOTICE: CREATE TABLE will create implicit sequence
"my_table_my_table_id_seq" for serial column "my_table.my_table_id"
psql:./test.sql:7: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit
index "my_table_pkey" for table "my_table"
CREATE TABLE
psql:./test.sql:17: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql:./test.sql:17: connection to server was lost
wszopko@fortress-curry:~$ dropdb trash
DROP DATABASE
"Will Szopko" <dba@vilaj.com> writes:
> The postmaster in 8.1.0 crashes when creating or replacing a PL/PgSQL
> function containing an invalid variable declaration.
Reproduced here --- thanks for the test case!
regards, tom lane
"Will Szopko" <dba@vilaj.com> writes:
> The postmaster in 8.1.0 crashes when creating or replacing a PL/PgSQL
> function containing an invalid variable declaration.
Looks like a copy-and-paste mistake...
Index: pl_comp.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v
retrieving revision 1.94.2.1
diff -c -r1.94.2.1 pl_comp.c
*** pl_comp.c 22 Nov 2005 18:23:30 -0000 1.94.2.1
--- pl_comp.c 9 Dec 2005 16:56:38 -0000
***************
*** 1457,1463 ****
done:
if (HeapTupleIsValid(classtup))
ReleaseSysCache(classtup);
! if (HeapTupleIsValid(classtup))
ReleaseSysCache(attrtup);
if (HeapTupleIsValid(typetup))
ReleaseSysCache(typetup);
--- 1457,1463 ----
done:
if (HeapTupleIsValid(classtup))
ReleaseSysCache(classtup);
! if (HeapTupleIsValid(attrtup))
ReleaseSysCache(attrtup);
if (HeapTupleIsValid(typetup))
ReleaseSysCache(typetup);
regards, tom lane