mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Added sql_odbc_driver option for mssql db
Add an option to choose the ODBC driver when sql_type is set to mssql
This commit is contained in:
parent
e4d6007293
commit
fdda572c9a
@ -137,6 +137,7 @@
|
||||
-export([sql_database/0, sql_database/1]).
|
||||
-export([sql_keepalive_interval/0, sql_keepalive_interval/1]).
|
||||
-export([sql_password/0, sql_password/1]).
|
||||
-export([sql_odbc_driver/0, sql_odbc_driver/1]).
|
||||
-export([sql_pool_size/0, sql_pool_size/1]).
|
||||
-export([sql_port/0, sql_port/1]).
|
||||
-export([sql_prepared_statements/0, sql_prepared_statements/1]).
|
||||
@ -928,6 +929,13 @@ sql_password() ->
|
||||
sql_password(Host) ->
|
||||
ejabberd_config:get_option({sql_password, Host}).
|
||||
|
||||
-spec sql_odbc_driver() -> binary().
|
||||
sql_odbc_driver() ->
|
||||
sql_odbc_driver(global).
|
||||
-spec sql_odbc_driver(global | binary()) -> binary().
|
||||
sql_odbc_driver(Host) ->
|
||||
ejabberd_config:get_option({sql_odbc_driver, Host}).
|
||||
|
||||
-spec sql_pool_size() -> pos_integer().
|
||||
sql_pool_size() ->
|
||||
sql_pool_size(global).
|
||||
|
@ -371,6 +371,8 @@ opt_type(sql_keepalive_interval) ->
|
||||
econf:timeout(second);
|
||||
opt_type(sql_password) ->
|
||||
econf:binary();
|
||||
opt_type(sql_odbc_driver) ->
|
||||
econf:binary();
|
||||
opt_type(sql_pool_size) ->
|
||||
econf:pos_int();
|
||||
opt_type(sql_port) ->
|
||||
@ -645,6 +647,7 @@ options() ->
|
||||
{sql_database, undefined},
|
||||
{sql_keepalive_interval, undefined},
|
||||
{sql_password, <<"">>},
|
||||
{sql_odbc_driver, <<"libtdsodbc.so">>}, % default is FreeTDS driver
|
||||
{sql_pool_size,
|
||||
fun(Host) ->
|
||||
case ejabberd_config:get_option({sql_type, Host}) of
|
||||
|
@ -52,7 +52,7 @@
|
||||
encode_term/1,
|
||||
decode_term/1,
|
||||
odbcinst_config/0,
|
||||
init_mssql/0,
|
||||
init_mssql/1,
|
||||
keep_alive/2,
|
||||
to_list/2,
|
||||
to_array/2]).
|
||||
@ -1107,7 +1107,7 @@ db_opts(Host) ->
|
||||
SSLOpts = get_ssl_opts(Transport, Host),
|
||||
case Type of
|
||||
mssql ->
|
||||
[mssql, <<"DRIVER=FreeTDS;SERVER=", Server/binary, ";UID=", User/binary,
|
||||
[mssql, <<"DRIVER=ODBC;SERVER=", Server/binary, ";UID=", User/binary,
|
||||
";DATABASE=", DB/binary ,";PWD=", Pass/binary,
|
||||
";PORT=", (integer_to_binary(Port))/binary ,";CLIENT_CHARSET=UTF-8;">>, Timeout];
|
||||
_ ->
|
||||
@ -1151,9 +1151,10 @@ get_ssl_opts(ssl, Host) ->
|
||||
get_ssl_opts(tcp, _) ->
|
||||
[].
|
||||
|
||||
init_mssql() ->
|
||||
ODBCINST = io_lib:fwrite("[FreeTDS]~n"
|
||||
"Driver = libtdsodbc.so~n", []),
|
||||
init_mssql(Host) ->
|
||||
Driver = ejabberd_option:sql_odbc_driver(Host),
|
||||
ODBCINST = io_lib:fwrite("[ODBC]~n"
|
||||
"Driver = ~s~n", [Driver]),
|
||||
?DEBUG("~ts:~n~ts", [odbcinst_config(), ODBCINST]),
|
||||
case filelib:ensure_dir(odbcinst_config()) of
|
||||
ok ->
|
||||
|
@ -96,7 +96,7 @@ init([Host]) ->
|
||||
sqlite ->
|
||||
check_sqlite_db(Host);
|
||||
mssql ->
|
||||
ejabberd_sql:init_mssql();
|
||||
ejabberd_sql:init_mssql(Host);
|
||||
_ ->
|
||||
ok
|
||||
end,
|
||||
|
Loading…
Reference in New Issue
Block a user