It appears that the core simpletest framework re-runs the install process with a $db_prefix. On pgsql, we do CREATE DOMAIN {,small,big}int_unsigned CHECK (VALUE >= 0) in system.install. These have a single global name so re-running the install generates "already exists" errors.

There are a variety of ways out of this gotcha. My suggestion is http://drupal.org/node/257006. I do not think these are duplicate issues (this one is about unit tests throwing exceptions, that one is about unifying an inconsistency between how int, float, and numeric unsigned columns are handled), though my proposed solution conveniently fixes both.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bjaspan’s picture

Status: Active » Needs review
FileSize
1.43 KB

Actually, I decided to fix this more expediently by simply not trying to create the unsigned domains if they already exist. This gives a very short patch that makes the simpletests stop throwing exceptions on pgsql. This fix does not prevent the more comprehensive one contemplated in http://drupal.org/node/257006, but certainly lessens my motivation to take on the complex update issues. :-)

To test this patch, run any tests on pgsql. If they pass without exceptions, the patch works.

Freso’s picture

Component: unit testing » tests
FileSize
1.41 KB

For some reason, the patch didn't apply:

freso@nayru /s/h/l/h/drupal7> wget http://drupal.org/files/issues/simpletest-pgsql-create-domain-257009-1.p...
[...]
freso@nayru /s/h/l/h/drupal7> patch -p0 < simpletest-pgsql-create-domain-257009-1.patch
patching file modules/system/system.install
Hunk #1 FAILED at 305.
1 out of 1 hunk FAILED -- saving rejects to file modules/system/system.install.rej

The change was easy to do myself, so I did a re-roll using cvs diff -up. Reviewing now.

Freso’s picture

I tested it against #264836: Bike shed test fails (PostgreSQL?), which removed the PHP exceptions there. So it works as advertised. :)

However, it being in system.install... won't that mean that old sites upgrading to Drupal 7 won't get the benefit of this? Just curious, as that wouldn't be something we'd want... right?

bjaspan’s picture

This patch does not affect upgrade from pre-D7 sites. Upgrading does not run system_install(), so the pgsql domains are not re-created.

Freso’s picture

Status: Needs review » Needs work

Well, I'd say it shouldn't go into CVS until that is resolved.

bjaspan’s picture

Status: Needs work » Needs review

@Freso: You have not actually presented a problem with the current patch. The upgrade process from pre-D7 is not affected by the bug I reported and is not affected by the patch I've presented, so there is nothing to resolve regarding upgrading from pre-D7 sites pertaining to this bug before the patch can be committed.

I'm putting this back to "code needs review" so I do not forget to do so later. However, if you can describe an actual problem with the patch, by all means do so. Thanks!

Freso’s picture

@bjaspan: The perceived problem (which I thought you confirmed #4) is that sites upgrading from 6.x will still have tests fail on pgsql systems, as the pgsql domains are not re-created as you put it. I haven't tested it, so can't say if this is really so, but, yeah. I thought you confirmed this in #4 - sorry to put words in your mouth if you didn't. :)

catch’s picture

I think the issue is that simpletest.module is running that hunk of code for a second time - which would otherwise never happen - so the changes only exist to accommodate this behaviour, and therefore only in D7 (afaik the D6 contrib verson of simpletest doesn't do this either). Since this isn't immediately obvious (and I might not have it right anyway) a code comment might help.

bjaspan’s picture

Comment added.

mustafau’s picture

Status: Needs review » Reviewed & tested by the community

#9 eliminates exceptions on pgsql.

Freso’s picture

There's a line with excessive whitespace introduced after the new comment lines. Looks okay apart from this. I didn't test.

mustafau’s picture

Re-roll without whitespace.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

I've extended the documentation a bit and committed this patch to CVS HEAD. Thanks everyone.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

Darren Oh’s picture

Version: 7.x-dev » 6.x-dev
Component: tests » system.module
Assigned: bjaspan » Unassigned
Status: Closed (fixed) » Patch (to be ported)
FileSize
1.79 KB

Drupal 6 needs this, too.

Darren Oh’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Looks like you've even included Dries' comment changes. Looks good, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.