|
1 |
| -<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.33 2003/04/28 05:17:31 tgl Exp $ --> |
| 1 | +<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.34 2003/05/05 00:44:55 tgl Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="protocol">
|
4 | 4 | <title>Frontend/Backend Protocol</title>
|
|
595 | 595 | <para>
|
596 | 596 | If successfully created, a named prepared-statement object lasts till
|
597 | 597 | the end of the current session, unless explicitly destroyed. An unnamed
|
598 |
| - prepared statement lasts only until the next Parse message is issued. |
| 598 | + prepared statement lasts only until the next Parse statement specifying |
| 599 | + the unnamed statement as destination is issued. (Note that a simple |
| 600 | + Query message also destroys the unnamed statement.) Named prepared |
| 601 | + statements must be explicitly closed before they can be redefined by |
| 602 | + a Parse message, but this is not required for the unnamed statement. |
599 | 603 | Named prepared statements can also be created and accessed at the SQL
|
600 | 604 | command level, using <command>PREPARE</> and <command>EXECUTE</>.
|
601 | 605 | </para>
|
|
611 | 615 | </para>
|
612 | 616 |
|
613 | 617 | <para>
|
614 |
| - If successfully created, a named portal object lasts till |
615 |
| - the end of the current transaction, unless explicitly destroyed. An |
616 |
| - unnamed portal is destroyed at the end of the transaction, or as soon |
617 |
| - as the next Parse or Bind message is executed. |
| 618 | + If successfully created, a named portal object lasts till the end of the |
| 619 | + current transaction, unless explicitly destroyed. An unnamed portal is |
| 620 | + destroyed at the end of the transaction, or as soon as the next Bind |
| 621 | + statement specifying the unnamed portal as destination is issued. (Note |
| 622 | + that a simple Query message also destroys the unnamed portal.) Named |
| 623 | + portals must be explicitly closed before they can be redefined by a Bind |
| 624 | + message, but this is not required for the unnamed portal. |
618 | 625 | Named portals can also be created and accessed at the SQL
|
619 | 626 | command level, using <command>DECLARE CURSOR</> and <command>FETCH</>.
|
620 | 627 | </para>
|
|
691 | 698 | The Describe message (statement variant) specifies the name of an existing
|
692 | 699 | prepared statement (or an empty string for the unnamed prepared
|
693 | 700 | statement). The response is a ParameterDescription message describing the
|
694 |
| - parameters needed by the statement (if any), followed by a RowDescription |
695 |
| - message describing the rows that will be returned when the statement is |
696 |
| - eventually executed (or NoData if there is no SELECT-type query in the |
697 |
| - prepared statement). ErrorResponse is issued if there is no such prepared |
698 |
| - statement. This message may be useful if the client library is |
699 |
| - uncertain about the parameters needed by a prepared statement. |
| 701 | + parameters needed by the statement. ErrorResponse is issued if there is |
| 702 | + no such prepared statement. This message may be useful if the client |
| 703 | + library is uncertain about the parameters needed by a prepared statement. |
700 | 704 | </para>
|
701 | 705 |
|
702 | 706 | <para>
|
703 | 707 | The Close message closes an existing prepared statement or portal
|
704 |
| - and releases resources. |
| 708 | + and releases resources. It is not an error to issue Close against |
| 709 | + a nonexistent statement or portal name. The response is normally |
| 710 | + CloseComplete, but could be ErrorResponse if some difficulty is |
| 711 | + encountered while releasing resources. Note that closing a prepared |
| 712 | + statement implicitly closes any open portals that were constructed |
| 713 | + from that statement. |
705 | 714 | </para>
|
706 | 715 |
|
707 | 716 | <para>
|
708 | 717 | The Flush message does not cause any specific output to be generated,
|
709 | 718 | but forces the backend to deliver any data pending in its output
|
710 | 719 | buffers. A Flush must be sent after any extended-query command except
|
711 | 720 | Sync, if the frontend wishes to examine the results of that command before
|
712 |
| - issuing more commands. Without Flush, returning data will be combined |
713 |
| - into the minimum possible number of packets to minimize network overhead. |
| 721 | + issuing more commands. Without Flush, messages returned by the backend |
| 722 | + will be combined into the minimum possible number of packets to minimize |
| 723 | + network overhead. |
714 | 724 | </para>
|
715 | 725 |
|
716 | 726 | <note>
|
717 | 727 | <para>
|
718 | 728 | The simple Query message is approximately equivalent to the series Parse,
|
719 |
| - Bind, portal Describe, Execute, Sync, using the unnamed prepared statement |
720 |
| - and portal objects and no parameters. One difference is that it |
721 |
| - will accept multiple SQL statements in the query string, automatically |
| 729 | + Bind, portal Describe, Execute, Close, Sync, using the unnamed prepared |
| 730 | + statement and portal objects and no parameters. One difference is that |
| 731 | + it will accept multiple SQL statements in the query string, automatically |
722 | 732 | performing the bind/describe/execute sequence for each one in succession.
|
723 |
| - Another is that it will not return ParseComplete, BindComplete, or |
724 |
| - NoData messages. |
| 733 | + Another difference is that it will not return ParseComplete, BindComplete, |
| 734 | + CloseComplete, or NoData messages. |
725 | 735 | </para>
|
726 | 736 | </note>
|
727 | 737 | </sect2>
|
@@ -1917,6 +1927,41 @@ Close (F)
|
1917 | 1927 | </VarListEntry>
|
1918 | 1928 |
|
1919 | 1929 |
|
| 1930 | +<VarListEntry> |
| 1931 | +<Term> |
| 1932 | +CloseComplete (B) |
| 1933 | +</Term> |
| 1934 | +<ListItem> |
| 1935 | +<Para> |
| 1936 | + |
| 1937 | +<VariableList> |
| 1938 | +<VarListEntry> |
| 1939 | +<Term> |
| 1940 | + Byte1('3') |
| 1941 | +</Term> |
| 1942 | +<ListItem> |
| 1943 | +<Para> |
| 1944 | + Identifies the message as a Close-complete indicator. |
| 1945 | +</Para> |
| 1946 | +</ListItem> |
| 1947 | +</VarListEntry> |
| 1948 | +<VarListEntry> |
| 1949 | +<Term> |
| 1950 | + Int32(4) |
| 1951 | +</Term> |
| 1952 | +<ListItem> |
| 1953 | +<Para> |
| 1954 | + Length of message contents in bytes, including self. |
| 1955 | +</Para> |
| 1956 | +</ListItem> |
| 1957 | +</VarListEntry> |
| 1958 | +</VariableList> |
| 1959 | + |
| 1960 | +</Para> |
| 1961 | +</ListItem> |
| 1962 | +</VarListEntry> |
| 1963 | + |
| 1964 | + |
1920 | 1965 | <VarListEntry>
|
1921 | 1966 | <Term>
|
1922 | 1967 | CommandComplete (B)
|
@@ -3875,6 +3920,15 @@ The ReadyForQuery ('<literal>Z</>') message includes a transaction status
|
3875 | 3920 | indicator.
|
3876 | 3921 | </para>
|
3877 | 3922 |
|
| 3923 | +<para> |
| 3924 | +There is a new <quote>extended query</> sub-protocol, which adds the frontend |
| 3925 | +message types Parse, Bind, Execute, Describe, Close, Flush, and Sync, and the |
| 3926 | +backend message types ParseComplete, BindComplete, PortalSuspended, |
| 3927 | +ParameterDescription, NoData, and CloseComplete. Existing clients do not |
| 3928 | +have to concern themselves with this sub-protocol, but making use of it |
| 3929 | +may allow improvements in performance or functionality. |
| 3930 | +</para> |
| 3931 | + |
3878 | 3932 | <para>
|
3879 | 3933 | COPY data is now encapsulated into CopyData and CopyDone messages. There
|
3880 | 3934 | is a well-defined way to recover from errors during COPY. The special
|
|
0 commit comments