Annotate

plugins/storage/ejabberd_init.lib.lua @ 3816:39d83a43d473

mod_proxy65: Cleaned up stanza processing a little.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 03 Dec 2010 00:22:11 +0500
parent 3415:5ba0e094a5e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3415
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local t_concat = table.concat;
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 local t_insert = table.insert;
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4 local pairs = pairs;
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 local DBI = require "DBI";
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 local sqlite = true;
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 local q = {};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 local function set(key, val)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11 -- t_insert(q, "SET "..key.."="..val..";\n")
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 local function create_table(name, fields)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 t_insert(q, "CREATE TABLE ".."IF NOT EXISTS "..name.." (\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 for _, field in pairs(fields) do
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 t_insert(q, "\t");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 field = t_concat(field, " ");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 if sqlite then
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 if field:lower():match("^primary key *%(") then field = field:gsub("%(%d+%)", ""); end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 t_insert(q, field);
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 if _ ~= #fields then t_insert(q, ",\n"); end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 t_insert(q, "\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
25 if sqlite then
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26 t_insert(q, ");\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27 else
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28 t_insert(q, ") CHARACTER SET utf8;\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31 local function create_index(name, index)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 --t_insert(q, "CREATE INDEX "..name.." ON "..index..";\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
33 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34 local function create_unique_index(name, index)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
35 --t_insert(q, "CREATE UNIQUE INDEX "..name.." ON "..index..";\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
36 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
37 local function insert(target, value)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
38 t_insert(q, "INSERT INTO "..target.."\nVALUES "..value..";\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
39 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
40 local function foreign_key(name, fkey, fname, fcol)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
41 t_insert(q, "ALTER TABLE `"..name.."` ADD FOREIGN KEY (`"..fkey.."`) REFERENCES `"..fname.."` (`"..fcol.."`) ON DELETE CASCADE;\n");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
42 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
43
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
44 function build_query()
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
45 q = {};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
46 set('table_type', 'InnoDB');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
47 create_table('hosts', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
48 {'clusterid','integer','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
49 {'host','varchar(250)','NOT','NULL','PRIMARY','KEY'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
50 {'config','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
51 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
52 insert("hosts (clusterid, host, config)", "(1, 'localhost', '')");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
53 create_table('users', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
54 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
55 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
56 {'password','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
57 {'created_at','timestamp','NOT','NULL','DEFAULT','CURRENT_TIMESTAMP'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
58 {'PRIMARY','KEY','(host, username)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
59 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
60 create_table('last', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
61 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
62 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
63 {'seconds','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
64 {'state','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
65 {'PRIMARY','KEY','(host, username)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
66 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
67 create_table('rosterusers', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
68 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
69 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
70 {'jid','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
71 {'nick','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
72 {'subscription','character(1)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
73 {'ask','character(1)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
74 {'askmessage','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
75 {'server','character(1)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
76 {'subscribe','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
77 {'type','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
78 {'created_at','timestamp','NOT','NULL','DEFAULT','CURRENT_TIMESTAMP'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
79 {'PRIMARY','KEY','(host(75), username(75), jid(75))'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
80 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
81 create_index('i_rosteru_username', 'rosterusers(username)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
82 create_index('i_rosteru_jid', 'rosterusers(jid)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
83 create_table('rostergroups', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
84 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
85 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
86 {'jid','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
87 {'grp','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
88 {'PRIMARY','KEY','(host(75), username(75), jid(75))'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
89 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
90 --[[create_table('spool', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
91 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
92 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
93 {'xml','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
94 {'seq','BIGINT','UNSIGNED','NOT','NULL','AUTO_INCREMENT','UNIQUE'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
95 {'created_at','timestamp','NOT','NULL','DEFAULT','CURRENT_TIMESTAMP'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
96 {'PRIMARY','KEY','(host, username, seq)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
97 });]]
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
98 create_table('vcard', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
99 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
100 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
101 {'vcard','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
102 {'created_at','timestamp','NOT','NULL','DEFAULT','CURRENT_TIMESTAMP'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
103 {'PRIMARY','KEY','(host, username)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
104 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
105 create_table('vcard_search', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
106 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
107 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
108 {'lusername','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
109 {'fn','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
110 {'lfn','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
111 {'family','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
112 {'lfamily','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
113 {'given','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
114 {'lgiven','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
115 {'middle','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
116 {'lmiddle','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
117 {'nickname','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
118 {'lnickname','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
119 {'bday','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
120 {'lbday','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
121 {'ctry','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
122 {'lctry','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
123 {'locality','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
124 {'llocality','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
125 {'email','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
126 {'lemail','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
127 {'orgname','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
128 {'lorgname','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
129 {'orgunit','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
130 {'lorgunit','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
131 {'PRIMARY','KEY','(host, lusername)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
132 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
133 create_index('i_vcard_search_lfn ', 'vcard_search(lfn)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
134 create_index('i_vcard_search_lfamily ', 'vcard_search(lfamily)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
135 create_index('i_vcard_search_lgiven ', 'vcard_search(lgiven)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
136 create_index('i_vcard_search_lmiddle ', 'vcard_search(lmiddle)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
137 create_index('i_vcard_search_lnickname', 'vcard_search(lnickname)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
138 create_index('i_vcard_search_lbday ', 'vcard_search(lbday)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
139 create_index('i_vcard_search_lctry ', 'vcard_search(lctry)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
140 create_index('i_vcard_search_llocality', 'vcard_search(llocality)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
141 create_index('i_vcard_search_lemail ', 'vcard_search(lemail)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
142 create_index('i_vcard_search_lorgname ', 'vcard_search(lorgname)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
143 create_index('i_vcard_search_lorgunit ', 'vcard_search(lorgunit)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
144 create_table('privacy_default_list', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
145 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
146 {'username','varchar(250)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
147 {'name','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
148 {'PRIMARY','KEY','(host, username)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
149 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
150 --[[create_table('privacy_list', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
151 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
152 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
153 {'name','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
154 {'id','BIGINT','UNSIGNED','NOT','NULL','AUTO_INCREMENT','UNIQUE'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
155 {'created_at','timestamp','NOT','NULL','DEFAULT','CURRENT_TIMESTAMP'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
156 {'PRIMARY','KEY','(host, username, name)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
157 });]]
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
158 create_table('privacy_list_data', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
159 {'id','bigint'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
160 {'t','character(1)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
161 {'value','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
162 {'action','character(1)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
163 {'ord','NUMERIC','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
164 {'match_all','boolean','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
165 {'match_iq','boolean','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
166 {'match_message','boolean','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
167 {'match_presence_in','boolean','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
168 {'match_presence_out','boolean','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
169 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
170 create_table('private_storage', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
171 {'host','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
172 {'username','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
173 {'namespace','varchar(250)','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
174 {'data','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
175 {'created_at','timestamp','NOT','NULL','DEFAULT','CURRENT_TIMESTAMP'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
176 {'PRIMARY','KEY','(host(75), username(75), namespace(75))'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
177 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
178 create_index('i_private_storage_username USING BTREE', 'private_storage(username)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
179 create_table('roster_version', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
180 {'username','varchar(250)','PRIMARY','KEY'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
181 {'version','text','NOT','NULL'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
182 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
183 --[[create_table('pubsub_node', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
184 {'host','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
185 {'node','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
186 {'parent','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
187 {'type','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
188 {'nodeid','bigint','auto_increment','primary','key'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
189 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
190 create_index('i_pubsub_node_parent', 'pubsub_node(parent(120))');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
191 create_unique_index('i_pubsub_node_tuple', 'pubsub_node(host(20), node(120))');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
192 create_table('pubsub_node_option', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
193 {'nodeid','bigint'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
194 {'name','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
195 {'val','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
196 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
197 create_index('i_pubsub_node_option_nodeid', 'pubsub_node_option(nodeid)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
198 foreign_key('pubsub_node_option', 'nodeid', 'pubsub_node', 'nodeid');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
199 create_table('pubsub_node_owner', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
200 {'nodeid','bigint'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
201 {'owner','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
202 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
203 create_index('i_pubsub_node_owner_nodeid', 'pubsub_node_owner(nodeid)');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
204 foreign_key('pubsub_node_owner', 'nodeid', 'pubsub_node', 'nodeid');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
205 create_table('pubsub_state', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
206 {'nodeid','bigint'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
207 {'jid','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
208 {'affiliation','character(1)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
209 {'subscriptions','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
210 {'stateid','bigint','auto_increment','primary','key'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
211 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
212 create_index('i_pubsub_state_jid', 'pubsub_state(jid(60))');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
213 create_unique_index('i_pubsub_state_tuple', 'pubsub_state(nodeid, jid(60))');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
214 foreign_key('pubsub_state', 'nodeid', 'pubsub_node', 'nodeid');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
215 create_table('pubsub_item', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
216 {'nodeid','bigint'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
217 {'itemid','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
218 {'publisher','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
219 {'creation','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
220 {'modification','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
221 {'payload','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
222 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
223 create_index('i_pubsub_item_itemid', 'pubsub_item(itemid(36))');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
224 create_unique_index('i_pubsub_item_tuple', 'pubsub_item(nodeid, itemid(36))');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
225 foreign_key('pubsub_item', 'nodeid', 'pubsub_node', 'nodeid');
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
226 create_table('pubsub_subscription_opt', {
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
227 {'subid','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
228 {'opt_name','varchar(32)'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
229 {'opt_value','text'};
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
230 });
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
231 create_unique_index('i_pubsub_subscription_opt', 'pubsub_subscription_opt(subid(32), opt_name(32))');]]
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
232 return t_concat(q);
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
233 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
234
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
235 local function init(dbh)
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
236 local q = build_query();
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
237 for statement in q:gmatch("[^;]*;") do
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
238 statement = statement:gsub("\n", ""):gsub("\t", " ");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
239 if sqlite then
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
240 statement = statement:gsub("AUTO_INCREMENT", "AUTOINCREMENT");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
241 statement = statement:gsub("auto_increment", "autoincrement");
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
242 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
243 local result, err = DBI.Do(dbh, statement);
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
244 if not result then
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
245 print("X", result, err);
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
246 print("Y", statement);
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
247 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
248 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
249 end
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
250
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
251 local _M = { init = init };
5ba0e094a5e2 storage/mod_ejabberd (and associated library): Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
252 return _M;