Home Explore Blog CI



postgresql

55th chunk of `doc/src/sgml/ref/psql-ref.sgml`
5a53c6f47c0c94b7f0043522252c1dbbfced1867e53a589f0000000100000fa1
 set by <command>\o</command>.
        </para>

        <para>
         The target function can be specified by name alone, or by name
         and arguments, for example <literal>foo(integer, text)</literal>.
         The argument types must be given if there is more
         than one function of the same name.
        </para>

        <para>
         If <literal>+</literal> is appended to the command name, then the
         output lines are numbered, with the first line of the function body
         being line 1.
        </para>

        <para>
        Unlike most other meta-commands, the entire remainder of the line is
        always taken to be the argument(s) of <command>\sf</command>, and neither
        variable interpolation nor backquote expansion are performed in the
        arguments.
        </para>
        </listitem>
      </varlistentry>


      <varlistentry id="app-psql-meta-command-sv">
        <term><literal>\sv[+] <replaceable class="parameter">view_name</replaceable> </literal></term>

        <listitem>
         <para>
          This command fetches and shows the definition of the named view,
          in the form of a <command>CREATE OR REPLACE VIEW</command> command.
          The definition is printed to the current query output channel,
          as set by <command>\o</command>.
         </para>

         <para>
          If <literal>+</literal> is appended to the command name, then the
          output lines are numbered from 1.
         </para>

        <para>
        Unlike most other meta-commands, the entire remainder of the line is
        always taken to be the argument(s) of <command>\sv</command>, and neither
        variable interpolation nor backquote expansion are performed in the
        arguments.
        </para>
        </listitem>
      </varlistentry>

     <varlistentry id="app-psql-meta-command-pipeline">
      <term><literal>\startpipeline</literal></term>
      <term><literal>\sendpipeline</literal></term>
      <term><literal>\syncpipeline</literal></term>
      <term><literal>\endpipeline</literal></term>
      <term><literal>\flushrequest</literal></term>
      <term><literal>\flush</literal></term>
      <term><literal>\getresults [ <replaceable class="parameter">number_results</replaceable> ]</literal></term>

      <listitem>
       <para>
        This group of commands implements pipelining of SQL statements.
        A pipeline must begin with a <command>\startpipeline</command>
        and end with an <command>\endpipeline</command>. In between there
        may be any number of <command>\syncpipeline</command> commands,
        which sends a <link linkend="protocol-flow-ext-query">sync message</link>
        without ending the ongoing pipeline and flushing the send buffer.
        In pipeline mode, statements are sent to the server without waiting
        for the results of previous statements.
        See <xref linkend="libpq-pipeline-mode"/> for more details.
       </para>

       <para>
        All queries executed while a pipeline is ongoing use the extended
        query protocol. Queries are appended to the pipeline when ending with
        a semicolon. The meta-commands <literal>\bind</literal>,
        <literal>\bind_named</literal>, <literal>\close</literal> or
        <literal>\parse</literal> can be used in an ongoing pipeline. While
        a pipeline is ongoing, <literal>\sendpipeline</literal> will append
        the current query buffer to the pipeline. Other meta-commands like
        <literal>\g</literal>, <literal>\gx</literal> or
        <literal>\gdesc</literal> are not allowed in pipeline mode.
       </para>

       <para>
        <command>\flushrequest</command> appends a flush command to the
        pipeline, allowing to read results with
        <command>\getresults</command> without issuing a sync or ending the
        pipeline. <command>\getresults</command> will automatically push
        unsent data to the server. <command>\flush</command> can

Title: psql Meta-Commands: \sv and Pipelining Commands
Summary
This section details the \sv meta-command in psql, which displays the definition of a view, similar to \sf for functions. It also introduces a set of commands for SQL statement pipelining: \startpipeline, \sendpipeline, \syncpipeline, \endpipeline, \flushrequest, \flush, and \getresults. These commands allow sending multiple SQL statements to the server without waiting for the results of each one, improving performance. The section explains how to use these commands to manage pipelines and retrieve results.