v9-0003-libpq-Add-PQunsupportedProtocolExtensionParameter.patch
application/octet-stream
Filename: v9-0003-libpq-Add-PQunsupportedProtocolExtensionParameter.patch
Type: application/octet-stream
Part: 2
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v9-0003
Subject: libpq: Add PQunsupportedProtocolExtensionParameters
| File | + | − |
|---|---|---|
| doc/src/sgml/libpq.sgml | 19 | 0 |
| src/interfaces/libpq/exports.txt | 1 | 0 |
| src/interfaces/libpq/fe-connect.c | 14 | 0 |
| src/interfaces/libpq/libpq-fe.h | 1 | 0 |
From 27ddd3ff78476bea4cc7499be6860d3a287695b6 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Mon, 22 Jan 2024 09:54:28 +0100
Subject: [PATCH v9 03/13] libpq: Add PQunsupportedProtocolExtensionParameters
This patch adds a new PQunsupportedProtocolExtensionParamters API to
libpq. This can be used for feature detection of protocol extension
parameters by the client. Similar to how a client can feature detection
of the protocol and server version using PQprotocolVersion and
PQserverVersion respectively.
---
doc/src/sgml/libpq.sgml | 19 +++++++++++++++++++
src/interfaces/libpq/exports.txt | 1 +
src/interfaces/libpq/fe-connect.c | 14 ++++++++++++++
src/interfaces/libpq/libpq-fe.h | 1 +
4 files changed, 35 insertions(+)
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 1d8998efb2a..f939274249c 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -2573,6 +2573,25 @@ int PQprotocolVersion(const PGconn *conn);
</listitem>
</varlistentry>
+ <varlistentry id="libpq-PQunsupportedProtocolExtensionParameters">
+ <term><function>PQunsupportedProtocolExtensionParameters</function><indexterm><primary>PQunsupportedProtocolExtensionParameters</primary></indexterm></term>
+
+ <listitem>
+ <para>
+ Returns a null-terminated array of protocol extensions that were
+ requested by the client but are not supported by the server.
+<synopsis>
+int PQunsupportedProtocolExtensionParameters(const PGconn *conn);
+</synopsis>
+ Applications might wish to use this function to determine whether certain
+ protocol extensions they intended to use are supported. Even when some
+ extension is not supported the connection can still be used, only the
+ unsupported extensions cannot be used. Returns NULL if the connection is
+ bad.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="libpq-PQserverVersion">
<term><function>PQserverVersion</function><indexterm><primary>PQserverVersion</primary></indexterm></term>
diff --git a/src/interfaces/libpq/exports.txt b/src/interfaces/libpq/exports.txt
index 088592deb16..b46c387f6f7 100644
--- a/src/interfaces/libpq/exports.txt
+++ b/src/interfaces/libpq/exports.txt
@@ -193,3 +193,4 @@ PQsendClosePrepared 190
PQsendClosePortal 191
PQchangePassword 192
PQsendPipelineSync 193
+PQunsupportedProtocolExtensions 194
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 3ff4403858b..7075134d155 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -382,6 +382,8 @@ static const PQEnvironmentOption EnvironmentOptions[] =
}
};
+static const char *no_unsupported_protocol_extensions[1] = {NULL};
+
/* The connection URI must start with either of the following designators: */
static const char uri_designator[] = "postgresql://";
static const char short_uri_designator[] = "postgres://";
@@ -6857,6 +6859,18 @@ PQprotocolVersion(const PGconn *conn)
return PG_PROTOCOL_MAJOR(conn->pversion);
}
+const char **
+PQunsupportedProtocolExtensionParameters(const PGconn *conn)
+{
+ if (!conn)
+ return NULL;
+ if (conn->status == CONNECTION_BAD)
+ return NULL;
+ if (!conn->unsupported_pextension_params)
+ return no_unsupported_protocol_extensions;
+ return (const char **) conn->unsupported_pextension_params;
+}
+
int
PQserverVersion(const PGconn *conn)
{
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index defc415fa3f..d538f702b99 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -347,6 +347,7 @@ extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
extern const char *PQparameterStatus(const PGconn *conn,
const char *paramName);
extern int PQprotocolVersion(const PGconn *conn);
+extern const char **PQunsupportedProtocolExtensionParameters(const PGconn *conn);
extern int PQserverVersion(const PGconn *conn);
extern char *PQerrorMessage(const PGconn *conn);
extern int PQsocket(const PGconn *conn);
--
2.34.1