|
528 | 528 | </para>
|
529 | 529 |
|
530 | 530 | <para>
|
531 |
| - The executor mechanism is used to evaluate all four basic SQL query types: |
532 |
| - <command>SELECT</command>, <command>INSERT</command>, <command>UPDATE</command>, and |
533 |
| - <command>DELETE</command>. For <command>SELECT</command>, the top-level executor |
534 |
| - code only needs to send each row returned by the query plan tree off |
535 |
| - to the client. For <command>INSERT</command>, each returned row is inserted |
536 |
| - into the target table specified for the <command>INSERT</command>. This is |
537 |
| - done in a special top-level plan node called <literal>ModifyTable</literal>. |
538 |
| - (A simple |
539 |
| - <command>INSERT ... VALUES</command> command creates a trivial plan tree |
540 |
| - consisting of a single <literal>Result</literal> node, which computes just one |
541 |
| - result row, and <literal>ModifyTable</literal> above it to perform the insertion. |
542 |
| - But <command>INSERT ... SELECT</command> can demand the full power |
543 |
| - of the executor mechanism.) For <command>UPDATE</command>, the planner arranges |
544 |
| - that each computed row includes all the updated column values, plus |
545 |
| - the <firstterm>TID</firstterm> (tuple ID, or row ID) of the original target row; |
546 |
| - this data is fed into a <literal>ModifyTable</literal> node, which uses the |
547 |
| - information to create a new updated row and mark the old row deleted. |
548 |
| - For <command>DELETE</command>, the only column that is actually returned by the |
549 |
| - plan is the TID, and the <literal>ModifyTable</literal> node simply uses the TID |
550 |
| - to visit each target row and mark it deleted. |
| 531 | + The executor mechanism is used to evaluate all four basic SQL query |
| 532 | + types: <command>SELECT</command>, <command>INSERT</command>, |
| 533 | + <command>UPDATE</command>, and <command>DELETE</command>. |
| 534 | + For <command>SELECT</command>, the top-level executor code |
| 535 | + only needs to send each row returned by the query plan tree |
| 536 | + off to the client. <command>INSERT ... SELECT</command>, |
| 537 | + <command>UPDATE</command>, and <command>DELETE</command> |
| 538 | + are effectively <command>SELECT</command>s under a special |
| 539 | + top-level plan node called <literal>ModifyTable</literal>. |
| 540 | + </para> |
| 541 | + |
| 542 | + <para> |
| 543 | + <command>INSERT ... SELECT</command> feeds the rows up |
| 544 | + to <literal>ModifyTable</literal> for insertion. For |
| 545 | + <command>UPDATE</command>, the planner arranges that each |
| 546 | + computed row includes all the updated column values, plus the |
| 547 | + <firstterm>TID</firstterm> (tuple ID, or row ID) of the original |
| 548 | + target row; this data is fed up to the <literal>ModifyTable</literal> |
| 549 | + node, which uses the information to create a new updated row and |
| 550 | + mark the old row deleted. For <command>DELETE</command>, the only |
| 551 | + column that is actually returned by the plan is the TID, and the |
| 552 | + <literal>ModifyTable</literal> node simply uses the TID to visit each |
| 553 | + target row and mark it deleted. |
| 554 | + </para> |
| 555 | + |
| 556 | + <para> |
| 557 | + A simple <command>INSERT ... VALUES</command> command creates a |
| 558 | + trivial plan tree consisting of a single <literal>Result</literal> |
| 559 | + node, which computes just one result row, feeding that up |
| 560 | + to<literal>ModifyTable</literal> to perform the insertion. |
551 | 561 | </para>
|
552 | 562 |
|
553 | 563 | </sect1>
|
|
0 commit comments