MyBB Community Forums

Full Version: SQLite not the best choice?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have just set up a MyBB 1.4.4 install on Solaris/SPARC 10 10/08 using Sun's CoolStack 1.3.1 version of PHP 5.2.6, with a SQLite database.

For further background, I'm running my PHP as a FastCGI process with nginx 0.7.30. The PHP process is running as the same user/group as the user who owns the files.

The issue I am seeing is that various operations throw nasty-looking SQL errors (not even framed in the MyBB page). For this reason, I've yet to open the forum to users.

A couple of example errors:

While trying to edit a forum announcement in the ACP:
Fatal error:  Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDOStatement instances' in /home/pancakes/www/bb/admin/inc/functions.php:37
Stack trace:
#0 [internal function]: PDOStatement->__sleep()
#1 /home/pancakes/www/bb/admin/inc/functions.php(37): serialize(Array)
#2 /home/pancakes/www/bb/admin/modules/forum/announcements.php(429): log_admin_action(Object(PDOStatement), 'You can't post ...')
#3 /home/pancakes/www/bb/admin/index.php(378): require('/home/pancakes/...')
#4 {main}
  thrown in /home/pancakes/www/bb/admin/inc/functions.php on line 37

While trying to install MusicalMidget's Board Messages plugin:
Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "unsigned": syntax error' in /home/pancakes/www/bb/inc/db_pdo.php:67
Stack trace:
#0 /home/pancakes/www/bb/inc/db_pdo.php(67): PDO->query('???CREATE TABLE...', 4)
#1 /home/pancakes/www/bb/inc/db_sqlite3.php(189): dbpdoEngine->query('???CREATE TABLE...')
#2 /home/pancakes/www/bb/inc/db_sqlite3.php(261): DB_SQLite3->query('???CREATE TABLE...', 0)
#3 /home/pancakes/www/bb/inc/plugins/board_messages.php(55): DB_SQLite3->write_query('???CREATE TABLE...')
#4 [internal function]: board_messages_install()
#5 /home/pancakes/www/bb/admin/modules/config/plugins.php(193): call_user_func('board_messages_...')
#6 /home/pancakes/www/bb/admin/index.php(378): require('/home/pancakes/...')
#7 {main}
  thrown in /home/pancakes/www/bb/inc/db_pdo.php on line 67

Each and every failing plugin (alas, this is most of the ones I've tried fail to install/activate) puke on line 67 of db_pdo.php. Looking at that line, there's not much to figure out where to start. (It executes the SQL query.)

My first question is probably "WTF are all those question marks in the queries?", followed by "Why is a core part of MyBB trying to serialize operations when it really doesn't gain anything even on databases that support it, let alone on ones that don't?".

I'd really love to use SQLite for MyBB; it's one of the reasons I chose MyBB. (Another was the Openfire integration plugin... Oh, and the browser info plugin.) I really don't have the need for the overhead of MySQL or Postgres for what will be a low-traffic forum. But, since I have a working pgsql already, I'd probably prefer to use that. Are there any show-stoppers with Postgres? Or should I somehow try to figure out how to make SQLite work right?

Let me know what info you need, and I will do my best to provide it. I haven't (yet) seen any errors on the user side, just in the ACP. So, the URL to the forum is kind of useless, especially since I really don't want to give the world an admin login to what will (ideally) be a live site in the next day or two...
We can't really support broken plugins, as they're not written by MyBB, they'll have to be made to work with different SQLs by the author. SQLite support was only added in 1.4 and there aren't many problems considering that fact. This can make it hard for plugin developers, though, as they'll have to figure out the differences between MySQl and SQLite.

I actually decided to test SQLite to destruction and found about 7 or 8 errors and they have either been fixed, or will be fixed (when I set something up for testing).

I can't seem to reproduce the announcements error. If you can PM me with some detailed reproduction steps, I'll investigate.
To answer your question, no, SQLite is not the best choice.

The best choice is Linux + Apache + MySQL + PHP quite simply because that is what everyone uses and tests with. Any other setup is exotic and not nearly as well tested, especially not by plugin authors, and you'll run into trouble more often than not.

I love nginx and sqlite, I use both of them for my own projects that are not related to PHP. However in the PHP world you can't get very far with them, because PHP softwares are dominated by LAMP. My own MyBB plugins do not support nginx, SQLite or anything other than LAMP even though I do use nginx and SQLite elsewhere. There's little to no point in it for PHP.
Thanks, Matt. I PMed with the exact steps I can reliably reproduce the error with. As for the plugins, it appears that about 1 in 10 actually manages to activate. So, I'll have to do some digging there.

I couldn't find any forum posts complaining about the SQLite support, so I was assuming that either: A) it was rock-solid; or, B) no one actually uses it. I was hoping for the former, though it's appearing the latter is the case.

Frost, 1) Linux is out of the question as I've never gotten it to run as a stable operating system on SPARC; 2) nginx takes advantage of eventports, and does basic webserving in a much smaller memory footprint than Apache; 3) I have Postgres and Oracle already running on this machine, why do I want MySQL also?

I fail to see how your MyBB plugins actually could care about which webserver is in use. I realize your SEO plugin "requires" .htaccess, but I disable that on Apache anyhow. (Why should I stat() the hierarchy each request?) So, if I were to use it on either Apache or nginx, I'd be doing some minor rewrite rewriting. So, how do your plugins fail on nginx? I've come across nothing (that doesn't require .htaccess, often for lame things that require loosening Apache security anyhow) written in PHP that doesn't run properly with nginx+FastCGI->PHP (and this is certainly not my first server where Apache is not even running), so I'd be curious how your plugins manage to fail.

And, do either of you have any suggestions on where to start looking for errors in the plugins? I'm really getting suspicious of all the question marks I see in the SQL statements that are erroring out...

Frost, I'll actually be starting with trying to troubleshoot what's wrong with the Subforum Bulb, since you're watching this thread (apparently Smile ) and it's your plugin.

For reference, the error it throws when I try to activate it is:

Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "AND": syntax error' in /home/pancakes/www/bb/inc/db_pdo.php:67
Stack trace:
#0 /home/pancakes/www/bb/inc/db_pdo.php(67): PDO->query('SELECT sid FROM...', 4)
#1 /home/pancakes/www/bb/inc/db_sqlite3.php(189): dbpdoEngine->query('SELECT sid FROM...')
#2 /home/pancakes/www/bb/inc/plugins/subforum_bulb.php(185): DB_SQLite3->query('SELECT sid FROM...')
#3 [internal function]: subforum_bulb_activate()
#4 /home/pancakes/www/bb/admin/modules/config/plugins.php(200): call_user_func('subforum_bulb_a...')
#5 /home/pancakes/www/bb/admin/index.php(378): require('/home/pancakes/...')
#6 {main}
  thrown in <b>/home/pancakes/www/bb/inc/db_pdo.php</b> on line <b>67</b>

I'm including this to show that the errors I am seeing from plugins vary all over the map. While I realize they're not supported by the MyBB team, it may be useful to have 2 different plugin errors in hopes that it may trigger a lightbulb for someone. Smile Perhaps the end-result of this could be a "How to make your plugins work with all supported database backends" guide or something. Cool
I don't know if my plugins fail on nginx+sqlite. It's just that my plugins don't support them, i.e. I have never tested them in such an environment and I won't test nor fix errors unrelated to LAMP - you're welcome to send docs as well as patches though if they don't break the code for MySQL and don't make it more complicated.

You were asking for the 'best choice', and LAMP is the best choice (in regards to compatibility and likelyness to run into problems), simply because it's the #1 tested setup for almost anything related to PHP.

I agree with you on the advantages of nginx / the things you don't like about apache / mysql, and if you don't want to install them that's your choice, but running into problems like this is to be expected under these conditions. If you don't want to change your setup, instead of asking for best choices, you should ask for how to fix the issues you are seeing. Unfortunately the number of people who can help you with that is extremely low. At least I don't know anyone who is running sparc + nginx + sqlite.
Well, I wasn't really asking for the 'best choice'... I was hoping to come up with a good subject for future searchers. Cool

And, sadly, I think the biggest incompatibilities with PHP is actually PHP itself. There's just so many different possible configuration combinations, you're unlikely to come across the same exact options from one host to the next. Wink

And, I doubt that the fact that I'm running Solaris on SPARC is the cause of these issues. I also doubt that nginx is at fault. My hunch from the get-go is that there's MySQL-specific things in the SQL statements being executed. That's why I didn't just give up and use my an already-live DB server (I have none that are MySQL) when I first encountered an SQLite-looking issue; I'd probably be posting that I am having issues with Postgres, instead.

Right now, I'm looking at the plugins I've tried to install to see why some work and others don't. The odd thing is that executing some of the queries on the database file directly seems to work. I'm kind of wondering if PDO is doing some "massaging" which it ought not. There's also the possibility that the MyBB PDO wrapper is doing something odd, too. First I have to find the pattern, then I can find where things are failing. Smile
So, it looks like most plugin issues with SQLite are due to poorly-written SQL, overly MySQL-specific queries, or mixing PDO and non-PDO functions. (Amazingly enough, using non-PDO functions with PDO (MySQL) works more often than it ought.)

I'll be giving back all the changes I manage to make to plugins, in appropriate threads. So, that part of my issue is moot (and warrants no further discussion in this forum after this post). Cool

I have exchanged PMs with MattR. It looks like I may have somehow come across a bug with the forum announcement that has yet to be reproduced. Luckily, I have other servers I can see if I can duplicate it on, once I get my board up and running. Smile

I think I've also managed to find a few other bugs. However, I'm about to reconfigure the site to use MySQL (at least for the time being) and deploy it with that. I can then look into the SQLite issues on a few platforms to see if I can 1) find the causes; 2) submit patches. Cool