Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
rules-status.html35 linesDownload Raw Back to html
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>41.6. Rules and Command Status</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="rules-privileges.html" title="41.5. Rules and Privileges" /><link rel="next" href="rules-triggers.html" title="41.7. Rules Versus Triggers" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">41.6. Rules and Command Status</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="rules-privileges.html" title="41.5. Rules and Privileges">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="rules.html" title="Chapter 41. The Rule System">Up</a></td><th width="60%" align="center">Chapter 41. The Rule System</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="rules-triggers.html" title="41.7. Rules Versus Triggers">Next</a></td></tr></table><hr /></div><div class="sect1" id="RULES-STATUS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">41.6. Rules and Command Status <a href="#RULES-STATUS" class="id_link">#</a></h2></div></div></div><p>3    The <span class="productname">PostgreSQL</span> server returns a command4    status string, such as <code class="literal">INSERT 149592 1</code>, for each5    command it receives.  This is simple enough when there are no rules6    involved, but what happens when the query is rewritten by rules?7</p><p>8    Rules affect the command status as follows:9 10    </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>11       If there is no unconditional <code class="literal">INSTEAD</code> rule for the query, then12       the originally given query will be executed, and its command13       status will be returned as usual.  (But note that if there were14       any conditional <code class="literal">INSTEAD</code> rules, the negation of their qualifications15       will have been added to the original query.  This might reduce the16       number of rows it processes, and if so the reported status will17       be affected.)18      </p></li><li class="listitem"><p>19       If there is any unconditional <code class="literal">INSTEAD</code> rule for the query, then20       the original query will not be executed at all.  In this case,21       the server will return the command status for the last query22       that was inserted by an <code class="literal">INSTEAD</code> rule (conditional or23       unconditional) and is of the same command type24       (<code class="command">INSERT</code>, <code class="command">UPDATE</code>, or25       <code class="command">DELETE</code>) as the original query.  If no query26       meeting those requirements is added by any rule, then the27       returned command status shows the original query type and28       zeroes for the row-count and OID fields.29      </p></li></ul></div><p>30</p><p>31    The programmer can ensure that any desired <code class="literal">INSTEAD</code> rule is the one32    that sets the command status in the second case, by giving it the33    alphabetically last rule name among the active rules, so that it34    gets applied last.35</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="rules-privileges.html" title="41.5. Rules and Privileges">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="rules.html" title="Chapter 41. The Rule System">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="rules-triggers.html" title="41.7. Rules Versus Triggers">Next</a></td></tr><tr><td width="40%" align="left" valign="top">41.5. Rules and Privileges </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 41.7. Rules Versus Triggers</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai