From 3e5ca0f158bd671e56690e034afcc26a1d10b00a Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Fri, 28 Jul 2023 15:18:18 +0200 Subject: pq: added oid-by-name lookup API NEWS: Added GNUNET_PQ_get_oid_by_name --- src/include/gnunet_pq_lib.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index edb0519b0..3b960df70 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h @@ -28,6 +28,7 @@ #include #include +#include "gnunet_common.h" #include "gnunet_time_lib.h" #include "gnunet_util_lib.h" #include "gnunet_db_lib.h" @@ -198,7 +199,7 @@ enum GNUNET_PQ_DataTypes }; /** - * Returns the oid for a given datatype + * Returns the oid for a given, basic datatype * * @param db The db-connection * @param typ the Datatype @@ -209,6 +210,38 @@ GNUNET_PQ_get_oid ( const struct GNUNET_PQ_Context *db, enum GNUNET_PQ_DataTypes typ); +/** + * Returns the oid for a given datatype by name. + * + * @param db The db-connection + * @param name The name of the datatype + * @param[out] oid The OID of the datatype. + * @return GNUNET_OK when the datatype was found, GNUNET_SYSERR otherwise + */ +enum GNUNET_GenericReturnValue +GNUNET_PQ_get_oid_by_name ( + struct GNUNET_PQ_Context *db, + const char *name, + Oid *oid); + + +/** + * The header for a postgresql array in binary format. note that this a + * simplified special case of the general structure (which contains pointers), + * as we only support one-dimensional arrays. + * + * Note that all values must be in network-byte-order. + */ +struct GNUNET_PQ_ArrayHeader_P +{ + uint32_t ndim; /* number of dimensions. we only support ndim = 1 */ + uint32_t has_null; + uint32_t oid; /* oid of the elements */ + uint32_t dim; /* size of the array */ + uint32_t lbound; /* index value of first element in the db (default: 1). */ +} __attribute__((packed)); + + /** * Generate query parameter for an array of bool in host byte order. * -- cgit v1.2.3