24#ifndef __M_SQL_DRIVER_H__
25#define __M_SQL_DRIVER_H__
29#include <mstdlib/base/m_defs.h>
30#include <mstdlib/base/m_types.h>
31#include <mstdlib/mstdlib_sql.h>
33#include <mstdlib/sql/m_module.h>
57#define M_SQL_DRIVER_VERSION 0x0100
65struct M_sql_driver_connpool;
71struct M_sql_driver_conn;
77struct M_sql_driver_stmt;
184typedef char *(*M_sql_driver_cb_queryformat_t)(
M_sql_conn_t *conn,
const char *query,
size_t num_params,
size_t num_rows,
char *error,
size_t error_size);
343typedef char *(*M_sql_driver_cb_rewrite_indexname_t)(
M_sql_connpool_t *pool,
const char *index_name);
433M_API
char *
M_sql_driver_queryformat(
const char *query, M_uint32 flags,
size_t num_params,
size_t num_rows,
char *error,
size_t error_size);
738#ifdef MSTDLIB_SQL_STATIC_MODULE
741# define M_SQL_API M_DLL_EXPORT
748#define M_SQL_DRIVER(name) \
749 M_SQL_API M_sql_driver_t *M_sql_get_driver_##name(void); \
750 M_sql_driver_t *M_sql_get_driver_##name(void) \
752 return &M_sql_##name; \
struct M_buf M_buf_t
Definition: m_buf.h:77
struct M_hash_dict M_hash_dict_t
Definition: m_hash_dict.h:52
void * M_module_handle_t
Definition: m_module.h:52
struct M_sql_connpool M_sql_connpool_t
Definition: m_sql.h:335
M_sql_connstr_type_t type
Definition: m_sql_driver.h:449
M_sql_driver_cb_rewrite_indexname_t cb_rewrite_indexname
Definition: m_sql_driver.h:389
M_sql_driver_cb_queryformat_t cb_queryformat
Definition: m_sql_driver.h:376
M_sql_driver_cb_execute_t cb_execute
Definition: m_sql_driver.h:380
M_sql_driver_cb_queryrowcnt_t cb_queryrowcnt
Definition: m_sql_driver.h:377
M_uint16 port
Definition: m_sql_driver.h:461
M_sql_driver_cb_fetch_t cb_fetch
Definition: m_sql_driver.h:381
M_bool required
Definition: m_sql_driver.h:450
M_uint16 driver_sys_version
Definition: m_sql_driver.h:361
M_sql_driver_cb_createpool_t cb_createpool
Definition: m_sql_driver.h:370
const char * display_name
Definition: m_sql_driver.h:363
const char * name
Definition: m_sql_driver.h:448
M_sql_driver_cb_connect_t cb_connect
Definition: m_sql_driver.h:372
M_sql_driver_cb_prepare_destroy_t cb_prepare_destroy
Definition: m_sql_driver.h:379
M_sql_driver_cb_disconnect_t cb_disconnect
Definition: m_sql_driver.h:375
M_module_handle_t handle
Definition: m_sql_driver.h:390
M_sql_driver_cb_rollback_t cb_rollback
Definition: m_sql_driver.h:383
M_sql_driver_cb_begin_t cb_begin
Definition: m_sql_driver.h:382
M_sql_driver_cb_commit_t cb_commit
Definition: m_sql_driver.h:384
const char * version
Definition: m_sql_driver.h:364
M_sql_driver_cb_connect_runonce_t cb_connect_runonce
Definition: m_sql_driver.h:374
M_sql_driver_cb_datatype_t cb_datatype
Definition: m_sql_driver.h:385
const char * name
Definition: m_sql_driver.h:362
M_sql_driver_cb_append_bitop_t cb_append_bitop
Definition: m_sql_driver.h:388
M_sql_driver_cb_destroypool_t cb_destroypool
Definition: m_sql_driver.h:371
size_t max_len
Definition: m_sql_driver.h:452
M_sql_driver_cb_append_updlock_t cb_append_updlock
Definition: m_sql_driver.h:387
M_sql_driver_cb_destroy_t cb_destroy
Definition: m_sql_driver.h:369
M_sql_driver_cb_createtable_suffix_t cb_createtable_suffix
Definition: m_sql_driver.h:386
M_sql_driver_cb_serverversion_t cb_serverversion
Definition: m_sql_driver.h:373
M_sql_driver_cb_init_t cb_init
Definition: m_sql_driver.h:368
M_sql_driver_cb_flags_t cb_flags
Definition: m_sql_driver.h:367
size_t min_len
Definition: m_sql_driver.h:451
M_sql_driver_cb_prepare_t cb_prepare
Definition: m_sql_driver.h:378
size_t M_sql_driver_stmt_bind_rows(M_sql_stmt_t *stmt)
M_sql_driver_bitop_caps_t
Definition: m_sql_driver.h:702
void(* M_sql_driver_cb_disconnect_t)(M_sql_driver_conn_t *conn)
Definition: m_sql_driver.h:167
const char * M_sql_driver_stmt_bind_get_text(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_bool M_sql_driver_append_bitop(M_sql_driver_bitop_caps_t caps, M_buf_t *query, M_sql_query_bitop_t op, const char *exp1, const char *exp2)
M_sql_error_t(* M_sql_driver_cb_begin_t)(M_sql_conn_t *conn, M_sql_isolation_t isolation, char *error, size_t error_size)
Definition: m_sql_driver.h:254
M_sql_error_t(* M_sql_driver_cb_connect_runonce_t)(M_sql_conn_t *conn, M_sql_driver_connpool_t *dpool, M_bool is_first_in_pool, M_bool is_readonly, char *error, size_t error_size)
Definition: m_sql_driver.h:161
void(* M_sql_driver_cb_destroy_t)(void)
Definition: m_sql_driver.h:97
void(* M_sql_driver_cb_createtable_suffix_t)(M_sql_connpool_t *pool, M_buf_t *query)
Definition: m_sql_driver.h:304
M_bool M_sql_driver_conn_is_readonly(M_sql_conn_t *conn)
size_t M_sql_driver_stmt_get_requested_row_cnt(M_sql_stmt_t *stmt)
M_bool M_sql_driver_conn_in_trans(M_sql_conn_t *conn)
size_t M_sql_driver_conn_get_id(M_sql_conn_t *conn)
size_t(* M_sql_driver_cb_queryrowcnt_t)(M_sql_conn_t *conn, size_t num_params, size_t num_rows)
Definition: m_sql_driver.h:194
size_t M_sql_driver_stmt_bind_get_curr_col_size(M_sql_stmt_t *stmt, size_t row, size_t col)
M_sql_driver_flags_t
Definition: m_sql_driver.h:346
M_bool M_sql_driver_stmt_bind_isnull(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_bool(* M_sql_driver_cb_append_bitop_t)(M_sql_connpool_t *pool, M_buf_t *query, M_sql_query_bitop_t op, const char *exp1, const char *exp2)
Definition: m_sql_driver.h:330
size_t M_sql_driver_stmt_bind_get_text_len(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_bool M_sql_driver_stmt_result_set_col_type(M_sql_stmt_t *stmt, size_t col, M_sql_data_type_t type, size_t max_size)
M_bool M_sql_driver_stmt_bind_get_bool(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_error_t(* M_sql_driver_cb_execute_t)(M_sql_conn_t *conn, M_sql_stmt_t *stmt, size_t *rows_executed, char *error, size_t error_size)
Definition: m_sql_driver.h:230
M_sql_data_type_t M_sql_driver_stmt_bind_get_type(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_conn_state_t
Definition: m_sql_driver.h:466
M_int16 * M_sql_driver_stmt_bind_get_int16_addr(M_sql_stmt_t *stmt, size_t row, size_t idx)
const char * M_sql_driver_conn_get_password(M_sql_conn_t *conn)
const char *(* M_sql_driver_cb_serverversion_t)(M_sql_driver_conn_t *conn)
Definition: m_sql_driver.h:142
void(* M_sql_driver_cb_destroypool_t)(M_sql_driver_connpool_t *dpool)
Definition: m_sql_driver.h:125
M_int32 M_sql_driver_stmt_bind_get_int32(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_conn_state_t M_sql_conn_get_state(M_sql_conn_t *conn)
M_sql_driver_stmt_t * M_sql_driver_stmt_get_stmt(M_sql_stmt_t *stmt)
size_t M_sql_driver_stmt_bind_cnt(M_sql_stmt_t *stmt)
M_sql_connpool_t * M_sql_driver_conn_get_pool(M_sql_conn_t *conn)
M_sql_driver_connpool_t * M_sql_driver_conn_get_dpool(M_sql_conn_t *conn)
M_sql_error_t(* M_sql_driver_cb_fetch_t)(M_sql_conn_t *conn, M_sql_stmt_t *stmt, char *error, size_t error_size)
Definition: m_sql_driver.h:241
const char * M_sql_driver_isolation2str(M_sql_isolation_t type)
M_bool M_sql_driver_stmt_result_set_affected_rows(M_sql_stmt_t *stmt, size_t cnt)
M_bool M_sql_driver_stmt_result_set_col_name(M_sql_stmt_t *stmt, size_t col, const char *name)
M_sql_error_t(* M_sql_driver_cb_rollback_t)(M_sql_conn_t *conn)
Definition: m_sql_driver.h:269
size_t M_sql_driver_stmt_bind_get_binary_len(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_int64 * M_sql_driver_stmt_bind_get_int64_addr(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_error_t M_sql_conn_execute(M_sql_conn_t *conn, M_sql_stmt_t *stmt)
M_int32 * M_sql_driver_stmt_bind_get_int32_addr(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_driver_conn_t * M_sql_driver_conn_get_conn(M_sql_conn_t *conn)
M_sql_data_type_t M_sql_driver_stmt_bind_get_col_type(M_sql_stmt_t *stmt, size_t idx)
struct M_sql_driver_connpool M_sql_driver_connpool_t
Definition: m_sql_driver.h:68
M_sql_isolation_t M_sql_driver_str2isolation(const char *str)
struct M_sql_driver_stmt M_sql_driver_stmt_t
Definition: m_sql_driver.h:80
M_bool(* M_sql_driver_cb_init_t)(char *error, size_t error_size)
Definition: m_sql_driver.h:91
void(* M_sql_driver_cb_append_updlock_t)(M_sql_connpool_t *pool, M_buf_t *query, M_sql_query_updlock_type_t type, const char *table_name)
Definition: m_sql_driver.h:316
size_t M_sql_driver_stmt_bind_get_max_col_size(M_sql_stmt_t *stmt, size_t idx)
M_sql_error_t(* M_sql_driver_cb_prepare_t)(M_sql_driver_stmt_t **driver_stmt, M_sql_conn_t *conn, M_sql_stmt_t *stmt, char *error, size_t error_size)
Definition: m_sql_driver.h:208
M_sql_driver_updlock_caps_t
Definition: m_sql_driver.h:683
void M_sql_driver_append_updlock(M_sql_driver_updlock_caps_t caps, M_buf_t *query, M_sql_query_updlock_type_t type, const char *table_name)
M_sql_error_t(* M_sql_driver_cb_commit_t)(M_sql_conn_t *conn, char *error, size_t error_size)
Definition: m_sql_driver.h:281
const char * M_sql_driver_stmt_get_query(M_sql_stmt_t *stmt)
M_bool(* M_sql_driver_cb_datatype_t)(M_sql_connpool_t *pool, M_buf_t *buf, M_sql_data_type_t type, size_t max_len, M_bool is_cast)
Definition: m_sql_driver.h:294
M_sql_driver_connpool_t * M_sql_driver_pool_get_dpool(M_sql_connpool_t *pool)
struct M_sql_driver_conn M_sql_driver_conn_t
Definition: m_sql_driver.h:74
M_sql_driver_flags_t(* M_sql_driver_cb_flags_t)(M_sql_conn_t *conn)
Definition: m_sql_driver.h:356
const char * M_sql_driver_pool_get_password(M_sql_connpool_t *pool)
const char * M_sql_driver_conn_get_username(M_sql_conn_t *conn)
M_bool M_sql_driver_stmt_result_set_num_cols(M_sql_stmt_t *stmt, size_t cnt)
M_bool M_sql_driver_validate_connstr(const M_hash_dict_t *conndict, const M_sql_connstr_params_t *params, char *error, size_t error_size)
char *(* M_sql_driver_cb_rewrite_indexname_t)(M_sql_connpool_t *pool, const char *index_name)
Definition: m_sql_driver.h:343
const char * M_sql_driver_pool_get_username(M_sql_connpool_t *pool)
void(* M_sql_driver_cb_prepare_destroy_t)(M_sql_driver_stmt_t *stmt)
Definition: m_sql_driver.h:214
M_int16 M_sql_driver_stmt_bind_get_int16(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_error_t(* M_sql_driver_cb_connect_t)(M_sql_driver_conn_t **conn, M_sql_connpool_t *pool, M_bool is_readonly_pool, size_t host_idx, char *error, size_t error_size)
Definition: m_sql_driver.h:136
M_sql_connstr_type_t
Definition: m_sql_driver.h:436
M_buf_t * M_sql_driver_stmt_result_col_start(M_sql_stmt_t *stmt)
char *(* M_sql_driver_cb_queryformat_t)(M_sql_conn_t *conn, const char *query, size_t num_params, size_t num_rows, char *error, size_t error_size)
Definition: m_sql_driver.h:184
struct M_sql_conn M_sql_conn_t
Definition: m_sql_driver.h:62
M_bool(* M_sql_driver_cb_createpool_t)(M_sql_driver_connpool_t **dpool, M_sql_connpool_t *pool, M_bool is_readonly, const M_hash_dict_t *conndict, size_t *num_hosts, char *error, size_t error_size)
Definition: m_sql_driver.h:119
M_int64 M_sql_driver_stmt_bind_get_int64(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_sql_stmt_t * M_sql_conn_execute_simple(M_sql_conn_t *conn, const char *query, M_bool skip_sanity_checks)
void M_sql_driver_trace_message(M_bool is_debug, M_sql_connpool_t *pool, M_sql_conn_t *conn, M_sql_error_t err, const char *msg)
M_bool M_sql_driver_stmt_result_row_finish(M_sql_stmt_t *stmt)
const M_uint8 * M_sql_driver_stmt_bind_get_binary(M_sql_stmt_t *stmt, size_t row, size_t idx)
M_bool * M_sql_driver_stmt_bind_get_bool_addr(M_sql_stmt_t *stmt, size_t row, size_t idx)
char * M_sql_driver_queryformat(const char *query, M_uint32 flags, size_t num_params, size_t num_rows, char *error, size_t error_size)
M_sql_hostport_t * M_sql_driver_parse_hostport(const char *hostport, M_uint16 default_port, size_t *out_len, char *error, size_t error_size)
M_sql_driver_queryformat_flags_t
Definition: m_sql_driver.h:395
@ M_SQL_DRIVER_BITOP_CAP_FUNC
Definition: m_sql_driver.h:704
@ M_SQL_DRIVER_BITOP_CAP_OP_CAST_BIGINT
Definition: m_sql_driver.h:705
@ M_SQL_DRIVER_BITOP_CAP_OP
Definition: m_sql_driver.h:703
@ M_SQL_DRIVER_FLAG_NONE
Definition: m_sql_driver.h:347
@ M_SQL_DRIVER_FLAG_UNIQUEINDEX_NOTNULL_WHERE
Definition: m_sql_driver.h:348
@ M_SQL_CONN_STATE_OK
Definition: m_sql_driver.h:467
@ M_SQL_CONN_STATE_FAILED
Definition: m_sql_driver.h:469
@ M_SQL_CONN_STATE_ROLLBACK
Definition: m_sql_driver.h:468
@ M_SQL_DRIVER_UPDLOCK_CAP_MSSQL
Definition: m_sql_driver.h:686
@ M_SQL_DRIVER_UPDLOCK_CAP_FORUPDATEOF
Definition: m_sql_driver.h:687
@ M_SQL_DRIVER_UPDLOCK_CAP_FORUPDATE
Definition: m_sql_driver.h:685
@ M_SQL_DRIVER_UPDLOCK_CAP_NONE
Definition: m_sql_driver.h:684
@ M_SQL_CONNSTR_TYPE_BOOL
Definition: m_sql_driver.h:437
@ M_SQL_CONNSTR_TYPE_NUM
Definition: m_sql_driver.h:438
@ M_SQL_CONNSTR_TYPE_ALPHANUM
Definition: m_sql_driver.h:440
@ M_SQL_CONNSTR_TYPE_ALPHA
Definition: m_sql_driver.h:439
@ M_SQL_CONNSTR_TYPE_ANY
Definition: m_sql_driver.h:441
@ M_SQL_DRIVER_QUERYFORMAT_TERMINATOR
Definition: m_sql_driver.h:397
@ M_SQL_DRIVER_QUERYFORMAT_ENUMPARAM_COLON
Definition: m_sql_driver.h:400
@ M_SQL_DRIVER_QUERYFORMAT_INSERT_ONCONFLICT_DONOTHING
Definition: m_sql_driver.h:407
@ M_SQL_DRIVER_QUERYFORMAT_MULITVALUEINSERT_CD
Definition: m_sql_driver.h:402
@ M_SQL_DRIVER_QUERYFORMAT_NORMAL
Definition: m_sql_driver.h:396
@ M_SQL_DRIVER_QUERYFORMAT_ENUMPARAM_DOLLAR
Definition: m_sql_driver.h:398
Definition: m_sql_driver.h:447
Definition: m_sql_driver.h:360
Definition: m_sql_driver.h:459
M_sql_error_t
Definition: m_sql.h:190
M_sql_data_type_t
Definition: m_sql.h:256
M_sql_query_bitop_t
Definition: m_sql.h:706
M_sql_query_updlock_type_t
Definition: m_sql.h:623
struct M_sql_stmt M_sql_stmt_t
Definition: m_sql_stmt.h:46
M_sql_isolation_t
Definition: m_sql_trans.h:53