commit b14eee0fdd9c3f5283788fd60733b5a08d39a17f
parent effd970f95eb50bebbe4fed4b2343e192a1487f9
Author: Özgür Kesim <oec-taler@kesim.org>
Date: Wed, 26 Jul 2023 03:51:17 +0200
pq: expose array-type->oid mapping via function
NEWS: added GNUNET_PQ_get_oid()
Diffstat:
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
@@ -31,13 +31,13 @@
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_db_lib.h"
+#include "postgres_ext.h"
/**
* Postgres context.
*/
struct GNUNET_PQ_Context;
-
/* ************************* pq_query_helper.c functions ************************ */
@@ -198,6 +198,18 @@ enum GNUNET_PQ_DataTypes
};
/**
+ * Returns the oid for a given datatype
+ *
+ * @param db The db-connection
+ * @param typ the Datatype
+ * @return The oid
+ */
+Oid
+GNUNET_PQ_get_oid (
+ const struct GNUNET_PQ_Context *db,
+ enum GNUNET_PQ_DataTypes typ);
+
+/**
* Generate query parameter for an array of bool in host byte order.
*
* @param num Number of elements in @a elements
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
@@ -420,6 +420,16 @@ get_array_type_oids (struct GNUNET_PQ_Context *db)
}
+Oid
+GNUNET_PQ_get_oid (
+ const struct GNUNET_PQ_Context *db,
+ enum GNUNET_PQ_DataTypes typ)
+{
+ GNUNET_assert (GNUNET_PQ_DATATYPE_MAX > typ);
+ return db->oids[typ];
+}
+
+
void
GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db)
{