Re: Trouble with NEW

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Trouble with NEW
Дата
Msg-id 5008432F.9080408@gmail.com
обсуждение исходный текст
Ответ на Re: Trouble with NEW  ("Bob Pawley" <rjpawley@shaw.ca>)
Ответы Re: Trouble with NEW  ("David Johnston" <polobo@yahoo.com>)
Список pgsql-general
On 07/19/2012 08:41 AM, Bob Pawley wrote:
> In all my reading of new and old I never made that connection.

It makes more sense if you know what NEW and OLD represent.

What follows is a simplification:
1)Postgres uses Multiversion Concurrency Control(MVCC). See here for
brief intro:
http://www.postgresql.org/docs/9.0/interactive/mvcc-intro.html

2) As a result on:
A) INSERT. For each record you have only a corresponding NEW record
that holds the values you are inserting.
b) UPDATE. In Postgres an update is a two part process where you delete
the old record and insert the new record. In that case you have both an
OLD and a NEW record representing the respective values.
c) DELETE. You are getting rid of a record and all you have is the OLD
record representing the record you are deleting.

3) When you use a trigger or rule that uses the OLD, NEW records it only
has access to those records for the table it is attached to.

4) If you want to pull information from another table, you either need
to set up a FOREIGN KEY relationship that you can leverage or you need
to do a query in the trigger function that pulls in the necessary
information.

>
> Thanks Adrian
>
> Bob

>


--
Adrian Klaver
adrian.klaver@gmail.com



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

Предыдущее
От: Younus
Дата:
Сообщение: Re: How to stop a query
Следующее
От: Luiz Damim
Дата:
Сообщение: Default value of serial fields changes after restore