src/modules/sqlops/sqlops.c
dd6cc225
 /**
  * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com)
  *
  * This file is part of Kamailio, a free SIP server.
  *
  * Kamailio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
  * Kamailio is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
ac566990
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
dd6cc225
  */
 
2caae8fd
 /*! \file
  * \ingroup sqlops
33cdf4f3
  * \brief Kamailio SQL-operations :: Module interface
2caae8fd
  *
  * - Module: \ref sqlops
  */
 
33cdf4f3
 /*! \defgroup sqlops Kamailio :: SQL Operations
1b29ea77
  *
2caae8fd
  * The module adds support for raw SQL queries in the configuration file.
1b29ea77
  *
2caae8fd
  */
 
 
 
 
 
dd6cc225
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <unistd.h>
 #include <fcntl.h>
 
cf83221d
 #include "../../core/sr_module.h"
 #include "../../core/dprint.h"
 #include "../../core/pvar.h"
f9ca87af
 #include "../../core/kemi.h"
 
dd6cc225
 #include "sql_api.h"
 #include "sql_var.h"
486c7e18
 #include "sql_trans.h"
dd6cc225
 
 
 MODULE_VERSION
 
576ed7b9
 static int bind_sqlops(sqlops_api_t* api);
 
dd6cc225
 /** module functions */
2df43b99
 static int sql_check_connection(sql_con_t*);
dd6cc225
 static int sql_query(struct sip_msg*, char*, char*, char*);
9b62514b
 static int sql_query2(struct sip_msg*, char*, char*);
6f886339
 static int sql_query_async(struct sip_msg*, char*, char*);
f2e79b33
 static int sql_xquery(struct sip_msg *msg, char *dbl, char *query, char *res);
ab4e481b
 static int sql_pvquery(struct sip_msg *msg, char *dbl, char *query, char *res);
dd6cc225
 static int sql_rfree(struct sip_msg*, char*, char*);
ac566990
 static int mod_init(void);
dd6cc225
 static int child_init(int rank);
81fad30a
 static void destroy(void);
dd6cc225
 
 static int fixup_sql_query(void** param, int param_no);
f2e79b33
 static int fixup_sql_xquery(void** param, int param_no);
ab4e481b
 static int fixup_sql_pvquery(void** param, int param_no);
dd6cc225
 static int fixup_sql_rfree(void** param, int param_no);
 
576ed7b9
 static int sql_con_param(modparam_t type, void* val);
 static int sql_res_param(modparam_t type, void* val);
dd6cc225
 
ac566990
 extern int sqlops_tr_buf_size;
 
2df43b99
 static int sqlops_connect_mode = 0;
 
dd6cc225
 static pv_export_t mod_pvs[] = {
 	{ {"dbr", sizeof("dbr")-1}, PVT_OTHER, pv_get_dbr, 0,
 		pv_parse_dbr_name, 0, 0, 0 },
d947e752
 	{ {"sqlrows", sizeof("sqlrows")-1}, PVT_OTHER, pv_get_sqlrows, 0,
 		pv_parse_con_name, 0, 0, 0 },
dd6cc225
 	{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
 };
 
 static cmd_export_t cmds[]={
ac566990
 	{"sql_query",  (cmd_function)sql_query, 3, fixup_sql_query, 0,
7fceaf17
 		ANY_ROUTE},
ac566990
 	{"sql_query",  (cmd_function)sql_query2, 2, fixup_sql_query, 0,
7fceaf17
 		ANY_ROUTE},
ac566990
 	{"sql_query_async",  (cmd_function)sql_query_async, 2, fixup_sql_query, 0,
6f886339
 		ANY_ROUTE},
ac566990
 	{"sql_xquery",  (cmd_function)sql_xquery, 3, fixup_sql_xquery, 0,
7fceaf17
 		ANY_ROUTE},
ab4e481b
 	{"sql_pvquery",  (cmd_function)sql_pvquery, 3, fixup_sql_pvquery, 0,
7fceaf17
 		ANY_ROUTE},
ac566990
 	{"sql_result_free",  (cmd_function)sql_rfree,  1, fixup_sql_rfree, 0,
7fceaf17
 		ANY_ROUTE},
576ed7b9
 	{"bind_sqlops", (cmd_function)bind_sqlops, 0, 0, 0, 0},
dd6cc225
 	{0,0,0,0,0,0}
 };
 
 static param_export_t params[]={
827d20c2
 	{"sqlcon",  PARAM_STRING|USE_FUNC_PARAM, (void*)sql_con_param},
 	{"sqlres",  PARAM_STRING|USE_FUNC_PARAM, (void*)sql_res_param},
ac566990
 	{"tr_buf_size",     PARAM_INT,   &sqlops_tr_buf_size},
2df43b99
 	{"connect_mode",    PARAM_INT,   &sqlops_connect_mode},
dd6cc225
 	{0,0,0}
 };
 
486c7e18
 static tr_export_t mod_trans[] = {
 	{ {"sql", sizeof("sql")-1}, tr_parse_sql },
 	{ { 0, 0 }, 0 }
 };
 
dd6cc225
 
 /** module exports */
 struct module_exports exports= {
8a87b0b8
 	"sqlops",   /* module name */
dd6cc225
 	DEFAULT_DLFLAGS, /* dlopen flags */
8a87b0b8
 	cmds,       /* exported functions */
 	params,     /* exported parameters */
 	0,          /* exported rpc functions */
dd6cc225
 	mod_pvs,    /* exported pseudo-variables */
8a87b0b8
 	0,          /* response handling function */
 	mod_init,   /* module init function */
 	child_init, /* per-child init function */
 	destroy     /* module destroy function */
dd6cc225
 };
 
ac566990
 static int mod_init(void)
 {
 	if(sqlops_tr_buffer_init()<0) {
 		return -1;
 	}
 	return 0;
 }
 
dd6cc225
 static int child_init(int rank)
 {
2df43b99
 	int ret;
82a5ef65
 	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
dd6cc225
 		return 0;
2df43b99
 
 	ret = sql_connect((sqlops_connect_mode == 1)?1:0);
 
 	LM_DBG("SQL result: %d \n", ret);
 
 	if (ret != 0 && sqlops_connect_mode == 1)
 	{
 		LM_INFO("SQL result: %d but start_without_db_connection enabled - proceed\n",
 				ret);
 		return 0;
 
 	} else {
 		return ret;
 	}
dd6cc225
 }
 
 /**
  * destroy function
  */
81fad30a
 static void destroy(void)
dd6cc225
 {
 	sql_destroy();
 }
 
576ed7b9
 /**
  * parse sqlcon module parameter
  */
 int sql_con_param(modparam_t type, void *val)
dd6cc225
 {
 	if(val==NULL)
 		goto error;
 
 	return sql_parse_param((char*)val);
 error:
 	return -1;
 
 }
 
576ed7b9
 /**
  * parse sqlres module parameter
  */
 int sql_res_param(modparam_t type, void *val)
 {
 	sql_result_t *res = NULL;
 	str s;
 
 	if(val==NULL)
 	{
0d247e7b
 		LM_ERR("invalid parameter\n");
576ed7b9
 		goto error;
 	}
 
 	s.s = (char*)val;
 	s.len = strlen(s.s);
 
 	res = sql_get_result(&s);
 	if(res==NULL)
 	{
897f58fd
 		LM_ERR("invalid result container [%s]\n", s.s);
576ed7b9
 		goto error;
 	}
 	return 0;
 error:
 	return -1;
 }
 
2df43b99
 static int sql_check_connection(sql_con_t *dbl)
 {
 	if (dbl->dbh != NULL) {
 		return 0;
 	}
 
 	if(sqlops_connect_mode != 1) {
 		LM_CRIT("no database handle with reconnect disabled\n");
 		return -1;
 	}
 
     LM_DBG("try to establish SQL connection\n");
 	if(sql_reconnect(dbl)<0) {
 		LM_ERR("failed to connect to database\n");
 		return -1;
 	}
 	return 0;
 }
 
576ed7b9
 /**
  *
  */
dd6cc225
 static int sql_query(struct sip_msg *msg, char *dbl, char *query, char *res)
 {
576ed7b9
 	str sq;
2df43b99
 	if(sql_check_connection((sql_con_t*)dbl)<0) {
 		LM_ERR("invalid connection to database");
 		return -2;
 	}
 	if(pv_printf_s(msg, (pv_elem_t*)query, &sq)!=0) {
576ed7b9
 		LM_ERR("cannot print the sql query\n");
 		return -1;
 	}
 	return sql_do_query((sql_con_t*)dbl, &sq, (sql_result_t*)res);
dd6cc225
 }
 
9b62514b
 static int sql_query2(struct sip_msg *msg, char *dbl, char *query)
 {
 	return sql_query(msg, dbl, query, NULL);
 }
 
6f886339
 static int sql_query_async(struct sip_msg *msg, char *dbl, char *query)
 {
 	str sq;
2df43b99
 	if(sql_check_connection((sql_con_t*)dbl)<0) {
 		LM_ERR("invalid connection to database");
 		return -2;
 	}
6f886339
 	if(pv_printf_s(msg, (pv_elem_t*)query, &sq)!=0)
 	{
 		LM_ERR("cannot print the sql query\n");
 		return -1;
 	}
 	return sql_do_query_async((sql_con_t*)dbl, &sq);
 }
 
 
f2e79b33
 /**
  *
  */
 static int sql_xquery(struct sip_msg *msg, char *dbl, char *query, char *res)
 {
2df43b99
 	if(sql_check_connection((sql_con_t*)dbl)<0) {
 		LM_ERR("invalid connection to database");
 		return -2;
 	}
c1c19d84
 	return sql_do_xquery(msg, (sql_con_t*)dbl, (pv_elem_t*)query, (pv_elem_t*)res);
f2e79b33
 }
 
ab4e481b
 /**
  *
  */
 static int sql_pvquery(struct sip_msg *msg, char *dbl, char *query, char *res)
 {
2df43b99
 	if(sql_check_connection((sql_con_t*)dbl)<0) {
 		LM_ERR("invalid connection to database");
 		return -2;
 	}
ab4e481b
 	return sql_do_pvquery(msg, (sql_con_t*)dbl, (pv_elem_t*)query, (pvname_list_t*)res);
 }
 
576ed7b9
 /**
  *
  */
dd6cc225
 static int sql_rfree(struct sip_msg *msg, char *res, char *s2)
 {
 	sql_reset_result((sql_result_t*)res);
 	return 1;
 }
 
576ed7b9
 /**
  *
  */
dd6cc225
 static int fixup_sql_query(void** param, int param_no)
 {
 	sql_con_t *con = NULL;
 	pv_elem_t *query = NULL;
 	sql_result_t *res = NULL;
 	str s;
 
 	s.s = (char*)(*param);
 	s.len = strlen(s.s);
 
 	if (param_no==1) {
 		con = sql_get_connection(&s);
 		if(con==NULL)
 		{
 			LM_ERR("invalid connection [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)con;
 	} else if (param_no==2) {
 		if(pv_parse_format(&s, &query)<0)
 		{
 			LM_ERR("invalid query string [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)query;
 	} else if (param_no==3) {
 		res = sql_get_result(&s);
 		if(res==NULL)
 		{
897f58fd
 			LM_ERR("invalid result container [%s]\n", s.s);
dd6cc225
 			return E_UNSPEC;
 		}
 		*param = (void*)res;
 	}
 	return 0;
 }
 
f2e79b33
 /**
  *
  */
 static int fixup_sql_xquery(void** param, int param_no)
 {
 	sql_con_t *con = NULL;
 	pv_elem_t *pv = NULL;
 	str s;
 
 	s.s = (char*)(*param);
 	s.len = strlen(s.s);
 
 	if (param_no==1) {
 		con = sql_get_connection(&s);
 		if(con==NULL)
 		{
 			LM_ERR("invalid connection [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)con;
 	} else if (param_no==2) {
 		if(pv_parse_format(&s, &pv)<0)
 		{
 			LM_ERR("invalid query string [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)pv;
 	} else if (param_no==3) {
 		if(pv_parse_format(&s, &pv)<0)
 		{
 			LM_ERR("invalid result [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)pv;
 	}
 	return 0;
 }
 
ab4e481b
 /**
  *
  */
 static int fixup_sql_pvquery(void** param, int param_no)
 {
 	sql_con_t *con = NULL;
 	pv_elem_t *pv = NULL;
 	pvname_list_t *res = NULL;
 	pvname_list_t *pvl = NULL;
 	str s;
 	int i;
 
 	if(*param == NULL)
 	{
 		LM_ERR("missing parameter %d\n", param_no);
 		return E_UNSPEC;
 	}
 	s.s = (char*)(*param);
 	s.len = strlen(s.s);
 
 	if (param_no==1) {
 		con = sql_get_connection(&s);
 		if(con==NULL)
 		{
 			LM_ERR("invalid connection [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)con;
 	} else if (param_no==2) {
 		if(pv_parse_format(&s, &pv)<0)
 		{
 			LM_ERR("invalid query string [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		*param = (void*)pv;
 	} else if (param_no==3) {
 		/* parse result variables into list of pv_spec_t's */
 		res = parse_pvname_list(&s, 0);
 		if(res==NULL)
 		{
 			LM_ERR("invalid result parameter [%s]\n", s.s);
 			return E_UNSPEC;
 		}
 		/* check if all result variables are writable */
 		pvl = res;
 		i = 1;
 		while (pvl) {
 			if (pvl->sname.setf == NULL)
 			{
 				LM_ERR("result variable [%d] is read-only\n", i);
8f460d16
 				free_pvname_list(res);
ab4e481b
 				return E_UNSPEC;
 			}
 			i++;
 			pvl = pvl->next;
 		}
 		*param = (void*)res;
 		return 0;
 	}
 	return 0;
 }
 
576ed7b9
 /**
  *
  */
dd6cc225
 static int fixup_sql_rfree(void** param, int param_no)
 {
 	sql_result_t *res = NULL;
 	str s;
 
 	s.s = (char*)(*param);
 	s.len = strlen(s.s);
 
 	if (param_no==1) {
 		res = sql_get_result(&s);
 		if(res==NULL)
 		{
897f58fd
 			LM_ERR("invalid result container [%s]\n", s.s);
dd6cc225
 			return E_UNSPEC;
 		}
 		*param = (void*)res;
 	}
 	return 0;
 }
 
576ed7b9
 /**
  * @brief bind functions to SQLOPS API structure
  */
 static int bind_sqlops(sqlops_api_t* api)
 {
 	if (!api) {
 		ERR("Invalid parameter value\n");
 		return -1;
 	}
 	api->query = sqlops_do_query;
 	api->value = sqlops_get_value;
 	api->is_null = sqlops_is_null;
 	api->column  = sqlops_get_column;
 	api->reset   = sqlops_reset_result;
 	api->nrows   = sqlops_num_rows;
 	api->ncols   = sqlops_num_columns;
7fceaf17
 	api->xquery  = sqlops_do_xquery;
576ed7b9
 
 	return 0;
 }
f9ca87af
 
 static int ki_sqlops_query(sip_msg_t *msg, str *scon, str *squery, str *sres)
 {
 	return sqlops_do_query(scon, squery, sres);
 }
 
3b2a0a84
 static int ki_sqlops_pvquery(sip_msg_t *msg, str *scon, str *squery, str *sres)
 {
 	pv_elem_t *query = NULL;
 	pvname_list_t *pv_res = NULL;
 	pvname_list_t *pvl = NULL;
 	sql_con_t *con = NULL;
 	int i, res;
 
 	if (scon == NULL || scon->s == NULL || scon->len<=0) {
 		LM_ERR("invalid connection name\n");
 		return -1;
 	}
 
 	con = sql_get_connection(scon);
 	if(con==NULL) {
 		LM_ERR("invalid connection [%.*s]\n", scon->len, scon->s);
 		return -1;
 	}
 
 	if(pv_parse_format(squery, &query)<0)
 	{
 		LM_ERR("invalid query string [%s]\n", squery->s);
 		return -1;
 	}
 
 	/* parse result variables into list of pv_spec_t's */
 	pv_res = parse_pvname_list(sres, 0);
 	if(pv_res==NULL)
 	{
 		LM_ERR("invalid result parameter [%s]\n", sres->s);
 		pv_elem_free_all(query);
 		return -1;
 	}
 	/* check if all result variables are writable */
 	pvl = pv_res;
 	i = 1;
 	while (pvl) {
 		if (pvl->sname.setf == NULL)
 		{
 			LM_ERR("result variable [%d] is read-only\n", i);
 			pv_elem_free_all(query);
 			free_pvname_list(pv_res);
 			return -1;
 		}
 		i++;
 		pvl = pvl->next;
 	}
 	res = sql_do_pvquery(msg, con, query, pv_res);
 
 	pv_elem_free_all(query);
 	free_pvname_list(pv_res);
 	return res;
 }
 
127beb37
 static int ki_sqlops_query_async(sip_msg_t *msg, str *scon, str *squery)
 {
 	sql_con_t *con = NULL;
 
 	if (scon == NULL || scon->s == NULL || scon->len<=0) {
 		LM_ERR("invalid connection name\n");
 		return -1;
 	}
 
 	con = sql_get_connection(scon);
 	if(con==NULL) {
 		LM_ERR("invalid connection [%.*s]\n", scon->len, scon->s);
 		return -1;
 	}
 
 	return sql_do_query_async(con, squery);
 }
 
f9ca87af
 static int ki_sqlops_reset_result(sip_msg_t *msg, str *sres)
 {
 	sqlops_reset_result(sres);
 	return 1;
 }
 
684f98ac
 static int ki_sqlops_num_rows(sip_msg_t *msg, str *sres)
f9ca87af
 {
 	return sqlops_num_rows(sres);
 }
 
684f98ac
 static int ki_sqlops_num_columns(sip_msg_t *msg, str *sres)
f9ca87af
 {
 	return sqlops_num_columns(sres);
 }
 
 static int ki_sqlops_is_null(sip_msg_t *msg, str *sres, int i, int j)
 {
 	return sqlops_is_null(sres, i, j);
 }
 
b9da65bc
 /**
  *
  */
 static sr_kemi_xval_t _ksr_kemi_sqlops_xval = {0};
 
 
 /**
  *
  */
855c06f4
 static sr_kemi_xval_t* ki_sqlops_result_get_mode(sip_msg_t *msg, str *resid,
 		int row, int col, int rmode)
b9da65bc
 {
 	sql_result_t *res = NULL;
 
 	memset(&_ksr_kemi_sqlops_xval, 0, sizeof(sr_kemi_xval_t));
 
 	if (resid == NULL || resid->s == NULL || resid->len == 0) {
 		LM_ERR("invalid result name\n");
855c06f4
 		sr_kemi_xval_null(&_ksr_kemi_sqlops_xval, rmode);
b9da65bc
 		return &_ksr_kemi_sqlops_xval;
 	}
 
 	res = sql_get_result(resid);
 	if(res==NULL) {
 		LM_ERR("invalid result container [%.*s]\n", resid->len, resid->s);
855c06f4
 		sr_kemi_xval_null(&_ksr_kemi_sqlops_xval, rmode);
b9da65bc
 		return &_ksr_kemi_sqlops_xval;
 	}
 
 	if(row >= res->nrows) {
855c06f4
 		sr_kemi_xval_null(&_ksr_kemi_sqlops_xval, rmode);
b9da65bc
 		return &_ksr_kemi_sqlops_xval;
 	}
 	if(col >= res->ncols) {
855c06f4
 		sr_kemi_xval_null(&_ksr_kemi_sqlops_xval, rmode);
b9da65bc
 		return &_ksr_kemi_sqlops_xval;
 	}
 	if(res->vals[row][col].flags&PV_VAL_NULL) {
855c06f4
 		sr_kemi_xval_null(&_ksr_kemi_sqlops_xval, rmode);
b9da65bc
 		return &_ksr_kemi_sqlops_xval;
 	}
 	if(res->vals[row][col].flags&PV_VAL_INT) {
855c06f4
 		_ksr_kemi_sqlops_xval.vtype = SR_KEMIP_INT;
b9da65bc
 		_ksr_kemi_sqlops_xval.v.n = res->vals[row][col].value.n;
 		return &_ksr_kemi_sqlops_xval;
 	}
 	_ksr_kemi_sqlops_xval.vtype = SR_KEMIP_STR;
 	_ksr_kemi_sqlops_xval.v.s = res->vals[row][col].value.s;
 	return &_ksr_kemi_sqlops_xval;
 }
 
855c06f4
 /**
  *
  */
 static sr_kemi_xval_t* ki_sqlops_result_get(sip_msg_t *msg, str *resid,
 		int row, int col)
 {
 	return ki_sqlops_result_get_mode(msg, resid, row, col,
 			SR_KEMI_XVAL_NULL_NONE);
 }
 
 /**
  *
  */
 static sr_kemi_xval_t* ki_sqlops_result_gete(sip_msg_t *msg, str *resid,
 		int row, int col)
 {
 	return ki_sqlops_result_get_mode(msg, resid, row, col,
 			SR_KEMI_XVAL_NULL_EMPTY);
 }
 
 /**
  *
  */
 static sr_kemi_xval_t* ki_sqlops_result_getz(sip_msg_t *msg, str *resid,
 		int row, int col)
 {
 	return ki_sqlops_result_get_mode(msg, resid, row, col,
 			SR_KEMI_XVAL_NULL_ZERO);
 }
 
f9ca87af
 /**
  *
  */
 /* clang-format off */
 static sr_kemi_t sr_kemi_sqlops_exports[] = {
 	{ str_init("sqlops"), str_init("sql_query"),
 		SR_KEMIP_INT, ki_sqlops_query,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	{ str_init("sqlops"), str_init("sql_result_free"),
 		SR_KEMIP_INT, ki_sqlops_reset_result,
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	{ str_init("sqlops"), str_init("sql_num_rows"),
 		SR_KEMIP_INT, ki_sqlops_num_rows,
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	{ str_init("sqlops"), str_init("sql_num_columns"),
 		SR_KEMIP_INT, ki_sqlops_num_columns,
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	{ str_init("sqlops"), str_init("sql_is_null"),
 		SR_KEMIP_INT, ki_sqlops_is_null,
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_INT,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
3b2a0a84
 	{ str_init("sqlops"), str_init("sql_pvquery"),
 		SR_KEMIP_INT, ki_sqlops_pvquery,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
f9ca87af
 	{ str_init("sqlops"), str_init("sql_xquery"),
 		SR_KEMIP_INT, sqlops_do_xquery,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
127beb37
 	{ str_init("sqlops"), str_init("sql_query_async"),
 		SR_KEMIP_INT, ki_sqlops_query_async,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
b9da65bc
 	{ str_init("sqlops"), str_init("sql_result_get"),
 		SR_KEMIP_XVAL, ki_sqlops_result_get,
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_INT,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
855c06f4
 	{ str_init("sqlops"), str_init("sql_result_gete"),
 		SR_KEMIP_XVAL, ki_sqlops_result_gete,
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_INT,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	{ str_init("sqlops"), str_init("sql_result_getz"),
 		SR_KEMIP_XVAL, ki_sqlops_result_getz,
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_INT,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
f9ca87af
 
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };
 /* clang-format on */
 
 /**
  *
  */
 int mod_register(char *path, int *dlflags, void *p1, void *p2)
 {
 	sr_kemi_modules_add(sr_kemi_sqlops_exports);
 	return register_trans_mod(path, mod_trans);
684f98ac
 }