Closed (fixed)
Project:
SimpleTest
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
12 Mar 2009 at 23:30 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
carlos8f commentedpatch implements a
SHOW TABLESquery instead of selecting frominformation_schema.Comment #2
boombatower commentedCommitted.
Thanks.
Comment #3
Freso commentedThis breaks PostgreSQL support, as
SHOWis something completely else there.Edit: Or, I guess, it's not something completely different, but it doesn't support
SHOW TABLESany way.Comment #4
boombatower commentedHow's this?
Comment #5
Freso commentedIsn't this just the way it was before the patch from #1? Ie., it won't work on MySQL < 5? I'm only using MySQL 5 and PostgreSQL (8.3), so it wouldn't bother me a whole lot; but if the module aims to support the same software setups as Drupal core...
Comment #6
boombatower commentedVery similar to previous way, exactly the same SQL query.
I'm not sure what else to do unless someone has some SQL magic...
This module already requires PHP 5, which is above Drupal 6 requirement...I think it is fair to require MySQL 5 as it is for testing and should be on a developers machine anyway.
Then again Drupal 6 doesn't tend to support Postgres that well....so which do we choose?
Comment #7
Freso commentedWell. SimpleTest 6.x-2.x is aiming to be compatible with the test module in Drupal 7, which has various requirements like PHP >= 5.2 && ( MySQL >= 5 || PostgreSQL >= 8.3 ). So... it might be best/easiest to simply set the same requirements for SimpleTest 6.x-2.x?
Comment #8
boombatower commentedI very much agree...just making sure everyone was fine with that. So commit patch?
Comment #9
Freso commentedFine with me, but not with carlos8f. Perhaps you could take a quick census in #drupal or something?
Comment #10
boombatower commentedCommitted revert and added node in README.txt.
Comment #12
neilnz commentedReopening.
You've still got no Postgres compatibility, so cleaning the environment doesn't work for Postgres users.
Attached a patch to provide equivalent functionality on postgres (switching on $db_type). Other databases may need to be considered also though.
It's a pity the database abstraction layer can't provide a list of tables!
Comment #13
boombatower commentedI thought that information_schema.tables was cross-compatible?? At least that is what I was told.
http://www.postgresql.org/docs/7.4/static/infoschema-tables.html
Comment #14
neilnz commentedOn second look, yes it should be, but it's different.
Here's a row that should be returned:
The module is checking if table_schema = $database, but as you can see, in Postgres table_schema actually points to the schema, not the database. The table_catalog points at the database name. This is PostgreSQL 8.3.
Have a look at how db_find_tables() does this in Drupal 7 (and especially at buildTableNameCondition() in includes/database/schema.inc for how it puts together this query. It seems to match table_catalog to the database name.
Also, another bug in this code is that simpletest_get_like_tables() prefixes the $base_table in its search with $db_prefix, but if the site is actually using db prefixing, this will fail because drupal_web_test_case.php overrides $db_prefix to simpletest$uniqid (without preserving any configured prefix), so the simpletest temporary tables are actually not pre-prefixed at all, so applying the site's $db_prefix (if not '') in simpletest_get_like_tables() will cause it not to match anything.
Comment #15
neilnz commentedAttaching a patch against simpletest.test to self-test the database functionality. This patch should work in either D7 using db_find_tables() or in D6 using simpletest_get_like_tables(), whichever is available.
I was trying to call simpletest_clean_environment(), but of course calling that from within a unit test causes the temporary environment that the test is executing under to be destroyed (chicken/egg problem).
Hopefully this will allow you to check this works on all databases.
Comment #16
RockyRoad commentedI confirm that
SHOW TABLESis not ANSI SQL, and fails in PostgreSQL.I added (manually, because patch failed on v 1.1.2.11 2009/04/23 05:39:51)
simpletest.test.checkdbcleanup.patchtest and launched it again in may pgsql localhost installation.Unfortunately it fails, it several points for me:
* Exception: pg_query() [function.pg-query]: Query failed: ERROR: relation "simpletest705219cache" does not exist
Warning database.pgsql.inc 151 _db_query()
* Exception: query: UPDATE simpletest705219cache SET data = '.....', created = 1243442532, expire = 0, headers = '', serialized = 1 WHERE cid = 'schema'
User warning database.pgsql.inc 172 _db_query()
(consequence of previous !)
* Assertion failure: "Checking for any missed tables that should have been cleaned up"
Other simpletest.test 318 SimpleTestFunctionalTest->testEnvironmentCleanup()
Disabling testEnvironmentCleanup() makes the whole block.test succeed again.
Comment #17
neilnz commentedRockyRoad, are you on D6 or D7?
For my test case to succeed on D6, you either have to apply my (slightly bad) patch from above for simpletest_get_like_tables(), or fix it in the way I described later, by changing "table_schema" to "table_catalog" in that function.
Would anyone be interested in me rolling a new patch for the Postgres fix + the test case in the way I described?
Comment #18
RockyRoad commentedhi neilnz,
I'm running D6.
I must confess I didn't really study your code yet.
I came to that bug ... to be sure SHOW TABLES wouldn't come up again (I found it, or similar, in several other modules).
But if I have time (and knowledge, I'm quite new to drupal, though having programming experience) I'd be glad to help you polishing your patch.
Comment #19
neilnz commentedAdding this to our code sprint for fixing
Comment #20
neilnz commentedRolled a patch to change the use of information_schema.tables to be cross database
Comment #21
boombatower commentedCommitted.