BUG #2101: Postmaster Crash Using PL/PgSQL With %TYPE on Non-Exisiting Column - Mailing list pgsql-bugs

From Will Szopko
Subject BUG #2101: Postmaster Crash Using PL/PgSQL With %TYPE on Non-Exisiting Column
Date
Msg-id 20051208153952.43677F0B5B@svr2.postgresql.org
Whole thread Raw
Responses Re: BUG #2101: Postmaster Crash Using PL/PgSQL With %TYPE on Non-Exisiting Column
Re: BUG #2101: Postmaster Crash Using PL/PgSQL With %TYPE on Non-Exisiting Column
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: "wangshj"
Date:
Subject: BUG #2103: System column oid is not unique
Next
From: wangshj
Date:
Subject: pgsql8.1: About COPY Command and system clomn oid