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