r1338

0 views
Skip to first unread message

Owen Winkler

unread,
Feb 5, 2008, 12:39:15 PM2/5/08
to habar...@googlegroups.com
There are some weird code changes in r1338 to SQLite's dbDelta(). Do
they actually work? I can't imagine that they do. For example, the
original line:

$allqueries[] = 'ALTER TABLE {' . $tablename . '} RENAME TO {' .
$tablename . '}__temp;';

Was changed to:

$allqueries[]= 'ALTER TABLE {$tablename} RENAME TO {$tablename}__temp;';

The braces in the query enclose a table name that is processed by the
databaseconnection to be replaced with a table name that has the
config's table prefix applied. So this:

"SELECT * FROM {posts}"

Gets expanded to this:

"SELECT * FROM habari__posts"

If the prefix happens to be "habari__".

Also, since the changed line uses single-quotes, the tablename won't
even be expanded in the query, so it should cause all kinds of errors
when it tries to update a SQLite database.

Did anyone test this code? Maybe I'm missing something huge.

Owen

Raman Ng (tinyau)

unread,
Feb 5, 2008, 1:53:20 PM2/5/08
to habar...@googlegroups.com
Sorry Owen, the changes are applied by me without test it thoroughly even r1339 has been changed to use double quote.

In the ticket #121, the error is not only caused by MySQL specific SQL statement.  After I turned on DEBUG in config.php, I found PDO::prepare() tried to prepare SQL with '{', i.e. something like

   "SELECT * FROM {habari__posts}"

instead of

   "SELECT * FROM habari__posts"

The table explansion can't working properly due to {table name} included table prefix.

I haven't think it properly to fix the root cause.  Sorry folk.  May be I revert to the original statement and test it before I commit another patch.

Besides, I would like to clarify the approach of coding SQL statement of independent database engine.  Use MySQL as standard and translate the specific SQL syntax to other database engine in sql_t() function?

Umbrae

unread,
Feb 5, 2008, 1:57:34 PM2/5/08
to habari-dev
Seems like you're dead on, Owen.

Link to changeset:

http://trac.habariproject.org/habari/changeset/1338

Umbrae

unread,
Feb 5, 2008, 1:58:11 PM2/5/08
to habari-dev
And like usual, I'm late. Whoops.

Owen Winkler

unread,
Feb 5, 2008, 3:05:39 PM2/5/08
to habar...@googlegroups.com
Raman Ng (tinyau) wrote:
> Sorry Owen, the changes are applied by me without test it thoroughly
> even r1339 has been changed to use double quote.
>

I think there has been a couple of subsequent commits that address these
issues. I haven't tested them myself yet.

Also, I see what you're saying, since the schema files don't have the
table names, and actually use a different method to apply the prefix
altogether.

Someone's going to have to test all this out and make sure it works
before release. Nobody likes SQLite being broken. :(

Owen

Reply all
Reply to author
Forward
0 new messages