SMF icon indicating copy to clipboard operation
SMF copied to clipboard

SQLite compatibility

Open norv opened this issue 14 years ago • 51 comments

SMF 2.0 is only supports officially SQLite 2.8. SQLite 3.x is backwards incompatible (or not guaranteed) with 2.x. The standard PHP driver for SQLite 3.x is the PDO driver. Which SMF 2.0 database layer does not support.

So the question is: are we going to implement SQLite 3.x support for 2.1, or just fix 2.8? My previous answer: support 3.x in any next version of SMF.

Notes: 2.x is extremely outdated. (this is an understatement) 3.x is almost certainly on the hosts supporting SQLite. Once a database is migrated to 3.x, one cannot go back. They both can be installed in parallel and work side by side on a server. SQLite has designed its 3.x so that it has different functions to create/open/work with a database, to enable that. SMF uses the SQLite 2 functions, i.e. install.php first lines: sqlite_open() http://www.php.net/manual/en/function.sqlite-open.php

(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0) This function only support database of SQLite 2 or below. For SQLite 3, you must use PDO.

Ref: http://www.php.net/manual/en/sqlite.installation.php

norv avatar May 25 '12 17:05 norv

Hummm ... no comments ... I would have thought the 2 people using sqlite would have chimed in :D ....

Yes it should be moved to 3/PDO however I don't think its worth the effort to make the change for such a seldom used feature. Also given is scant usage, testing it will take forever ... really we are still finding postgre and sqlite errors from the early days of 2.0 which is all about test coverage and real life usage.

IMO in 3.0 I would drop support for all but MySQL, this was a nice experiment but the gain vs the effort or development and support is just not worth it. If thats not possible, maybe move on to a more robust abstraction layer, or maybe you have!

Spuds avatar May 30 '12 13:05 Spuds

The database abstraction at the time was a nice shiny new object. Everyone thought it was the coolest things since sliced bread. After seeing how little it's been used and how much trouble it's been to fix and support, I'd agree at this point to let it go the way of the wind. Would be better if we just left it abstract enough that someone else can plug into it if they so desire. Off with it's head!

IchBin avatar May 31 '12 20:05 IchBin

Instead of dropping support for database engines, we should be supporting them through PDO.

We also need to get rid of this horrible abstraction layer and use something more standard. I don't care if it's our own or if we use a well-established code base, but the regex-based replacement stuff we have now is crazy, IMO.

Fustrate avatar Jun 01 '12 22:06 Fustrate

That sounds great for SMF3.0 :)

IchBin avatar Jun 02 '12 04:06 IchBin

but let's not drop support for it in the meantime. This looks terrible:

  • SMF < 2.0: No
  • SMF 2.0: Yes
  • SMF 2.1 - 3.0: No
  • SMF 3.0+: Yes

Fustrate avatar Jun 02 '12 04:06 Fustrate

Support SQLite 2.x is probably completely useless.

I have finally setup a VM with (hopefully, I still don't know if it works) SQLite 3. I'll try to work on it, but don't know if I'll be able to do anything.

emanuele45 avatar Jun 02 '12 12:06 emanuele45

nend has worked lately with these drivers on SMF 2.0, and may be interested in the issue.

/cc @sicommnend

norv avatar Jun 03 '12 16:06 norv

IMHO PHP's implementation of SqLite 3 isn't all that great. Also on PDO, you can use a SqLite DB but be warned, you may be using either SqLite 2 or 3 depending on how the server is set up. So with PDO your not going to be guaranteed use of the most current version of SqLite on the server.

sicommnend avatar Jun 13 '12 14:06 sicommnend

Here is what I use for SqLite 3 as I can't use PDO because on my shared host it uses SqLite 2. http://php.net/manual/en/book.sqlite3.php

sicommnend avatar Jun 13 '12 15:06 sicommnend

What host is it, and what version(s) of PHP does it have?

This particular Sqlite3 extension is PHP 5.3.0+ only, SMF 2.1 minimum required PHP version is 5.1.0.

norv avatar Jun 13 '12 15:06 norv

PHP 5.3.6 and the host is GoDaddy.

PDO drivers mysql, sqlite, sqlite2 PDO Driver for MySQL 5.0.77 PDO Driver for SQLite 3.x 3.7.4

Strange though shows SqLite 3, might have to check it out once again, I swear it used to use SqLite 2.

sicommnend avatar Jun 13 '12 15:06 sicommnend

Before we drop support for Postgres and SQLite 2.x we need to find out how many people are actually using them. If they're being used, we shouldn't drop support for them or it will irk those who are using them.

Oldiesmann avatar Jun 19 '12 01:06 Oldiesmann

As I said before, it looks really bad to not support something, then support it, then drop support again.

Fustrate avatar Jun 21 '12 16:06 Fustrate

I don't think we need to remove anything of what we have at the moment. We just need a bit of testing. For sure on postgre because I'm pretty sure it's buggy, at least the upgrade, probably the installer too...or it wat SQLite that was buggy?...or both? Don't remember any more.

To those that know more about SQLite (I'm almost completely ignorant about it): would be possible (and if so how difficult would be) to install SMF with the current SQLite 2 implementation and then switch to SQLite 3 for example with a mod?

emanuele45 avatar Jun 21 '12 16:06 emanuele45

SQLite 2 is compatible with SQLite 3 in that order. However a SQLite 3 database will not work with SQLite 2. So basically once you are upgraded there is no going back.

sicommnend avatar Jun 21 '12 16:06 sicommnend

You know I haven't done a database upgrade though, I know there where major changes in version 3 mainly with the formatting of the file. I think in the middle though you will have to have a conversion script to upgrade or downgrade because the database file contains the version. I haven't tried yet though but I believe SQLite will emulate the version that is in the db file.

sicommnend avatar Jun 21 '12 16:06 sicommnend

http://www.sqlite.org/version3.html

Here is a overview of changes. May be simpler to support both and give the option on install, because if this is done with a mod and the user uninstalls the mod then this may cause allot of headaches.

But basically the document is saying they are incompatible both ways. So in order to upgrade you will have to dump the database then reinsert the data in the version your upgrading or downgrading from.

sicommnend avatar Jun 21 '12 17:06 sicommnend

So, even if we'd be able to support 3.x in SMF 2.1 we couldn't drop the support for 2.8 unless we create a converter before.

/me thinks SQLite 3.x is for SMF 3.0.

emanuele45 avatar Jun 21 '12 17:06 emanuele45

Small bump to point those interested to tinoest job: http://www.simplemachines.org/community/index.php?topic=483878.0

emanuele45 avatar Aug 18 '12 19:08 emanuele45

We can continue support for SQLite 2.8 and 3.0 both. We simply name a new database abstraction file that uses sqlite3 specifically. This is better as it allows 2.8 to be used and for 3.0 to be implanted and migrated over properly. Having us try to migrate it seems like a troublesome task.

jdarwood007 avatar Aug 18 '12 23:08 jdarwood007