Skip site navigation (1) Skip section navigation (2)

BUG #4673: pl/PgSQL: Bug, when updating changed composite types.

From: "Oleg" <serovOv(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4673: pl/PgSQL: Bug, when updating changed composite types.
Date: 2009-02-23 14:11:50
Message-ID: 200902231411.n1NEBoQr077832@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      4673
Logged by:          Oleg
Email address:      serovOv(at)gmail(dot)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)"

Responses

pgsql-bugs by date

Next:From: tomasDate: 2009-02-23 14:28:32
Subject: Re: Link to MS Access
Previous:From: artur gancDate: 2009-02-23 13:24:06
Subject: Link to MS Access

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group