mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
* src/odbc/ejabberd_odbc.erl: ejabberd admin can now choose the
relational database port to user from ejabberd configuration file (EJAB-195). * src/doc/guide.tex: Likewise. SVN Revision: 740
This commit is contained in:
parent
0be3fe1377
commit
48c073abd2
@ -1,3 +1,10 @@
|
|||||||
|
2007-03-10 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
|
* src/odbc/ejabberd_odbc.erl: ejabberd admin can now choose the
|
||||||
|
relational database port to user from ejabberd configuration
|
||||||
|
file (EJAB-195).
|
||||||
|
* src/doc/guide.tex: Likewise.
|
||||||
|
|
||||||
2007-03-02 Mickael Remond <mickael.remond@process-one.net>
|
2007-03-02 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
* src/mod_muc/mod_muc_log.erl: Fix wrong return on check access log.
|
* src/mod_muc/mod_muc_log.erl: Fix wrong return on check access log.
|
||||||
|
@ -1037,6 +1037,20 @@ parameter:
|
|||||||
{odbc_server, {mysql, "localhost", "test", "root", "password"}}.
|
{odbc_server, {mysql, "localhost", "test", "root", "password"}}.
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
|
Optionally, it is possible to define the MySQL port to use. This
|
||||||
|
option is only useful, in very rare cases, when you are not running
|
||||||
|
MySQL with the default port setting. The \term{mysql} parameter
|
||||||
|
can thus take the following form:
|
||||||
|
\begin{verbatim}
|
||||||
|
{mysql, "Server", Port, "Database", "Username", "Password"}
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
The \term{Port} value should be an integer, without quotes. For example:
|
||||||
|
\begin{verbatim}
|
||||||
|
{odbc_server, {mysql, "localhost", Port, "test", "root", "password"}}.
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
|
||||||
\subsubsection{Storage}
|
\subsubsection{Storage}
|
||||||
\label{mysqlstorage}
|
\label{mysqlstorage}
|
||||||
\ind{MySQL!storage}
|
\ind{MySQL!storage}
|
||||||
@ -1162,6 +1176,19 @@ form as parameter:
|
|||||||
{odbc_server, {pgsql, "localhost", "database", "ejabberd", "password"}}.
|
{odbc_server, {pgsql, "localhost", "database", "ejabberd", "password"}}.
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
|
Optionally, it is possible to define the PostgreSQL port to use. This
|
||||||
|
option is only useful, in very rare cases, when you are not running
|
||||||
|
PostgreSQL with the default port setting. The \term{pgsql} parameter
|
||||||
|
can thus take the following form:
|
||||||
|
\begin{verbatim}
|
||||||
|
{pgsql, "Server", Port, "Database", "Username", "Password"}
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
The \term{Port} value should be an integer, without quotes. For example:
|
||||||
|
\begin{verbatim}
|
||||||
|
{odbc_server, {pgsql, "localhost", 5432, "database", "ejabberd", "password"}}.
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
\subsubsection{Storage}
|
\subsubsection{Storage}
|
||||||
\label{pgsqlstorage}
|
\label{pgsqlstorage}
|
||||||
\ind{PostgreSQL!storage}
|
\ind{PostgreSQL!storage}
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
-define(STATE_KEY, ejabberd_odbc_state).
|
-define(STATE_KEY, ejabberd_odbc_state).
|
||||||
-define(MAX_TRANSACTION_RESTARTS, 10).
|
-define(MAX_TRANSACTION_RESTARTS, 10).
|
||||||
|
-define(PGSQL_PORT, 5432).
|
||||||
-define(MYSQL_PORT, 3306).
|
-define(MYSQL_PORT, 3306).
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
@ -113,10 +114,16 @@ escape_like(C) -> odbc_queries:escape(C).
|
|||||||
init([Host]) ->
|
init([Host]) ->
|
||||||
SQLServer = ejabberd_config:get_local_option({odbc_server, Host}),
|
SQLServer = ejabberd_config:get_local_option({odbc_server, Host}),
|
||||||
case SQLServer of
|
case SQLServer of
|
||||||
|
%% Default pgsql port
|
||||||
{pgsql, Server, DB, Username, Password} ->
|
{pgsql, Server, DB, Username, Password} ->
|
||||||
pgsql_connect(Server, DB, Username, Password);
|
pgsql_connect(Server, ?PGSQL_PORT, DB, Username, Password);
|
||||||
|
{pgsql, Server, Port, DB, Username, Password} when is_integer(Port) ->
|
||||||
|
pgsql_connect(Server, Port, DB, Username, Password);
|
||||||
|
%% Default mysql port
|
||||||
{mysql, Server, DB, Username, Password} ->
|
{mysql, Server, DB, Username, Password} ->
|
||||||
mysql_connect(Server, DB, Username, Password);
|
mysql_connect(Server, ?MYSQL_PORT, DB, Username, Password);
|
||||||
|
{mysql, Server, Port, DB, Username, Password} when is_integer(Port) ->
|
||||||
|
mysql_connect(Server, Port, DB, Username, Password);
|
||||||
_ when is_list(SQLServer) ->
|
_ when is_list(SQLServer) ->
|
||||||
odbc_connect(SQLServer)
|
odbc_connect(SQLServer)
|
||||||
end.
|
end.
|
||||||
@ -229,8 +236,8 @@ odbc_connect(SQLServer) ->
|
|||||||
|
|
||||||
%% part of init/1
|
%% part of init/1
|
||||||
%% Open a database connection to PostgreSQL
|
%% Open a database connection to PostgreSQL
|
||||||
pgsql_connect(Server, DB, Username, Password) ->
|
pgsql_connect(Server, Port, DB, Username, Password) ->
|
||||||
case pgsql:connect(Server, DB, Username, Password) of
|
case pgsql:connect(Server, DB, Username, Password, Port) of
|
||||||
{ok, Ref} ->
|
{ok, Ref} ->
|
||||||
{ok, #state{db_ref = Ref, db_type = pgsql}};
|
{ok, #state{db_ref = Ref, db_type = pgsql}};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
@ -267,9 +274,9 @@ pgsql_item_to_odbc(_) ->
|
|||||||
|
|
||||||
%% part of init/1
|
%% part of init/1
|
||||||
%% Open a database connection to MySQL
|
%% Open a database connection to MySQL
|
||||||
mysql_connect(Server, DB, Username, Password) ->
|
mysql_connect(Server, Port, DB, Username, Password) ->
|
||||||
NoLogFun = fun(_Level,_Format,_Argument) -> ok end,
|
NoLogFun = fun(_Level,_Format,_Argument) -> ok end,
|
||||||
case mysql_conn:start(Server, ?MYSQL_PORT, Username, Password, DB, NoLogFun) of
|
case mysql_conn:start(Server, Port, Username, Password, DB, NoLogFun) of
|
||||||
{ok, Ref} ->
|
{ok, Ref} ->
|
||||||
erlang:monitor(process, Ref),
|
erlang:monitor(process, Ref),
|
||||||
{ok, #state{db_ref = Ref, db_type = mysql}};
|
{ok, #state{db_ref = Ref, db_type = mysql}};
|
||||||
|
Loading…
Reference in New Issue
Block a user