mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Try to improve support for roster_version in MSSQL (EJAB-1437)
This commit is contained in:
parent
7436ef1fb1
commit
34fc5d82b3
@ -600,6 +600,40 @@ BEGIN
|
|||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/****** Object: StoredProcedure [dbo].[set_roster_version] **/
|
||||||
|
/** Update users roster_version **/
|
||||||
|
/******************************************************************/
|
||||||
|
CREATE PROCEDURE [dbo].[set_roster_version]
|
||||||
|
@Username varchar(200),
|
||||||
|
@Version varchar(50)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (SELECT username FROM roster_version WITH (NOLOCK) WHERE username=@Username)
|
||||||
|
BEGIN
|
||||||
|
UPDATE roster_version SET username=@Username, version=@Version WHERE username=@Username;
|
||||||
|
END
|
||||||
|
ELSE
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO roster_version (username, version) VALUES (@Username, @Version);
|
||||||
|
END
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/****** Object: StoredProcedure [dbo].[get_roster_version] **/
|
||||||
|
/** Retrive the user roster_version **/
|
||||||
|
/******************************************************************/
|
||||||
|
CREATE PROCEDURE [dbo].[get_roster_version]
|
||||||
|
@Username varchar(200)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SELECT roster_version.version as version
|
||||||
|
FROM roster_version WITH (NOLOCK)
|
||||||
|
WHERE username=@Username;
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/****** Object: StoredProcedure [dbo].[clean_spool_msg] ******/
|
/****** Object: StoredProcedure [dbo].[clean_spool_msg] ******/
|
||||||
/** Delete messages older that 3 days from spool **/
|
/** Delete messages older that 3 days from spool **/
|
||||||
|
@ -923,6 +923,40 @@ BEGIN
|
|||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/****** Object: StoredProcedure [dbo].[set_roster_version] **/
|
||||||
|
/** Update users roster_version **/
|
||||||
|
/******************************************************************/
|
||||||
|
CREATE PROCEDURE [dbo].[set_roster_version]
|
||||||
|
@Username varchar(200),
|
||||||
|
@Version varchar(8000)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (SELECT username FROM roster_version WITH (NOLOCK) WHERE username=@Username)
|
||||||
|
BEGIN
|
||||||
|
UPDATE roster_version SET username=@Username, version=@Version WHERE username=@Username;
|
||||||
|
END
|
||||||
|
ELSE
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO roster_version (username, version) VALUES (@Username, @Version);
|
||||||
|
END
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/****** Object: StoredProcedure [dbo].[get_roster_version] **/
|
||||||
|
/** Retrive the user roster_version **/
|
||||||
|
/******************************************************************/
|
||||||
|
CREATE PROCEDURE [dbo].[get_roster_version]
|
||||||
|
@Username varchar(200)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SELECT roster_version.version as version
|
||||||
|
FROM roster_version WITH (NOLOCK)
|
||||||
|
WHERE username=@Username;
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/****** Object: StoredProcedure [dbo].[clean_spool_msg] ******/
|
/****** Object: StoredProcedure [dbo].[clean_spool_msg] ******/
|
||||||
/** Delete messages older that 3 days from spool **/
|
/** Delete messages older that 3 days from spool **/
|
||||||
|
@ -92,6 +92,8 @@
|
|||||||
-define(generic, true).
|
-define(generic, true).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
%% -----------------
|
%% -----------------
|
||||||
%% Generic queries
|
%% Generic queries
|
||||||
-ifdef(generic).
|
-ifdef(generic).
|
||||||
@ -909,8 +911,14 @@ count_records_where(LServer, Table, WhereClause) ->
|
|||||||
["select count(*) from ", Table, " with (nolock) ", WhereClause]).
|
["select count(*) from ", Table, " with (nolock) ", WhereClause]).
|
||||||
|
|
||||||
get_roster_version(LServer, LUser) ->
|
get_roster_version(LServer, LUser) ->
|
||||||
ejabberd_odbc:sql_query(LServer,
|
ejabberd_odbc:sql_query(
|
||||||
["select version from dbo.roster_version with (nolock) where username = '", LUser, "'"]).
|
LServer,
|
||||||
set_roster_version(LUser, Version) ->
|
["EXECUTE dbo.get_roster_version '", LUser, "'"]).
|
||||||
update_t("dbo.roster_version", ["username", "version"], [LUser, Version], ["username = '", LUser, "'"]).
|
|
||||||
|
set_roster_version(Username, Version) ->
|
||||||
|
%% This function doesn't know the vhost, so we hope it's the first one defined:
|
||||||
|
LServer = ?MYNAME,
|
||||||
|
ejabberd_odbc:sql_query(
|
||||||
|
LServer,
|
||||||
|
["EXECUTE dbo.set_roster_version '", Username, "', '", Version, "'"]).
|
||||||
-endif.
|
-endif.
|
||||||
|
Loading…
Reference in New Issue
Block a user