unsigned int column_idx, int64_t value);
void (*statement_bind_double)(struct sql_statement *stmt,
unsigned int column_idx, double value);
+ void (*statement_bind_uuid)(struct sql_statement *stmt,
+ unsigned int column_idx, const guid_128_t uuid);
void (*statement_query)(struct sql_statement *stmt,
sql_query_callback_t *callback, void *context);
struct sql_result *(*statement_query_s)(struct sql_statement *stmt);
stmt->db->v.statement_bind_double(stmt, column_idx, value);
}
+void sql_statement_bind_uuid(struct sql_statement *stmt,
+ unsigned int column_idx, const guid_128_t uuid)
+{
+ const char *value_str = p_strdup(stmt->pool, guid_128_to_uuid_string(uuid, FORMAT_RECORD));
+ array_idx_set(&stmt->args, column_idx, &value_str);
+
+ if (stmt->db->v.statement_bind_uuid != NULL)
+ stmt->db->v.statement_bind_uuid(stmt, column_idx, uuid);
+}
+
#undef sql_statement_query
void sql_statement_query(struct sql_statement **_stmt,
sql_query_callback_t *callback, void *context)
case SQL_TYPE_BOOL:
field_size = sizeof(bool);
break;
+ case SQL_TYPE_UUID:
+ field_size = GUID_128_SIZE;
+ break;
}
i_assert(def->offset + field_size <= dest_size);
} else {
*((bool *)ptr) = TRUE;
break;
}
+ case SQL_TYPE_UUID: {
+ if (value != NULL)
+ guid_128_from_uuid_string(value, *((guid_128_t *)ptr));
+ break;
+ }
}
}
}
#ifndef SQL_API_H
#define SQL_API_H
+#include "guid.h"
+
struct timespec;
/* This SQL API is designed to work asynchronously. The underlying drivers
SQL_TYPE_STR,
SQL_TYPE_UINT,
SQL_TYPE_ULLONG,
- SQL_TYPE_BOOL
+ SQL_TYPE_BOOL,
+ SQL_TYPE_UUID,
};
struct sql_field_def {
unsigned int column_idx, int64_t value);
void sql_statement_bind_double(struct sql_statement *stmt,
unsigned int column_idx, double value);
+void sql_statement_bind_uuid(struct sql_statement *stmt,
+ unsigned int column_idx, const guid_128_t uuid);
void sql_statement_query(struct sql_statement **stmt,
sql_query_callback_t *callback, void *context);
#define sql_statement_query(stmt, callback, context) \