Insert into partion table without logic statement

Поиск
Список
Период
Сортировка
От Jolles, Peter M (GE Infra, Energy)
Тема Insert into partion table without logic statement
Дата
Msg-id 450587DECE7D17438DC4C9EFD12F0A430AB0A348@ALPMLVEM08.e2k.ad.ge.com
обсуждение исходный текст
Список pgsql-general
I have a table that has multiple partitions (1000+) and I want a trigger
or rule to be able to write data automatically to each partition. One of
the values I am inserting is the table partition name, but I'm not sure
how to use it as a variable in a trigger. All trigger examples have a
series of IF statements, and I don't want to have 1000 IF statements
evaluated on every insert, not to mention adding new statements when I
have new partitions created.

Is something like the following possible? In the current form (below) I
get an INSERT INTO ERROR. I'm relatively new to databases, completely
new to Postgres, so I'm not sure if I'm headed in the right direction or
not. I'm running 8.3.5 if it makes a difference.


CREATE OR REPLACE FUNCTION mytable_insert_trigger()
RETURNS trigger AS
$BODY$
BEGIN
    insert into NEW.PartitionNameVariable values (NEW.*);
    return null;
END;
$BODY$
LANGUAGE 'plpgsql'


Thanks,
Peter

В списке pgsql-general по дате отправления:

Предыдущее
От: Sam Mason
Дата:
Сообщение: Re: Adding Arabic dictionary for TSearch2.. to_tsvector('arabic'...) doesn't work..
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: Adding Arabic dictionary for TSearch2.. to_tsvector('arabic'...) doesn't work..