Some C pgsql api improvements.

This commit is contained in:
Joris Vink 2019-06-01 23:14:50 +02:00
parent ff7c85460c
commit 1686ec22e6
2 changed files with 12 additions and 8 deletions

View File

@ -26,6 +26,10 @@
#define KORE_PGSQL_ASYNC 0x0002
#define KORE_PGSQL_SCHEDULED 0x0004
#define KORE_PGSQL_PARAM_BINARY(v, l) v, l, 1
#define KORE_PGSQL_PARAM_TEXT_LEN(v, l) v, l, 0
#define KORE_PGSQL_PARAM_TEXT(v) v, strlen(v), 0
#if defined(__cplusplus)
extern "C" {
#endif
@ -81,12 +85,12 @@ int kore_pgsql_setup(struct kore_pgsql *, const char *, int);
void kore_pgsql_handle(void *, int);
void kore_pgsql_cleanup(struct kore_pgsql *);
void kore_pgsql_continue(struct kore_pgsql *);
int kore_pgsql_query(struct kore_pgsql *, const char *);
int kore_pgsql_query(struct kore_pgsql *, const void *);
int kore_pgsql_query_params(struct kore_pgsql *,
const char *, int, int, ...);
const void *, int, int, ...);
int kore_pgsql_v_query_params(struct kore_pgsql *,
const char *, int, int, va_list);
int kore_pgsql_query_param_fields(struct kore_pgsql *, const char *,
const void *, int, int, va_list);
int kore_pgsql_query_param_fields(struct kore_pgsql *, const void *,
int, int, const char **, int *, int *);
int kore_pgsql_register(const char *, const char *);
int kore_pgsql_ntuples(struct kore_pgsql *);

View File

@ -172,7 +172,7 @@ kore_pgsql_bind_callback(struct kore_pgsql *pgsql,
}
int
kore_pgsql_query(struct kore_pgsql *pgsql, const char *query)
kore_pgsql_query(struct kore_pgsql *pgsql, const void *query)
{
if (pgsql->conn == NULL) {
pgsql_set_error(pgsql, "no connection was set before query");
@ -202,7 +202,7 @@ kore_pgsql_query(struct kore_pgsql *pgsql, const char *query)
int
kore_pgsql_v_query_params(struct kore_pgsql *pgsql,
const char *query, int binary, int count, va_list args)
const void *query, int binary, int count, va_list args)
{
int i;
const char **values;
@ -240,7 +240,7 @@ kore_pgsql_v_query_params(struct kore_pgsql *pgsql,
}
int
kore_pgsql_query_param_fields(struct kore_pgsql *pgsql, const char *query,
kore_pgsql_query_param_fields(struct kore_pgsql *pgsql, const void *query,
int binary, int count, const char **values, int *lengths, int *formats)
{
if (pgsql->conn == NULL) {
@ -275,7 +275,7 @@ kore_pgsql_query_param_fields(struct kore_pgsql *pgsql, const char *query,
int
kore_pgsql_query_params(struct kore_pgsql *pgsql,
const char *query, int binary, int count, ...)
const void *query, int binary, int count, ...)
{
int ret;
va_list args;