Bug Report #1236
Database introspection is cached when caching is disabled
| Status: | Closed | Start date: | ||
|---|---|---|---|---|
| Priority: | High | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | Core | |||
| Target version: | 2.3.3 | |||
| Resolution: | fixed | Points: |
Description
When caching is disabled, a call to clear_cache() is required for introspection to return correct results. clear_cache() should have no effect with caching disabled.
Test Case:
$db = new Database(array(
'cache' => FALSE,
'connection' => array(
'type' => 'mysql',
'host' => 'localhost',
'socket' => TRUE,
'user' => 'root',
'pass' => 'password',
'database' => 'testing',
),
));
$db->query('CREATE TABLE testtable ( first integer )');
$result1 = $db->list_fields('testtable'); // 1
$db->query('ALTER TABLE testtable ADD second integer');
$result2 = $db->list_fields('testtable'); // 2
// Correct results are obtained after clearing the cache
$db->clear_cache();
$result3 = $db->list_fields('testtable'); // 3
$db->query('DROP TABLE testtable');
try {
$result4 = $db->list_fields('testtable'); // 4
} catch (Kohana_Database_Exception $de) {
$result4 = FALSE;
}
Current Results:
- Results 1 and 2 match.
- Results 2 and 3 differ.
- Results 3 and 4 match.
- Results 1 and 2 should differ.
- Results 2 and 3 should match.
- Call 4 should throw an exception.
$result1should contain one more element than$result2.$db->clear_cache()should have no effect.
Possible Solution:
Utilize the regular query cache by calling $this->query() for introspection rather than mysql_query() directly.
Related issues
Associated revisions
Fixing #1236.
History
Updated by Jeremy Bush almost 3 years ago
It seems Pgsql has already been applied:
patch -p0 < 0002-Use-query-cache-for-introspection.patch
patching file system/libraries/drivers/Database/Pgsql.php
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
Mysql is out of date. Can you provide a new mysql patch?
Updated by Chris Bandy almost 3 years ago
Above patches updated and tested against r4227.
Updated by Chris Bandy over 2 years ago
Tested again against r4343.
Updated by Jeremy Bush over 2 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Applied in changeset r4344.
Updated by Jeremy Bush over 2 years ago
- Resolution set to fixed
Also merged to 2.3 database branch in r4345.