BUG #4673: pl/PgSQL: Bug, when updating changed composite types. - Mailing list pgsql-bugs

From Oleg
Subject BUG #4673: pl/PgSQL: Bug, when updating changed composite types.
Date
Msg-id 200902231411.n1NEBoQr077832@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #4673: pl/PgSQL: Bug, when updating changed composite types.
List pgsql-bugs
The following bug has been logged online:

Bug reference:      4673
Logged by:          Oleg
Email address:      serovOv@gmail.com
PostgreSQL version: 8.3.6
Operating system:   i686-redhat-linux-gnu
Description:        pl/PgSQL: Bug, when updating changed composite types.
Details:

If you added a field into composite type(table type), plpgsql won't update
it, until you recompile function.

DEMO SQL:

ROLLBACK;
BEGIN;
CREATE TABLE bug_composite (
    column_a INT,
    column_b INT
);

CREATE TABLE bug_parent (
    id INT,
    info bug_composite
);

INSERT INTO bug_parent(id, info) VALUES (1, ROW(1, 2));

CREATE OR REPLACE FUNCTION bug_update(r bug_parent) RETURNS void
AS
$BODY$
BEGIN
    UPDATE bug_parent
        SET info = r.info
        WHERE id = r.id;
END;
$BODY$ LANGUAGE 'plpgsql' VOLATILE;

SELECT bug_update(ROW(1, ROW(3, 5)));

SELECT * FROM bug_parent; -- WE WILL HAVE ROW(1, ROW(3, 5));

ALTER TABLE bug_composite ADD COLUMN column_c INT;

SELECT * FROM bug_parent; -- WE WILL HAVE ROW(1, ROW(3, 5, NULL));

SELECT bug_update(ROW(1, ROW(4, 6, 9)));

SELECT * FROM bug_parent; -- WE WILL HAVE ROW(1, ROW(4, 6, NULL));

SELECT version(); -- "PostgreSQL 8.3.6 on i686-redhat-linux-gnu, compiled by
GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)"

pgsql-bugs by date:

Previous
From: artur ganc
Date:
Subject: Link to MS Access
Next
From: tomas@tuxteam.de
Date:
Subject: Re: Link to MS Access