Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
39.6. Rules and Command Status
Prev UpChapter 39. The Rule SystemHome Next

39.6. Rules and Command Status#

ThePostgreSQL server returns a command status string, such asINSERT 149592 1, for each command it receives. This is simple enough when there are no rules involved, but what happens when the query is rewritten by rules?

Rules affect the command status as follows:

  • If there is no unconditionalINSTEAD rule for the query, then the originally given query will be executed, and its command status will be returned as usual. (But note that if there were any conditionalINSTEAD rules, the negation of their qualifications will have been added to the original query. This might reduce the number of rows it processes, and if so the reported status will be affected.)

  • If there is any unconditionalINSTEAD rule for the query, then the original query will not be executed at all. In this case, the server will return the command status for the last query that was inserted by anINSTEAD rule (conditional or unconditional) and is of the same command type (INSERT,UPDATE, orDELETE) as the original query. If no query meeting those requirements is added by any rule, then the returned command status shows the original query type and zeroes for the row-count and OID fields.

The programmer can ensure that any desiredINSTEAD rule is the one that sets the command status in the second case, by giving it the alphabetically last rule name among the active rules, so that it gets applied last.


Prev Up Next
39.5. Rules and Privileges Home 39.7. Rules Versus Triggers
pdfepub
Go to PostgreSQL 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp