Re: [HACKERS] UPDATE of partition key

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: [HACKERS] UPDATE of partition key
Дата
Msg-id 20171114165205.52ligem7qley3col@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: [HACKERS] UPDATE of partition key  (David Rowley <david.rowley@2ndquadrant.com>)
Список pgsql-hackers
David Rowley wrote:

> 5. Triggers. Do we need a new "TG_" tag to allow trigger functions to
> do something special when the DELETE/INSERT is a partition move? I
> have audit tables in mind here it may appear as though a user
> performed a DELETE when they actually performed an UPDATE giving
> visibility of this to the trigger function will allow the application
> to work around this.

+1  I think we do need a flag that can be inspected from the user
trigger function.

> 9. Also, this should likely be reworded:
> 
>  * 'num_update_rri' : number of UPDATE per-subplan result rels. For INSERT,
>  *      this is 0.
> 
>  'num_update_rri' number of elements in 'update_rri' array or zero for INSERT.

Also:

/pgsql/source/master/src/backend/executor/execMain.c: In function 'ExecSetupPartitionTupleRouting':
/pgsql/source/master/src/backend/executor/execMain.c:3401:18: warning: 'leaf_part_arr' may be used uninitialized in
thisfunction [-Wmaybe-uninitialized]   leaf_part_rri = leaf_part_arr + i;   ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
 

I think using num_update_rri==0 as a flag to indicate INSERT is strange.
I suggest passing an additional boolean -- or maybe just split the whole
function in two, one for updates and another for inserts, say
ExecSetupPartitionTupleRoutingForInsert() and
ExecSetupPartitionTupleRoutingForUpdate().  They seem to
share almost no code, and the current flow is hard to read; maybe just
add a common subroutine for the lower bottom of the loop.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: plpgsql test layout
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: [HACKERS] MAIN, Uncompressed?