Re: Deprecating RULES

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: Deprecating RULES
Дата
Msg-id 508035F1.5080603@pinpointresearch.com
обсуждение исходный текст
Ответ на Re: Deprecating RULES  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 10/17/2012 04:25 PM, Tom Lane wrote:
> ...Now having said that, I would definitely like to see rules in their 
> current form go away eventually. But not without a substitute. 
> Triggers are not a complete replacement, and no amount of wishful 
> thinking makes them so.
...
> Perhaps it would be more profitable to try to identify the pain points 
> that make people so eager to get rid of rules, and then see if we 
> could alleviate them.

Alternately/additionally identify the deficiencies in triggers that 
drive users to prefer rules. For example, a common need is to update a 
log table whenever updates are made to a main table.

Using rules to accomplish this is very easy to understand and write, 
even for most beginners. (Understand properly including limitations and 
dangers is another issue, of course.) It is also easy to maintain. If 
you drop the table, the rule is cleaned up as well.

With triggers you need to select from a variety of available languages, 
write a function in that language and write a trigger that calls that 
function. Dropping the function will remove the trigger but the user 
must remember to delete the function as well, if desired. Nothing 
insurmountable but inconvenient compared to the use of a rule.

Per the documentation "PostgreSQL only allows the execution of a 
user-defined function for the triggered action. The standard allows the 
execution of a number of other SQL commands..."

There may be valid reasons why implementing that part of the SQL 
standard in PostgreSQL is difficult or unwise but removing that 
limitation on triggers would eliminate one annoyance that pushes users 
toward rules.

Cheers,
Steve




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

Предыдущее
От: Daniel Farina
Дата:
Сообщение: Re: xlog filename formatting functions in recovery
Следующее
От: Guillaume Lelarge
Дата:
Сообщение: Re: Bug in -c CLI option of pg_dump/pg_restore