On Sun, Jul 17, 2005 at 12:45:09AM -0000, Aaron Stone wrote:
> On Sat, Jul 16, 2005, ""Christian G. Warden"" <[EMAIL PROTECTED]> said:
>
> > On Sat, Jul 16, 2005 at 05:38:34PM -0400, M. J. [Mike] O'Brien wrote:
> >> Suggestion:
> >> 1) Use DbMail 2.0.4 stable
> >
> > I'm using 2.1 mainly for the table prefix. I'm upgrading an old pre 2.0
> > installation, before the dbmail_ prefix was added to the tables. I have
> > a lot of code that interacts with the dbmail tables so I don't want to
> > rename the tables right now.
> >
> > Unfortunately, it looks like the table prefix code is somewhat broken.
>
> I'm looking at it right now; this bit of code needs a rewrite.
Thanks, Aaron.
> > config.c always sets the table prefix to DEFAULT_DBPFX. Also, the
> > iniparser treats and empty right-hand-side the same as if the key
> > doesn't exist so there doesn't appear to be a way to set the prefix to
> > an empty string.
>
> Have you tried quoting? e.g.
>
> table_prefix = ""
Yes, iniparser treats it as the string, '""', so you end up with
queries against tables named ""users, for example.
> > I think I'll probably just have to change
> > DEFAULT_DBPFX. And finally, there are a handful of places in db.c where
> > the dbmail_ prefix is hard-coded into the queries, but these are easy to
> > fix.
>
> Send patches!
I've attached the patch to db.c.
Christian
--- dbmail2-2.1.1/db.c 2005-06-20 06:44:31.000000000 -0700
+++ dbmail2-2.1.1-dev/db.c 2005-07-16 14:57:19.000000000 -0700
@@ -133,14 +133,14 @@
*/
int db_check_version(void)
{
- snprintf(query, DEF_QUERYSIZE, "SELECT 1=1 FROM dbmail_physmessage
LIMIT 1 OFFSET 0");
+ snprintf(query, DEF_QUERYSIZE, "SELECT 1=1 FROM %sphysmessage LIMIT 1
OFFSET 0", DBPFX);
if (db_query(query) == -1) {
trace(TRACE_FATAL, "%s,%s: pre-2.0 database incompatible. You
need to run the conversion script",
__FILE__,__func__);
return DM_EQUERY;
}
- snprintf(query, DEF_QUERYSIZE, "SELECT 1=1 FROM dbmail_headervalue
LIMIT 1 OFFSET 0");
+ snprintf(query, DEF_QUERYSIZE, "SELECT 1=1 FROM %sheadervalue LIMIT 1
OFFSET 0", DBPFX);
if (db_query(query) == -1) {
trace(TRACE_FATAL, "%s,%s: 2.0 database incompatible. You need
to add the header tables.",
__FILE__,__func__);
@@ -1050,7 +1050,7 @@
return DM_EQUERY;
}
snprintf(query, DEF_QUERYSIZE,
- "SELECT * FROM dbmail_pbsp WHERE since < '%s'",
escaped_lasttokeep);
+ "SELECT * FROM %spbsp WHERE since < '%s'", DBPFX,
escaped_lasttokeep);
dm_free(escaped_lasttokeep);
if (db_query(query) == -1) {
@@ -2108,7 +2108,7 @@
/* first we're deleting all the messageblks */
snprintf(query, DEF_QUERYSIZE,
- "SELECT message_idnr FROM dbmail_messages WHERE status='%d'",
+ "SELECT message_idnr FROM %smessages WHERE status='%d'", DBPFX,
MESSAGE_STATUS_PURGE);
trace(TRACE_DEBUG, "%s,%s: executing query [%s]",
__FILE__, __func__, query);
@@ -2628,15 +2628,15 @@
/* count messages */
snprintf(query, DEF_QUERYSIZE,
- "SELECT 'a',COUNT(*) FROM dbmail_messages WHERE
mailbox_idnr='%llu' "
+ "SELECT 'a',COUNT(*) FROM %smessages WHERE
mailbox_idnr='%llu' "
"AND (status='%d' OR status='%d') UNION "
- "SELECT 'b',COUNT(*) FROM dbmail_messages WHERE
mailbox_idnr='%llu' "
+ "SELECT 'b',COUNT(*) FROM %smessages WHERE
mailbox_idnr='%llu' "
"AND (status='%d' OR status='%d') AND seen_flag=1
UNION "
- "SELECT 'c',COUNT(*) FROM dbmail_messages WHERE
mailbox_idnr='%llu' "
+ "SELECT 'c',COUNT(*) FROM %smessages WHERE
mailbox_idnr='%llu' "
"AND (status='%d' OR status='%d') AND recent_flag=1",
- mb->uid, MESSAGE_STATUS_NEW, MESSAGE_STATUS_SEEN,
- mb->uid, MESSAGE_STATUS_NEW, MESSAGE_STATUS_SEEN,
- mb->uid, MESSAGE_STATUS_NEW, MESSAGE_STATUS_SEEN);
+ DBPFX, mb->uid, MESSAGE_STATUS_NEW,
MESSAGE_STATUS_SEEN,
+ DBPFX, mb->uid, MESSAGE_STATUS_NEW,
MESSAGE_STATUS_SEEN,
+ DBPFX, mb->uid, MESSAGE_STATUS_NEW,
MESSAGE_STATUS_SEEN);
if (db_query(query) == -1) {
trace(TRACE_ERROR, "%s,%s: query error", __FILE__, __func__);