From b14eee0fdd9c3f5283788fd60733b5a08d39a17f Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Wed, 26 Jul 2023 03:51:17 +0200 Subject: pq: expose array-type->oid mapping via function NEWS: added GNUNET_PQ_get_oid() --- src/include/gnunet_pq_lib.h | 14 +++++++++++++- src/pq/pq_connect.c | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index 69cf84583..edb0519b0 100644 --- 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 ************************ */ @@ -197,6 +197,18 @@ enum GNUNET_PQ_DataTypes GNUNET_PQ_DATATYPE_MAX, /* Must be last */ }; +/** + * 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. * diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c index 9493eb2d7..f30f989ea 100644 --- 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) { -- cgit v1.2.3