25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

MSSQL support was broken (EJAB-1201)

This commit is contained in:
Denis Kurochkin 2010-03-03 18:18:08 +02:00 committed by Badlop
parent 4984320f17
commit 6e878d17e6
2 changed files with 600 additions and 2 deletions

View File

@ -112,6 +112,46 @@ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[private_st
drop table [dbo].[private_storage] drop table [dbo].[private_storage]
GO GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[privacy_default_list]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[privacy_default_list]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[privacy_list]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[privacy_list]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[privacy_list_data]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[privacy_list_data]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[roster_version]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[roster_version]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pubsub_node_option]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[pubsub_node_option]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pubsub_node_owner]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[pubsub_node_owner]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pubsub_state]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[pubsub_state]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pubsub_item]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[pubsub_item]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pubsub_subscription_opt]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[pubsub_subscription_opt]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pubsub_node]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[pubsub_node]
GO
CREATE TABLE [dbo].[last] ( CREATE TABLE [dbo].[last] (
[username] [varchar] (250) NOT NULL , [username] [varchar] (250) NOT NULL ,
[seconds] [varchar] (50) NOT NULL , [seconds] [varchar] (50) NOT NULL ,
@ -234,6 +274,60 @@ CREATE TABLE [dbo].[privacy_list_data] (
) ON [PRIMARY] ) ON [PRIMARY]
GO GO
CREATE TABLE [dbo].[roster_version] (
[username] [varchar](250) PRIMARY KEY,
[version] [text] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[pubsub_node] (
[host] [varchar](250),
[node] [varchar](250),
[parent] [varchar](250),
[type] [varchar](250),
[nodeid] [bigint] IDENTITY(1,1) PRIMARY KEY
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[pubsub_node_option] (
[nodeid] [bigint],
[name] [varchar](250),
[val] [varchar](250)
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[pubsub_node_owner] (
[nodeid] [bigint],
[owner] [varchar](250)
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[pubsub_state] (
[nodeid] [bigint],
[jid] [varchar](250),
[affiliation] [CHAR](1),
[subscriptions] [text],
[stateid] [bigint] IDENTITY(1,1) PRIMARY KEY
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[pubsub_item] (
[nodeid] [bigint],
[itemid] [varchar](250),
[publisher] [text],
[creation] [text],
[modification] [text],
[payload] [text]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[pubsub_subscription_opt] (
[subid] [varchar](250),
[opt_name] [varchar](32),
[opt_value] [text]
) ON [PRIMARY]
GO
/* Constraints to add: /* Constraints to add:
- id in privacy_list is a SERIAL autogenerated number - id in privacy_list is a SERIAL autogenerated number
- id in privacy_list_data must exist in the table privacy_list */ - id in privacy_list_data must exist in the table privacy_list */
@ -276,6 +370,49 @@ ALTER TABLE [dbo].[vcard] WITH NOCHECK ADD
) WITH FILLFACTOR = 90 ON [PRIMARY] ) WITH FILLFACTOR = 90 ON [PRIMARY]
GO GO
ALTER TABLE [dbo].[pubsub_node_option] WITH NOCHECK ADD
CONSTRAINT [FK_pubsub_node_option] FOREIGN KEY
(
[nodeid]
) REFERENCES [dbo].[pubsub_node]
(
[nodeid]
)
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[pubsub_node_owner] WITH NOCHECK ADD
CONSTRAINT [FK_pubsub_node_owner] FOREIGN KEY
(
[nodeid]
) REFERENCES [pubsub_node]
(
[nodeid]
)
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[pubsub_state] WITH NOCHECK ADD
CONSTRAINT [FK_pubsub_state] FOREIGN KEY
(
[nodeid]
) REFERENCES [pubsub_node]
(
[nodeid]
)
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[pubsub_item] WITH NOCHECK ADD
CONSTRAINT [FK_pubsub_item] FOREIGN KEY
(
[nodeid]
) REFERENCES [pubsub_node]
(
[nodeid]
)
ON DELETE CASCADE
GO
CREATE INDEX [IX_vcard_search_lfn] ON [dbo].[vcard_search]([lfn]) WITH FILLFACTOR = 90 ON [PRIMARY] CREATE INDEX [IX_vcard_search_lfn] ON [dbo].[vcard_search]([lfn]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO GO
@ -355,6 +492,33 @@ GO
CREATE INDEX [IX_privacy_list_username_name] ON [dbo].[privacy_list]([username], [name]) WITH FILLFACTOR = 90 ON [PRIMARY] CREATE INDEX [IX_privacy_list_username_name] ON [dbo].[privacy_list]([username], [name]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO GO
CREATE INDEX [IX_pubsub_node_parent] ON [dbo].[pubsub_node]([parent]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_node_tuple] ON [dbo].[pubsub_node]([host], [node]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_node_option_nodeid] ON [dbo].[pubsub_node_option]([nodeid]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_node_owner_nodeid] ON [dbo].[pubsub_node_owner]([nodeid]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_state_jid] ON [dbo].[pubsub_state]([jid]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_state_tuple] ON [dbo].[pubsub_state]([nodeid], [jid]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_item_itemid] ON [dbo].[pubsub_item]([itemid]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_item_tuple] ON [dbo].[pubsub_item]([nodeid], [itemid]) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [IX_pubsub_subscription_opt] ON [dbo].[pubsub_subscription_opt]([subid], [opt_name]) WITH FILLFACTOR = 90 ON [PRIMARY]
Go
/*********************************************************/ /*********************************************************/
/** These store procedures are for use with ejabberd **/ /** These store procedures are for use with ejabberd **/
/** 1.1 and Microsoft Sql Server 2000 **/ /** 1.1 and Microsoft Sql Server 2000 **/
@ -370,6 +534,133 @@ GO
/****** Object: StoredProcedure [dbo].[add_roster] ******/ /****** Object: StoredProcedure [dbo].[add_roster] ******/
/** Add or update user entries in the roster **/ /** Add or update user entries in the roster **/
/*********************************************************/ /*********************************************************/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[add_roster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[add_roster]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[add_roster_group]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[add_roster_group]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[add_roster_user]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[add_roster_user]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_roster_groups]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_roster_groups]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[add_spool]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[add_spool]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[add_user]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[add_user]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[set_password]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[set_password]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[clean_spool_msg]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[clean_spool_msg]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_password]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_password]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_last]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_last]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_roster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_roster]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_spool_msg]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_spool_msg]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_user]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_user]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_user_return_password]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_user_return_password]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_user_roster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_user_roster]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_and_del_spool_msg]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_and_del_spool_msg]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_last]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_last]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_roster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_roster]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_roster_by_jid]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_roster_by_jid]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_roster_jid_groups]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_roster_jid_groups]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_roster_groups]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_roster_groups]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_rostergroup_by_jid]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_rostergroup_by_jid]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_subscription]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_subscription]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[list_users]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[list_users]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[set_last]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[set_last]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[set_private_data]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[set_private_data]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_private_data]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_private_data]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_user_storage]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_user_storage]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[set_vcard]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[set_vcard]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_vcard]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_vcard]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_default_privacy_list]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_default_privacy_list]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_privacy_list_names]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_privacy_list_names]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_privacy_list_id]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_privacy_list_id]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_privacy_list_data]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_privacy_list_data]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_privacy_list_data_by_id]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[get_privacy_list_data_by_id]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[set_default_privacy_list]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[set_default_privacy_list]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[unset_default_privacy_list]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[unset_default_privacy_list]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[remove_privacy_list]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[remove_privacy_list]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[add_privacy_list]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[add_privacy_list]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[set_privacy_list]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[set_privacy_list]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_privacy_list_by_id]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_privacy_list_by_id]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[del_privacy_lists]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[del_privacy_lists]
GO
CREATE PROCEDURE [dbo].[add_roster] CREATE PROCEDURE [dbo].[add_roster]
@Username varchar(250), @Username varchar(250),
@JID varchar(250), @JID varchar(250),
@ -1237,3 +1528,242 @@ BEGIN
WHERE username=@Username; WHERE username=@Username;
END END
GO GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[get_default_privacy_list]**/
/** Retrive the user's default privacy list **/
/******************************************************************/
CREATE PROCEDURE [dbo].[get_default_privacy_list]
@Username varchar(250)
AS
BEGIN
SELECT list.name
FROM privacy_default_list list WITH (NOLOCK)
WHERE list.username=@Username
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[get_privacy_list_names] **/
/** Retrive the user's default privacy list names **/
/******************************************************************/
CREATE PROCEDURE [dbo].[get_privacy_list_names]
@username varchar(250)
AS
BEGIN
SELECT list.name
FROM privacy_list list WITH (NOLOCK)
WHERE list.username=@Username
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[get_privacy_list_id] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[get_privacy_list_id]
@username varchar(250),
@SName varchar(250)
AS
BEGIN
SELECT id FROM privacy_list
WHERE username=@Username
AND name=@SName
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[get_privacy_list_data] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[get_privacy_list_data]
@username varchar(250),
@SName varchar(250)
AS
BEGIN
SELECT l_data.t,
l_data.value,
l_data.action,
l_data.ord,
l_data.match_all,
l_data.match_iq,
l_data.match_message,
l_data.match_presence_in,
l_data.match_presence_out
FROM privacy_list_data l_data (NOLOCK)
WHERE l_data.id = (SELECT list.id
FROM privacy_list list
WHERE list.username=@username
AND list.name=@SName)
ORDER BY l_data.ord
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[get_privacy_list_data_by_id]**/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[get_privacy_list_data_by_id]
@Id bigint
AS
BEGIN
SELECT l_data.t,
l_data.value,
l_data.action,
l_data.ord,
l_data.match_all,
l_data.match_iq,
l_data.match_message,
l_data.match_presence_in,
l_data.match_presence_out
FROM privacy_list_data l_data (NOLOCK)
WHERE l_data.id=@ID
ORDER BY l_data.ord
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[set_default_privacy_list]**/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[set_default_privacy_list]
@username varchar(250),
@Sname varchar(250)
AS
BEGIN
IF EXISTS (SELECT username FROM privacy_default_list with (nolock) WHERE privacy_default_list.username = @Username AND privacy_default_list.name = @Sname)
BEGIN
UPDATE [privacy_default_list]
SET [privacy_default_list].username = @Username,
[privacy_default_list].name = @Sname
WHERE privacy_default_list.username = @Username
END
ELSE
BEGIN
INSERT INTO [privacy_default_list]
( [privacy_default_list].username,
[privacy_default_list].name
)
VALUES
( @Username,
@SName
)
END
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[unset_default_privacy_list]**/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[unset_default_privacy_list]
@username varchar(250)
AS
BEGIN
DELETE
FROM privacy_default_list
WHERE privacy_default_list.username=@username
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[remove_privacy_list] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[remove_privacy_list]
@username varchar(250),
@SName varchar(250)
AS
BEGIN
DELETE
FROM privacy_list
WHERE privacy_list.username=@username
AND privacy_list.name=@SName
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[add_privacy_list] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[add_privacy_list]
@username varchar(250),
@SName varchar(250)
AS
BEGIN
INSERT INTO privacy_list(username, name)
VALUES (@username, @SName)
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[set_privacy_list] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[set_privacy_list]
@Id bigint,
@t char(1),
@value text,
@action char(1),
@ord numeric,
@match_all bit,
@match_iq bit,
@match_message bit,
@match_presence_in bit,
@match_presence_out bit
AS
BEGIN
insert into privacy_list_data (
id,
t,
value,
action,
ord,
match_all,
match_iq,
match_message,
match_presence_in,
match_presence_out
)
values (@Id,
@t,
@value,
@action,
@ord,
@match_all,
@match_iq,
@match_message,
@match_presence_in,
@match_presence_out
)
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[del_privacy_list_by_id] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[del_privacy_list_by_id]
@Id bigint
AS
BEGIN
DELETE FROM privacy_list_data
WHERE privacy_list_data.id=@Id
END
GO
/******************************************************************/
/****** Object: StoredProcedure [dbo].[del_privacy_lists] **/
/** **/
/******************************************************************/
CREATE PROCEDURE [dbo].[del_privacy_lists]
@Server varchar(250),
@username varchar(250)
AS
BEGIN
DELETE FROM privacy_list WHERE username=@username
DELETE FROM privacy_list_data WHERE convert(varchar,value)=@username+'@'+@Server
DELETE FROM privacy_default_list WHERE username=@username
END
GO

View File

@ -786,6 +786,74 @@ get_vcard(LServer, Username) ->
LServer, LServer,
["EXECUTE dbo.get_vcard '", Username, "'"]). ["EXECUTE dbo.get_vcard '", Username, "'"]).
get_default_privacy_list(LServer, Username) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.get_default_privacy_list '", Username, "'"]).
get_default_privacy_list_t(Username) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.get_default_privacy_list '", Username, "'"]).
get_privacy_list_names(LServer, Username) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.get_privacy_list_names '", Username, "'"]).
get_privacy_list_names_t(Username) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.get_privacy_list_names '", Username, "'"]).
get_privacy_list_id(LServer, Username, SName) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.get_privacy_list_id '", Username, "' , '", SName, "'"]).
get_privacy_list_id_t(Username, SName) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.get_privacy_list_id '", Username, "' , '", SName, "'"]).
get_privacy_list_data(LServer, Username, SName) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.get_privacy_list_data '", Username, "' , '", SName, "'"]).
get_privacy_list_data_by_id(LServer, ID) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.get_privacy_list_data_by_id '", ID, "'"]).
set_default_privacy_list(Username, SName) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.set_default_privacy_list '", Username, "' , '", SName, "'"]).
unset_default_privacy_list(LServer, Username) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.unset_default_privacy_list '", Username, "'"]).
remove_privacy_list(Username, SName) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.remove_privacy_list '", Username, "' , '", SName, "'"]).
add_privacy_list(Username, SName) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.add_privacy_list '", Username, "' , '", SName, "'"]).
set_privacy_list(ID, RItems) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.del_privacy_list_by_id '", ID, "'"]),
lists:foreach(fun(Items) ->
ejabberd_odbc:sql_query_t(
["EXECUTE dbo.set_privacy_list '", ID, "', '", join(Items, "', '"), "'"])
end, RItems).
del_privacy_lists(LServer, Server, Username) ->
ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.del_privacy_lists @Server='", Server ,"' @username='", Username, "'"]).
%% Characters to escape %% Characters to escape
escape($\0) -> "\\0"; escape($\0) -> "\\0";
escape($\t) -> "\\t"; escape($\t) -> "\\t";
@ -799,11 +867,11 @@ escape(C) -> C.
count_records_where(LServer, Table, WhereClause) -> count_records_where(LServer, Table, WhereClause) ->
ejabberd_odbc:sql_query( ejabberd_odbc:sql_query(
LServer, LServer,
["select count(*) from ", Table, " ", WhereClause, " with (nolock)"]). ["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(LServer,
["select version from dbo.roster_version where username = '", LUser, "'"]). ["select version from dbo.roster_version with (nolock) where username = '", LUser, "'"]).
set_roster_version(LUser, Version) -> set_roster_version(LUser, Version) ->
update_t("dbo.roster_version", ["username", "version"], [LUser, Version], ["username = '", LUser, "'"]). update_t("dbo.roster_version", ["username", "version"], [LUser, Version], ["username = '", LUser, "'"]).
-endif. -endif.