~ubuntu-branches/debian/squeeze/pgadmin3/squeeze

« back to all changes in this revision

Viewing changes to docs/en_US/pg/rules-views.html

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Enrici, src/frm/frmBackup.cpp, debian/control
  • Date: 2006-10-06 21:06:48 UTC
  • mfrom: (1.1.3 upstream) (3 etch)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061006210648-8ebo8o2zu28ydg0d
Tags: 1.4.3-2
* Patched frmBackup.cpp to ensure the schema is specified when backing up
  individual tables. (Closes: #387256)
  [src/frm/frmBackup.cpp]
* Cleaned up and updated description of the package. (Closes: #379188)
  [debian/control]

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
<title>34.2.�Views and the Rule System</title>
5
5
<link rel="stylesheet" href="stylesheet.css" type="text/css">
6
6
<link rev="made" href="pgsql-docs@postgresql.org">
7
 
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
8
 
<link rel="start" href="index.html" title="PostgreSQL 8.1.3 Documentation">
 
7
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
 
8
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
9
9
<link rel="up" href="rules.html" title="Chapter�34.�The Rule System">
10
10
<link rel="prev" href="rules.html" title="Chapter�34.�The Rule System">
11
11
<link rel="next" href="rules-update.html" title="34.3.�Rules on INSERT, UPDATE, and DELETE">
 
12
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
12
13
</head>
13
14
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
14
15
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
15
16
<a name="rules-views"></a>34.2.�Views and the Rule System</h2></div></div></div>
16
 
<a name="id663159"></a><a name="id663173"></a><p>    Views in <span class="productname">PostgreSQL</span> are implemented
 
17
<a name="id716190"></a><a name="id716204"></a><p>    Views in <span class="productname">PostgreSQL</span> are implemented
17
18
    using the rule system. In fact, there is essentially no difference
18
19
    between
19
20
 
39
40
<div class="sect2" lang="en">
40
41
<div class="titlepage"><div><div><h3 class="title">
41
42
<a name="rules-select"></a>34.2.1.�How <code class="command">SELECT</code> Rules Work</h3></div></div></div>
42
 
<a name="id663252"></a><p>    Rules <code class="literal">ON SELECT</code> are applied to all queries as the last step, even
 
43
<a name="id716283"></a><p>    Rules <code class="literal">ON SELECT</code> are applied to all queries as the last step, even
43
44
    if the command given is an <code class="command">INSERT</code>,
44
45
    <code class="command">UPDATE</code> or <code class="command">DELETE</code>. And they
45
46
    have different semantics from rules on the other command types in that they modify the
357
358
</div>
358
359
<div class="sect2" lang="en">
359
360
<div class="titlepage"><div><div><h3 class="title">
360
 
<a name="id663958"></a>34.2.2.�View Rules in Non-<code class="command">SELECT</code> Statements</h3></div></div></div>
 
361
<a name="id717045"></a>34.2.2.�View Rules in Non-<code class="command">SELECT</code> Statements</h3></div></div></div>
361
362
<p>    Two details of the query tree aren't touched in the description of
362
363
    view rules above. These are the command type and the result relation.
363
364
    In fact, view rules don't need this information.</p>
423
424
<p>    To resolve this problem, another entry is added to the target list
424
425
    in <code class="command">UPDATE</code> (and also in
425
426
    <code class="command">DELETE</code>) statements: the current tuple ID
426
 
    (<span class="acronym">CTID</span>).<a name="id664196"></a>  This is a system column containing the
 
427
    (<acronym class="acronym">CTID</acronym>).<a name="id717284"></a>  This is a system column containing the
427
428
    file block number and position in the block for the row. Knowing
428
 
    the table, the <span class="acronym">CTID</span> can be used to retrieve the
429
 
    original row of <code class="literal">t1</code> to be updated.  After adding the <span class="acronym">CTID</span>
 
429
    the table, the <acronym class="acronym">CTID</acronym> can be used to retrieve the
 
430
    original row of <code class="literal">t1</code> to be updated.  After adding the <acronym class="acronym">CTID</acronym>
430
431
    to the target list, the query actually looks like
431
432
 
432
433
</p>
437
438
    the stage. Old table rows aren't overwritten, and this
438
439
    is why <code class="command">ROLLBACK</code> is fast. In an <code class="command">UPDATE</code>,
439
440
    the new result row is inserted into the table (after stripping the
440
 
    <span class="acronym">CTID</span>) and in the row header of the old row, which the
441
 
    <span class="acronym">CTID</span> pointed to, the <code class="literal">cmax</code> and
 
441
    <acronym class="acronym">CTID</acronym>) and in the row header of the old row, which the
 
442
    <acronym class="acronym">CTID</acronym> pointed to, the <code class="literal">cmax</code> and
442
443
    <code class="literal">xmax</code> entries are set to the current command counter
443
444
    and current transaction ID. Thus the old row is hidden, and after
444
445
    the transaction committed the vacuum cleaner can really move it
448
449
</div>
449
450
<div class="sect2" lang="en">
450
451
<div class="titlepage"><div><div><h3 class="title">
451
 
<a name="id664284"></a>34.2.3.�The Power of Views in <span class="productname">PostgreSQL</span></h3></div></div></div>
 
452
<a name="id717372"></a>34.2.3.�The Power of Views in <span class="productname">PostgreSQL</span></h3></div></div></div>
452
453
<p>    The above demonstrates how the rule system incorporates view
453
454
    definitions into the original query tree. In the second example, a
454
455
    simple <code class="command">SELECT</code> from one view created a final