I am implementing table partition.
-- There is reason behind why we do not want to use trigger technique for
table unit.
-- Please refer to :
http://archives.postgresql.org/pgsql-general/2010-01/msg01184.php
-- INSERT INTO unit(fk_lot_id, cycle)
-- VALUES(_lotID, _cycle) RETURNING unit_id INTO _unit_id;
unit_table_index = _lotID;
unit_table_name = 'unit_' || _lotID;
IF NOT EXISTS(SELECT * FROM information_schema.tables WHERE table_name =
unit_table_name) THEN
EXECUTE 'CREATE TABLE ' || quote_ident(unit_table_name) || '
(
unit_id bigserial NOT NULL,
fk_lot_id bigint NOT NULL,
CHECK (fk_lot_id = ' || (unit_table_index) || '),
CONSTRAINT pk_unit_' || unit_table_index || '_id PRIMARY KEY
(unit_id),
CONSTRAINT fk_lot_' || unit_table_index || '_id FOREIGN KEY
(fk_lot_id) REFERENCES lot (lot_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE
CASCADE
) INHERITS (unit);';
EXECUTE 'CREATE INDEX fk_lot_' || unit_table_index || '_id_idx ON ' ||
quote_ident(unit_table_name) || '(fk_lot_id);';
END IF;
EXECUTE 'INSERT INTO ' || quote_ident(unit_table_name) || '(fk_lot_id,
cycle) VALUES (' || _lotID || ',' || _cycle || ') RETURNING unit_id'
INTO _unit_id;
_unit.unit_id = _unit_id;
_unit.fk_lot_id = _lotID;
_unit.cycle = _cycle;
However, I always get the following message, when there is a new table need to
be created.
NOTICE: CREATE TABLE will create implicit sequence "unit_2_unit_id_seq" for
serial column "unit_2.unit_id"
CONTEXT: SQL statement "CREATE TABLE unit_2
(
unit_id bigserial NOT NULL,
fk_lot_id bigint NOT NULL,
CHECK (fk_lot_id = 2),
CONSTRAINT pk_unit_2_id PRIMARY KEY (unit_id),
CONSTRAINT fk_lot_2_id FOREIGN KEY (fk_lot_id) REFERENCES lot
(lot_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CAS
CADE
) INHERITS (unit);"
PL/pgSQL function "insert_unit" line 29 at EXECUTE statement
NOTICE: merging column "unit_id" with inherited definition
Is this the warning message I should take any action on it? If not, how I can
suppress it? It is quite annoying, when I saw these message keep printing out
from my c++ console.
Thanks and Regards
Yan Cheng CHEOK
--
Sent via pgsql-general mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general