This issue has also been discussed in #74308: Support MS SQL databases, #783812: Allow db drivers outside of 'core', #778310: Update status for db drivers is missing, and probably other issues.

At present, third-party database drivers have to be copied to DRUPAL_ROOT/includes/database/{$driver}/database.inc.
There are a number of issues with db-driver handling in drupal, and reasons why the status-quo should change:

  • Adding a new driver requires copying files to a part of the directory-tree which is traditionally recognised as core - but, thou shalt not hack core.
  • Third party drivers are being published as though they were modules on Drupal.org (MS SQL Server, Oracle).
  • These drivers are not tracked by update-status.

Vendor lock-out

Most users are understandably reluctant to hack core. This means that non-core database drivers are significantly disadvantaged, because many users will see the process of adding a third-party driver as hacking core.

Vendors recognise this, and wish to have their drivers integrated into core to overcome this barrier (as can be seen in comments from Microsoft in #74308: Support MS SQL databases. Drupal doesn't have a policy (that I can find) on accepting third-party drivers into core, which leaves vendors uncertain of what they need to do to gain entry.

This uncertainty is likely to discourage vendors, which is bad news for the Drupal community. Vendors may start with a simple db-driver to utilise their product, but a positive response can encourage them to contribute more resources, maintain and improve their drivers, and become a positive input to Drupal.

Suggestions

  • Add a standard (non-core) file-system path for db drivers. E.g. DRUPAL_ROOT/sites/all/db_drivers, DRUPAL_ROOT/sites/foo/db_drivers, etc.
  • Extend the project and update-status modules to support a new type of project: db_driver.
  • Suggest a standard package format for the new db_driver project-type, including a .info file to support update-status.

In addition, I would then like to move sql-lite and pgsql out of core and into db_driver projects. This would allow updates/fixes to these drivers to be made without having the burden of a core-release: for pgsql/sqllite users, updates can be delivered quicker; for mysql users, they won't be prompted for an unnecessary core upgrade.

Policy for core db-drivers

Moving the pgsql and sql-lite drivers out of core would simplify an official policy for integrating third-party drivers into core:

MySQL, as the most popular db-driver, shall stay in core. All other drivers shall be contrib projects.

With db-drivers becoming a recognised project-type, the necessity of having additional drivers in core would be removed. The benefits of reducing the number of core db-drivers to a single driver are:
1. core isn't burdened by extra releases for a feature which is irrelevant to the majority.
2. development/bug-fixes for the additional db-drivers can be quicker, given that they don't have the burden of requiring a core-release.

This also ensures a level playing field for all: the choice of which drivers are provided in core is no longer arbitrary. Removing the distinction between a few privileged db-drivers and other third party db-drivers removes a potential dis-incentive for vendors.

I've kicked this topic about in a bit more detail on my blog too. Discussions are welcomed on my blog, but please keep suggestions and responses in favour or against in this thread, so it's tracked by the issue-queue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

As noted on the linked blog, Cassandra, MongoDB, CouchDB, and other such systems are not SQL servers. Therefore they are not relevant to this discussion, as the DB layer in Drupal 7 is SQL-specific. There's nothing wrong with Document DBs, but they are a different animal and not a drop-in replacement for MySQL or Oracle or Postgres by any means. You don't use those with Drupal's "DBTNG" database layer.

That leaves only a tiny number of SQL databases of relevance. PDO, the PHP database system on which Drupal's DB layer is built, theoretically has support for ten drivers: MS SQL, Firebird, "IBM", Informix, MySQL, Oracle, ODBC, PostgreSQL, SQLite, and 4D.

Of those Firebird and 4D are marked Experimental and "don't entirely work yet". 4D I know in particular is not a full SQL database, and so could not be used to run Drupal anyway. Firebird, as far as I'm aware, has been broken for a long time. I can't say that I've ever heard of someone using Informix or "IBM" (whatever that is; isn't it DB2?) with PHP.

So realistically, the DBs that are even relevant to support are: MySQL, PostgreSQL, SQLite, Oracle, MS SQL, and ODBC. Of those six, three already exist in core; that's a step up from the one and a half we supported in Drupal 6 (MySQL and, half-heartedly, PostgreSQL).

So that means we're talking about, really, three drivers at most: Oracle, MS SQL, and ODBC. That's it. I don't believe therefore that this is the significant issue you're making it out to be. Certainly creating a new category of project on Drupal.org to support a category that has an upper bound of three items is unnecessary overkill.

Additionally, the changes necessary to support DB drivers as components alongside modules and themes, or as modules as was previously discussed, would necessitate non-trivial work along the critical path. The "find a DB driver to use" logic is executed on every single request of any sort, and therefore we do need to be "counting cycles" for that. Disk IO is a slow operation, and we cannot cache a DB driver location in the DB the way we can for module locations, so that's a non-trivial amount of work Drupal would have to do on every single page request. Drupal 7 has enough performance issues already. :-) Such changes are also substantially out of scope for Drupal 7 anyway when we are approaching beta and could not even be considered until Drupal 8.

The current driver structure was written with contrib-extensibility in mind (Oracle in particular). Unlike in previous versions of Drupal, adding DB drivers requires modifying not one single existing line of Drupal core; all it requires is adding a directory to a specific location in a supported way. That is not hacking core; it is a new supported extension mechanism. If someone thinks that constitutes hacking core, well, they're wrong. :-) That's no more hacking core than the Libraries module in Drupal 6 was hacking core.

As for moving the non-MySQL drivers out of core, it's been noted before that when something is moved out of core it tends to die from lack of attention. The only reason that PostgreSQL and SQLite have gotten the attention they've gotten to date is because they're in core, and therefore their 100% compatibility is considered a release-blocking issue. If those move out of core, I fully expect the support for them would drop dramatically. We've gone to great lengths to get support for more DBs in core; let's not roll back that work now.

Which then leaves the question of moving the extant MS SQL or Oracle drivers into core proper. I don't believe that is necessary. For one, both MS and Oracle have volunteered and been working to set up test boxes of their own to run the core unit test suite on those databases; I am not sure of the status of those efforts but I have spoken with reps from both companies about it. That's something that SQLite or PostgreSQL cannot do as there is not a single vendor behind them. For another, and I fully understand that not all may share this viewpoint, Drupal is a Free Software project. If we put a driver in core, that means we're committing to the Drupal community supporting it. As a Free Software community we cannot reliably support a proprietary, closed source product in a community fashion. Thus we cannot properly support it in core, nor should we be expected to. Drivers for proprietary products do not belong in the core of a leading Free Software product. We should support them if at all possible, and we do, and leading members of the Drupal community have been working with both firms.

In conclusion:

- We cannot make this sort of change this late in the Drupal 7 development cycle.
- We are talking about, in practice, an extremely small number of use cases: 2, perhaps 3.
- Those use cases are already addressed.
- The question of which drivers are accepted to core it not arbitrary: Free Software DBs are supported in core, proprietary ones are not.

I believe this is a won't fix, but will leave it open briefly to allow others to respond. I don't believe there is anything to do here.

manarth’s picture

Perhaps this could also be described as a documentation bug.

The question of which drivers are accepted to core it not arbitrary: Free Software DBs are supported in core, proprietary ones are not.

That's a reasonable yard-stick to me. I had a hunt, but couldn't find any documentation which would describe how/why a DB driver would be accepted into core. I'd like to help write documentation around this if it doesn't already exist.

adding DB drivers requires modifying not one single existing line of Drupal core; all it requires is adding a directory to a specific location in a supported way.

I'm not sure I entirely agree with sticking extra directories in /includes/database, and given that settings.php has been found, there would only be 2 locations to check: sites/all/database and sites/foo/database. Or settings.php could define a directory-path variable. It need not be the performance hit suggested, and it would keep changes away from a directory that - to most people - will be considered core.
Keeping non-core code in sites/xxx makes deployment and upgrades simpler.
And again, there's no (easily findable) documentation which specifies that contrib drivers should be added to /includes/database. At the moment, they have to be there because the code requires them to be there, which isn't the same as intending them to be there.

Finally, there are 2 significant reasons for treating DB drivers more like 'projects':

  • Usage-tracking: provides users the information to judge how viable a particular choice might be, and provides module-maintainers an indication of how much effort they should spend ensuring their modules work across different DBs.
  • Update-reporting: If a bug exists in a DB driver, it could potentially impact every single page on a site. Core drivers can be notified via a core-release, but that still leaves non-core drivers out in the cold.

We cannot make this sort of change this late in the Drupal 7 development cycle.

Some of these changes are trivial - such as supporting a new include-directory. Others - like adding usage-tracking/update-reporting for DBs would take longer, but could be targeted at D8, and maybe back-ported. I wouldn't agree with "Won't fix" - if it's too short notice for D7, I still think some of these are genuinely useful for D8 and worth keeping in the backlog.

Crell’s picture

That is not an officially adopted policy; it's more an informal policy of the DB team, one that as DB maintainer I fully support. :-) I am open to documenting that somewhere if we can determine an appropriate somewhere.

I still don't consider adding DB drivers to be hacking core, any more than adding install profiles (which live in /profiles) to be hacking core. Install profiles have been available since Drupal 5.

Making DB drivers support the update module (essentially what you're asking for) would require them to have .info files. It would also require reconfiguration on Drupal.org. I cannot speak to the viability of the latter, but I highly doubt that infra team would be inclined to do so when we're on the cusp of completely changing both Drupal.org itself and our entire code management infrastructure (the Git Migration). That would be up to dww, probably, and would likely have to wait for Drupal 8 either way.

Damien Tournoud’s picture

I strongly disagree here.

Because database engines are not modules, themes or installation profiles, there is no way to properly package them with Drupal. They are essentially nothing more then core patches.

Because the database layer doesn't use standard Drupal plugin mechanisms, we cannot, as noted above:

  • Use drush_make to package distributions of Drupal containing database drivers
  • Have update status notifications
  • Have usage status for those projects

The way forward is to make the database layer use the standard mechanisms offered by Drupal core, by creating a new project type for those drivers, in addition to 'module', 'theme' and 'profile'. On the drupal.org side, we will have to create a new project type also, but this should be as easy as adding a taxonomy term to the correct vocabulary.

Damien Tournoud’s picture

Priority: Normal » Major
Status: Active » Needs review
FileSize
12.73 KB

Promoting to major.

Here is a first shot at a patch. Honestly, the changes look very minor.

Damien Tournoud’s picture

We are talking about, in practice, an extremely small number of use cases: 2, perhaps 3.

I don't believe so. There will be several proper drivers in contrib (SQL Server, Oracle, Drizzle, MongoDB), and probably several pseudo-drivers (extending existing drivers to add stuff like caching, different load-balancing strategy, health control for slaves, etc.).

Crell’s picture

Priority: Major » Normal
Status: Needs review » Needs work

MongoDB is not a DBTNG driver, nor is any other Document DB. chx has been experimenting with MongoDB as one just to prove that it can be done, not because any sane person would ever actually do so. :-) Drizzle has no PDO driver that I'm aware of and has forked from MySQL so it cannot use the MySQL PDO driver.

I don't know how many generic (ie, not site-specific) subclassed drivers we're likely to have and then you're talking about a very small percentage of sites that would be using them. So I definitely don't see this as major.

This is also technically an API change (adds required files to DB drivers), and dear god in heaven this is alpha-7 with a beta coming soon. Stop with the API changes.

Also, using the "sometimes the parameters mean X, sometimes Y, depending on if the first is NULL" pattern for db_autoload() gets an immediate won't fix from me. That's an incredibly bad pattern that serves no purpose other than to make code harder to follow.

I'm inclined at the very least to move this to Drupal 8, although I still lean toward won't fix.

Damien Tournoud’s picture

Priority: Normal » Major
Status: Needs work » Needs review

Well, this is definitely major if we want to support third-party database drivers properly *and we definitely want to*. I'm not sure why justify your aggressivity against the whole idea of properly supporting this.

MongoDB is not a DBTNG driver, nor is any other Document DB. chx has been experimenting with MongoDB as one just to prove that it can be done, not because any sane person would ever actually do so. :-)

I was explicitely speaking about the experimental "mongodb caching" driver from chx. This is definitely a DBTNG driver. I never said nor implied that Document DB are DBTNG drivers.

Drizzle has no PDO driver that I'm aware of and has forked from MySQL so it cannot use the MySQL PDO driver?

Drizzle supports connecting by PDO_MySQL perfectly. It actually has two interface, the legacy mysql client protocol and the new drizzle protocol. A Drizzle driver can and should be done. See #809810: Support the Drizzle database engine for context.

I don't know how many generic (ie, not site-specific) subclassed drivers we're likely to have and then you're talking about a very small percentage of sites that would be using them. So I definitely don't see this as major.

My guess is that most big hosts (including Acquia Hosting) will provide a site-specific driver. There is currently no way to do that properly, and it's a big failure of the whole revamped database layer.

This is also technically an API change (adds required files to DB drivers), and dear god in heaven this is alpha-7 with a beta coming soon. Stop with the API changes.

This is definitely a (small) API change, but you cannot argue at the same time that "this is an API change that will affect database drivers writers" and "there will be very few database driver writers".

Also, using the "sometimes the parameters mean X, sometimes Y, depending on if the first is NULL" pattern for db_autoload() gets an immediate won't fix from me. That's an incredibly bad pattern that serves no purpose other than to make code harder to follow.

Yes, this particular pattern is not very pretty. Sure. But we have it all over the place already, and there is no clean way to do this that I can see.

mikey_p’s picture

Subscribing, to better track for DBTNG backport.

I'd really be in favor of some sort of standardized location for these things, as D7 is released I expect the number of folks using the DBTNG backport in increase, and one of the main reasons they do so, it to use some of the new drivers. I'd love to have a standard way to install these both for 7 and 6.

Can we please stop arguing semantics about what a driver connecting to? If I write a carrier pigeon driver, I don't care what you say abou it, but it's using the same APIs to connect to Drupal. That's all that matters.

Dries’s picture

Version: 7.x-dev » 8.x-dev

It would be nice to get support for this as getting more database companies to adopt Drupal seems like a really smart strategy. At the same time, we're way beyond the point to figure this out, and I'm wary that there will be at least 3 follow-up issues to get this right (i.e. properly integrated with status update and whatnot). The proposed patch only implements the bare minimum. It's a bit sad but we should postpone this to Drupal 8.

+++ modules/update/update.fetch.inc
@@ -144,6 +144,7 @@ function _update_process_fetch_task($project) {
+    $h = fopen('/tmp/update', 'a'); fputs($h, print_r($xml, TRUE)); fclose($h);

Debug output?

sepeck’s picture

subscribe

chx’s picture

To clarify: http://drupal.org/project/mongodb_dbtng Drupal installs, I can log in and see tabs, node creation, user creation and filter tests pass.

Yes. It's crude. It's insane. But there is no reason to say it does not work.

chx’s picture

So here is how we can solve this in D7 without patching core. Create a .module file, 0 byte, write a .info file, put the database driver into the aptly named directory below the module and then add a line into README.txt "copy or symlink this directory into includes/database".

Damien Tournoud’s picture

So here is how we can solve this in D7 without patching core. Create a .module file, 0 byte, write a .info file, put the database driver into the aptly named directory below the module and then add a line into README.txt "copy or symlink this directory into includes/database".

That gives you nothing:

  • Packaging: you have to add a symlink, which is not supported by drupal.org packaging system
  • Update status: you will only get update status if the module is enabled, but you have zero reason to enable the module (because it's not required by the installation and the site will work without it)
  • Usage data: same applies
Damien Tournoud’s picture

Everyone should realize that not properly supporting database drivers like this means that the only way to get a third-party driver into a distribution is by patching core. Drupal.org doesn't (yet) support patches in .make files, but might one day.

Anyway, having no packaging, no update status and no usage data means that third-party drivers are not supported in Drupal 7. It's not really a big deal, but we all have to be clear about this.

mfer’s picture

@Damien Making changes to the API to make database drivers a top level entity (like a module, theme, or install profile) would be great. I previously looked into this as well. But, to do so would not be simple, would be an API change, and is past the point in the D7 release cycle to include it. I look forward to seeing patches in D8. Not sure there is a solution you'll be happy with until then.

Damien Tournoud’s picture

We will definitely make API changes up until 7.0 is released, and we will probably do so in 7.1, 7.2, 7.3, 7.4 etc.

The mere argument of "API change" is not an argument at all. API changes have to be avoided, but we make them all the time, on the argument that they bring more benefit then trouble. The changes described in the patch in #5 are pretty much self-contained, and will not impact *anyone* except the writers of database engines, who are mostly all participating in this issue.

Crell’s picture

There's also performance implications to consider, and the potential for introducing new bugs. We're talking about the critical path here so have to be careful, more careful than I want to be when we're desperately trying to squeeze out a beta. :-)

manarth’s picture

It's a question of API change vs breaking backward-compatibility.

If, for example, the look for db drivers in other directories in addition to DRUPAL_ROOT/includes/database feature were added after the first release, this wouldn't break sites when they upgrade. So I don't think it's too late for D7.

Dries said in #10: I'm wary that there will be at least 3 follow-up issues to get this right.
It's better to get this right than to rush a half-baked patch in to beat a deadline. Let's work on agreeing an approach and implementing it, and maybe if we're convincing enough it'll end up in D7 :-)

chx’s picture

Pardon me for this thought but I like this. Let Drupal 7 be a release when drivers are not yet modules. There are going to be such problems every time someone tries a Drupal on a non-MySQL database... let it mature. With plugins in D8, we will be able to do a lot more, anyways and then those drivers will need to become modules anyways so they can implement plugins.

dww’s picture

Status: Needs review » Needs work
Issue tags: +Update manager

DamZ asked me to comment here about the update status + usage statistics implications of this patch. I don't have time or head-space to do a thorough review, but off the top of my head, the following would have to be addressed:

=== update manager/status ===

- Although the changes in the patch should make it so we fetch data and process the status for any DB drivers, we'd need changes in update.report.inc to display that information properly.

- There's obviously nothing here to teach the update manager how to upgrade a DB driver via authorize.php and friends. That'd require (at least):
-- a DatabaseDriverUpdater class in modules/system/system.updater.inc:

class DatabaseDriverUpdater extends Updater implements DrupalUpdaterInterface

-- changes in modules/update/update.manager.inc
-- maybe some other stuff, I'd have to look more carefully

=== drupal.org ===

- Yeah, we'd probably just need a new term in the Project types vocab for the new project type
- It's possible that the release history XML generation script would Just Work(tm) for releases of the new project type
- Certainly serving the release history XML will Just Work(tm)
- I'm pretty sure that the usage tracking stuff isn't going to care about the project type
- It's possible that the http://drupal.org/project/usage page would also Just Work(tm)

So, pretty easy on the d.o side. Mostly 1 trivial change, and then checking that everything else behaves as expected.

I'm not in a great space right now to say much else about this issue, so instead of flu-induced rambling, I'll just leave it at that for now... ;)

quicksketch’s picture

Priority: Major » Normal

As a problem that affects a very small percentage of Drupal sites, and even then only in a minor way, I don't think we can classify this as major. Per #1050616: Figure out backport workflow from Drupal 8 to Drupal 7, major and critical bugs are now preventing development in other areas of Drupal core. If we'd like this issue to prevent development of features entirely in Drupal 8, please re-categorize again, but I don't see the actual harm here.

erinlalouve’s picture

hi,

I have done a Cassandra driver based on cassandra-pdo driver. What I understand here is that I can't share it easily to the community or things have changed on drupal8 and I can share it as a project without asking users to hardlink the project to core/lib/Drupal/Core/Database/Driver ?

sun’s picture

Issue summary: View changes

Unless I'm mistaken, #2209307: Convert database drivers into a regular extension type would help to resolve ~80% of this?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative

#3129534: Automatically enable the module that is providing the current database driver converted contrib database drivers to extensions, so this should be resolved now. Marking outdated.