@@ -2373,6 +2373,74 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
23732373 </para>
23742374 </listitem>
23752375 </varlistentry>
2376+
2377+ <varlistentry id="libpq-connect-min-protocol-version" xreflabel="min_protocol_version">
2378+ <term><literal>min_protocol_version</literal></term>
2379+ <listitem>
2380+ <para>
2381+ Specifies the minimum protocol version to allow for the connection.
2382+ The default is to allow any version of the
2383+ <productname>PostgreSQL</productname> protocol supported by libpq,
2384+ which currently means <literal>3.0</literal>. If the server
2385+ does not support at least this protocol version the connection will be
2386+ closed.
2387+ </para>
2388+
2389+ <para>
2390+ The current supported values are
2391+ <literal>3.0</literal>,
2392+ <literal>3.2</literal>,
2393+ and <literal>latest</literal>. The <literal>latest</literal> value is
2394+ equivalent to the latest protocol version that is supported by the used
2395+ libpq version, which currently is <literal>3.2</literal>, but this will
2396+ change in future libpq releases.
2397+ </para>
2398+ </listitem>
2399+ </varlistentry>
2400+
2401+ <varlistentry id="libpq-connect-max-protocol-version" xreflabel="max_protocol_version">
2402+ <term><literal>max_protocol_version</literal></term>
2403+ <listitem>
2404+ <para>
2405+ Specifies the protocol version to request from the server.
2406+ The default is to use version <literal>3.0</literal> of the
2407+ <productname>PostgreSQL</productname> protocol, unless the connection
2408+ string specifies a feature that relies on a higher protocol version, in
2409+ that case the latest version supported by libpq is used. If the server
2410+ does not support the requested protocol version of the client the
2411+ connection will be automatically downgraded to a lower minor protocol
2412+ version, which the server does support. After the connection attempt has
2413+ completed you can use <xref linkend="libpq-PQprotocolVersion"/> to find
2414+ out which exact protocol version was negotiated.
2415+ </para>
2416+
2417+ <para>
2418+ The current supported values are
2419+ <literal>3.0</literal>,
2420+ <literal>3.2</literal>,
2421+ and <literal>latest</literal>. The <literal>latest</literal> value is
2422+ equivalent to the latest protocol version that is supported by the used
2423+ libpq version, which currently is <literal>3.2</literal>, but this will
2424+ change in future libpq releases.
2425+ </para>
2426+ </listitem>
2427+ </varlistentry>
2428+
2429+ <varlistentry id="libpq-connect-report-parameters" xreflabel="report_parameters">
2430+ <term><literal>report_parameters</literal></term>
2431+ <listitem>
2432+ <para>
2433+ Specifies the value that is requested at connection startup for the
2434+ <xref linkend="protocol-parameter-report-parameters"/> protocol
2435+ parameter. The connection attempt is not canceled if the server does
2436+ not support this protocol parameter, or if it only supports part of
2437+ the requested value.
2438+ Use the <xref linkend="libpq-PQreportParameters"/> function after
2439+ connection has completed to find out what actual value the server uses.
2440+ </para>
2441+
2442+ </listitem>
2443+ </varlistentry>
23762444 </variablelist>
23772445 </para>
23782446 </sect2>
@@ -2690,7 +2758,7 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName);
26902758 </para>
26912759
26922760 <para>
2693- Parameters reported as of the current release include:
2761+ The parameters that are reported by default as of the current release include:
26942762 <simplelist type="vert" columns="2">
26952763 <member><varname>application_name</varname></member>
26962764 <member><varname>client_encoding</varname></member>
@@ -2718,6 +2786,10 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName);
27182786 <varname>server_encoding</varname> and
27192787 <varname>integer_datetimes</varname>
27202788 cannot change after startup.
2789+ It's possible to choose additional parameters for which the values should
2790+ be reported by using the
2791+ <xref linkend="protocol-parameter-report-parameters"/> protocol
2792+ parameter.
27212793 </para>
27222794
27232795 <para>
@@ -7655,6 +7727,117 @@ PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibilit
76557727 </listitem>
76567728 </varlistentry>
76577729
7730+ <varlistentry id="libpq-PQreportParameters">
7731+ <term><function>PQreportParameters</function><indexterm><primary>PQreportParameter</primary></indexterm></term>
7732+
7733+ <listitem>
7734+ <para>
7735+ Returns the server value of the
7736+ <xref linkend="protocol-parameter-report-parameters"/> protocol parameter.
7737+ <synopsis>
7738+ const char *PQreportParameters(const PGconn *<replaceable>conn</replaceable>);
7739+ </synopsis>
7740+
7741+ This returns a string with a comma separated list of server parameter
7742+ names. If the protocol parameter is not supported by the server this
7743+ returns NULL instead. Checking this value for NULL is the recommended way
7744+ to check for server support of report_parameters.
7745+ </para>
7746+ </listitem>
7747+ </varlistentry>
7748+
7749+ <varlistentry id="libpq-PQreportParametersSupport">
7750+ <term><function>PQreportParametersSupport</function><indexterm><primary>PQreportParametersSupport</primary></indexterm></term>
7751+
7752+ <listitem>
7753+ <para>
7754+ Returns the "supported values" of the
7755+ <xref linkend="protocol-parameter-report-parameters"/> protocol parameter.
7756+ <synopsis>
7757+ const char *PQreportParametersSupport(const PGconn *<replaceable>conn</replaceable>);
7758+ </synopsis>
7759+
7760+ This returns a string indicating what features report_parameters supports,
7761+ on future protocol versions this might be more useful, but for now this
7762+ always returns '<literal>L</literal>' if the report_parameters protocol
7763+ parameter is supported by the server. If the protocol parameter is not
7764+ supported by the server this returns NULL instead.
7765+ </para>
7766+ </listitem>
7767+ </varlistentry>
7768+
7769+ <varlistentry id="libpq-PQsetReportParameters">
7770+ <term><function>PQsetReportParameters</function><indexterm><primary>PQsetReportParameters</primary></indexterm></term>
7771+
7772+ <listitem>
7773+ <para>
7774+ Sends a request to set the value of the
7775+ <xref linkend="protocol-parameter-report-parameters"/> protocol parameter.
7776+ <synopsis>
7777+ PGresult *PQsetReportParameters(PGconn *<replaceable>conn</replaceable>, const char *<replaceable>params</replaceable>);
7778+ </synopsis>
7779+
7780+ <replaceable>conn</replaceable> is a connection to the server,
7781+ and <replaceable>params</replaceable> is a comma separated list of
7782+ parameter names for which the server should report their values.
7783+ use. If the request was not even sent, the function returns NULL;
7784+ The error message can be retrieved using
7785+ <xref linkend="libpq-PQerrorMessage"/>.
7786+ </para>
7787+
7788+ <para>
7789+ Returns a <structname>PGresult</structname> pointer representing the
7790+ result of the command, or a null pointer if the routine failed before
7791+ issuing any command.
7792+ The <xref linkend="libpq-PQresultStatus"/> function should be called
7793+ to check the return value for any errors (including the value of a null
7794+ pointer, in which case it will return
7795+ <symbol>PGRES_FATAL_ERROR</symbol>). Use
7796+ <xref linkend="libpq-PQerrorMessage"/> to get more information about
7797+ such errors.
7798+ </para>
7799+
7800+ <para>
7801+ The status can be <literal>PGRES_COMMAND_OK</literal> if the command
7802+ succeeded, <literal>PGRES_FATAL_ERROR</literal> if it failed, or
7803+ <literal>PGRES_NONFATAL_ERROR</literal> if it failed but not in a way
7804+ that required aborting a running transaction. Use
7805+ <xref linkend="libpq-PQerrorMessage"/> to get more information about the
7806+ error when the status is <literal>PGRES_FATAL_ERROR</literal>.
7807+ </para>
7808+
7809+ <para>
7810+ In case of success, use <xref linkend="libpq-PQreportParameters"/> to
7811+ find the new value of the report_parameters protocol parameter. This new
7812+ value might be different than the value that was sent, due to e.g.
7813+ unknown parameters.
7814+ </para>
7815+ </listitem>
7816+ </varlistentry>
7817+
7818+ <varlistentry id="libpq-PQsendSetReportParameters">
7819+ <term><function>PQsendSetReportParameters</function><indexterm><primary>PQsendSetReportParameters</primary></indexterm></term>
7820+
7821+ <listitem>
7822+ <para>
7823+ Sends a request to set the value of the
7824+ <xref linkend="protocol-parameter-report-parameters"/> protocol
7825+ parameter, without waiting for completion.
7826+ <synopsis>
7827+ int PQsendSetReportParameters(PGconn *conn, const char *params);
7828+ </synopsis>
7829+
7830+ This is an asynchronous version of
7831+ <xref linkend="libpq-PQsetReportParameters"/>: it
7832+ returns 1 if it was able to dispatch the request, and 0 if not.
7833+ After a successful call, call <xref linkend="libpq-PQgetResult"/> to
7834+ determine whether the server successfully set report_parameters. The
7835+ function's parameters are handled identically to
7836+ <xref linkend="libpq-PQsetReportParameters"/>.
7837+ </para>
7838+ </listitem>
7839+ </varlistentry>
7840+
76587841 <varlistentry id="libpq-PQtrace">
76597842 <term><function>PQtrace</function><indexterm><primary>PQtrace</primary></indexterm></term>
76607843
@@ -9219,6 +9402,26 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
92199402 linkend="libpq-connect-load-balance-hosts"/> connection parameter.
92209403 </para>
92219404 </listitem>
9405+
9406+ <listitem>
9407+ <para>
9408+ <indexterm>
9409+ <primary><envar>PGMINPROTOCOLVERSION</envar></primary>
9410+ </indexterm>
9411+ <envar>PGMINPROTOCOLVERSION</envar> behaves the same as the <xref
9412+ linkend="libpq-connect-min-protocol-version"/> connection parameter.
9413+ </para>
9414+ </listitem>
9415+
9416+ <listitem>
9417+ <para>
9418+ <indexterm>
9419+ <primary><envar>PGMAXPROTOCOLVERSION</envar></primary>
9420+ </indexterm>
9421+ <envar>PGMAXPROTOCOLVERSION</envar> behaves the same as the <xref
9422+ linkend="libpq-connect-max-protocol-version"/> connection parameter.
9423+ </para>
9424+ </listitem>
92229425 </itemizedlist>
92239426 </para>
92249427
0 commit comments