Kedves János!
Több kérdésem, észrevételem és javításom lenne.
- Miért van különbség a mysql és az sqlite3 adatbázis szerkezete között?
Itt nem az egyes mezők típusára gondolok, hanem táblákra és hiányzó
mezőkre (t_transport, t_queue tábla vagy uid mező)
- Az sqlite3-nál miért nincs az UID kezelés megoldva? Mert egyáltalán nincs a
t_token táblában uid mező, de a t_misc-ben van uid mező.
- Postgres adatbázis kezelés most nincs :( pedig nagyon jó lenne.
Várható, hogy készül? Vagy csináljam meg magamnak és küldjem el neked?
- Szeretnék csoport kezelést is megoldani, de ehhez szükség van a egységes
uid kezelésre.
- A mysql-nél és a sqlite3-nál található sql kéréseknél találtam (szerintem)
elvi hibát, ezt is nézd meg.
Az itt általam felvázolt észrevételekre csináltam már pár javítást is.
Ezeket csatolom.
* p1.diff:
COMMIT-on kivüli a DELETE és felesleges a select a unix_timestamp-nál.
* p2.diff:
mysql-ben benne van a t_transport tába sqlite3-ban nincs.
* p3.diff:
sqlite3-ban benne van a t_queue tába mysql-ben nincs.
* p4.diff és p5.diff:
A token ~string~-nél van két '0' karakter es a ',' sem jól voltak.
* p6.diff:
A kodolásnál volt hiba, ha nem volt szóköz a dekódolandó mintaban, akkor nem
mindent kódolt vissza!
From: alma=?UTF-8?B?S8OhZMOhciBBdHRpbGE=?=via RT
From: alma ?B? korte
* p7.diff:
fixupEncodedHeaderLine meghivása nem volt jó helyen :)
előrébb kellet tenni...
* p8.diff:
Segmentation fault, bizonyos esetekben.
Nincs vizsgálba, hogy sqlite3_column_blob(pStmt, X)
egyáltalán létezik-e mert csak kimásoljuk :)
--
[Varadi Gabor]
--- purge-mysql.sql.eta 2010-09-16 15:09:58.000000000 +0200
+++ purge-mysql.sql 2011-04-29 11:15:40.000000000 +0200
@@ -2,6 +2,5 @@
DELETE FROM t_token WHERE nham+nspam = 1 AND timestamp < UNIX_TIMESTAMP()-1296000;
DELETE FROM t_token WHERE (2*nham)+nspam < 5 AND timestamp < UNIX_TIMESTAMP()-5184000;
DELETE FROM t_token WHERE timestamp < UNIX_TIMESTAMP()-7776000;
+DELETE FROM t_minefield WHERE ts < UNIX_TIMESTAMP()-86400;
COMMIT;
-
-DELETE FROM t_minefield WHERE ts < (SELECT unix_timestamp() - 86400);
--- db-sqlite3.sql.eta 2010-09-16 15:09:58.000000000 +0200
+++ db-sqlite3.sql 2011-04-29 11:18:29.000000000 +0200
@@ -137,6 +137,11 @@
create index t_remote_idx on t_remote(remotedomain);
+create table if not exists t_transport (
+ domain char(64) not null primary key,
+ destination char(64) not null
+);
+
create table if not exists t_counters (
rcvd bigint unsigned default 0,
ham bigint unsigned default 0,
--- db-mysql.sql.eta 2010-09-16 15:09:58.000000000 +0200
+++ db-mysql.sql 2011-04-29 10:16:14.000000000 +0200
@@ -60,6 +60,17 @@
insert into t_black_list (uid) values(0);
+create table if not exists t_queue (
+ id char(32) not null,
+ uid int unsigned not null,
+ ts bigint unsigned not null,
+ is_spam integer(1) default 0,
+ data blob not null
+);
+
+create index t_queue_idx on t_queue(uid, id);
+create index t_queue_idx2 on t_queue(ts);
+
create table if not exists t_stat (
uid int unsigned not null,
ts bigint unsigned not null,
--- mysql.c.eta 2010-09-17 09:08:00.000000000 +0200
+++ mysql.c 2011-04-29 06:59:29.000000000 +0200
@@ -223,7 +223,7 @@
time(&cclock);
now = cclock;
- snprintf(s, SMALLBUFSIZE-1, "UPDATE %s SET timestamp=%ld WHERE token in (0", SQL_TOKEN_TABLE, now);
+ snprintf(s, SMALLBUFSIZE-1, "UPDATE %s SET timestamp=%ld WHERE token IN (", SQL_TOKEN_TABLE, now);
buffer_cat(query, s);
@@ -231,7 +231,8 @@
q = xhash[i];
while(q != NULL){
if(q->spaminess != DEFAULT_SPAMICITY){
- snprintf(s, SMALLBUFSIZE-1, ",%llu", q->key);
+ if(n) snprintf(s, SMALLBUFSIZE-1, ",%llu", q->key);
+ else snprintf(s, SMALLBUFSIZE-1, "%llu", q->key);
buffer_cat(query, s);
n++;
}
@@ -242,9 +243,9 @@
if(sdata->uid > 0)
- snprintf(s, SMALLBUFSIZE-1, "0) AND (uid=0 OR uid=%ld)", sdata->uid);
+ snprintf(s, SMALLBUFSIZE-1, ") AND (uid=0 OR uid=%ld)", sdata->uid);
else
- snprintf(s, SMALLBUFSIZE-1, "0) AND uid=0");
+ snprintf(s, SMALLBUFSIZE-1, ") AND uid=0");
buffer_cat(query, s);
--- sqlite3.c.eta 2010-09-16 15:09:58.000000000 +0200
+++ sqlite3.c 2011-05-20 09:03:29.000000000 +0200
buffer_destroy(query);
- sqlite3_exec(sdata->db, s, NULL, NULL, &err);
-
return 1;
}
@@ -213,7 +211,7 @@
time(&cclock);
now = cclock;
- snprintf(buf, SMALLBUFSIZE-1, "UPDATE %s SET timestamp=%ld WHERE token in (0", SQL_TOKEN_TABLE, now);
+ snprintf(buf, SMALLBUFSIZE-1, "UPDATE %s SET timestamp=%ld WHERE token IN (", SQL_TOKEN_TABLE, now);
buffer_cat(query, buf);
@@ -222,7 +220,8 @@
q = xhash[i];
while(q != NULL){
if(q->spaminess != DEFAULT_SPAMICITY){
- snprintf(buf, SMALLBUFSIZE-1, ",%llu", q->key);
+ if(n) snprintf(buf, SMALLBUFSIZE-1, ",%llu", q->key);
+ else snprintf(buf, SMALLBUFSIZE-1, "%llu", q->key);
buffer_cat(query, buf);
n++;
}
@@ -232,8 +231,7 @@
}
-
- snprintf(buf, SMALLBUFSIZE-1, "0)");
+ snprintf(buf, SMALLBUFSIZE-1, ")");
buffer_cat(query, buf);
if((sqlite3_exec(sdata->db, query->data, NULL, NULL, &err)) != SQLITE_OK)
--- parser_utils.c.eta 2011-04-28 11:22:57.000000000 +0200
+++ parser_utils.c 2011-04-28 13:26:03.000000000 +0200
@@ -138,8 +138,8 @@
void fixupEncodedHeaderLine(char *buf){
- int x;
char *p, *q, u[SMALLBUFSIZE], puf[MAXBUFSIZE];
+ char *end;
memset(puf, 0, MAXBUFSIZE);
@@ -147,20 +147,35 @@
do {
q = split_str(q, " ", u, SMALLBUFSIZE-1);
- x = 0;
+ end = (char *)NULL;
p = strcasestr(u, "?B?");
if(p){
- decodeBase64(p+3);
- x = 1;
+ end = strcasestr(p, "?=");
+ if(end) {
+ decodeBase64(p+3);
+ }
}
else if((p = strcasestr(u, "?Q?"))){
- decodeQP(p+3);
- x = 1;
+ end = strcasestr(p, "?=");
+ if(end) {
+ decodeQP(p+3);
+ }
}
- if(x == 1){
- if(strcasestr(u, "=?utf-8?")) decodeUTF8(p+3);
- strncat(puf, p+3, MAXBUFSIZE-1);
+ if(end){
+ char *start1 = strcasestr(u, "=?");
+ char *start2 = strcasestr(u, "=?utf-8?");
+ if(start1){
+ *start1 = '\0';
+ strncat(puf, u, MAXBUFSIZE-1);
+ if(start2)
+ decodeUTF8(p+3);
+ strncat(puf, p+3, MAXBUFSIZE-1);
+ strncat(puf, end+2, MAXBUFSIZE-1);
+ }
+ else {
+ strncat(puf, u, MAXBUFSIZE-1);
+ }
}
else {
strncat(puf, u, MAXBUFSIZE-1);
--- parser.c.eta 2011-04-28 11:00:12.000000000 +0200
+++ parser.c 2011-04-28 12:16:35.000000000 +0200
@@ -130,6 +130,9 @@
else if(strncmp(buf, "To:", 3) == 0) state->message_state = MSG_TO;
else if(strncmp(buf, "Subject:", strlen("Subject:")) == 0) state->message_state = MSG_SUBJECT;
+ /* fix encoded From:, To: and Subject: lines, 2008.11.24, SJ */
+
+ if(state->message_state == MSG_FROM || state->message_state == MSG_TO || state->message_state == MSG_SUBJECT) fixupEncodedHeaderLine(buf);
if(state->message_state == MSG_FROM){
p = strchr(buf+5, ' ');
@@ -256,11 +259,6 @@
if(state->base64 == 1 && state->message_state == MSG_BODY) b64_len = decodeBase64(buf);
- /* fix encoded From:, To: and Subject: lines, 2008.11.24, SJ */
-
- if(state->message_state == MSG_FROM || state->message_state == MSG_TO || state->message_state == MSG_SUBJECT) fixupEncodedHeaderLine(buf);
-
-
/* fix soft breaks with quoted-printable decoded stuff, 2006.03.01, SJ */
if(state->qp == 1) fixupSoftBreakInQuotedPritableLine(buf, state);
--- users.c.eta 2010-09-16 15:09:58.000000000 +0200
+++ users.c 2011-04-28 08:53:47.000000000 +0200
@@ -263,10 +263,10 @@
while(sqlite3_step(pStmt) == SQLITE_ROW){
if(n > 0) strncat(sdata->whitelist, "\n", MAXBUFSIZE-1);
- strncat(sdata->whitelist, (char *)sqlite3_column_blob(pStmt, 0), MAXBUFSIZE-1);
+ if(sqlite3_column_blob(pStmt, 0)) strncat(sdata->whitelist, (char *)sqlite3_column_blob(pStmt, 0), MAXBUFSIZE-1);
if(n > 0) strncat(sdata->blacklist, "\n", MAXBUFSIZE-1);
- strncat(sdata->blacklist, (char *)sqlite3_column_blob(pStmt, 1), MAXBUFSIZE-1);
+ if(sqlite3_column_blob(pStmt, 1)) strncat(sdata->blacklist, (char *)sqlite3_column_blob(pStmt, 1), MAXBUFSIZE-1);
n++;
}