Skip to content

Make test failure: ext/pdo_sqlite/tests/bug_42589.phpt #11492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CViniciusSDias opened this issue Jun 20, 2023 · 7 comments
Closed

Make test failure: ext/pdo_sqlite/tests/bug_42589.phpt #11492

CViniciusSDias opened this issue Jun 20, 2023 · 7 comments

Comments

@CViniciusSDias
Copy link
Contributor

CViniciusSDias commented Jun 20, 2023

Description

The following code:

<?php
$db = new PDO("sqlite::memory:");

$db->exec('CREATE TABLE test (field1 VARCHAR(10))');
$db->exec('INSERT INTO test VALUES("test")');

$result = $db->query('SELECT * FROM test t1 LEFT JOIN test t2 ON t1.field1 = t2.field1');
$meta1 = $result->getColumnMeta(0);
$meta2 = $result->getColumnMeta(1);

var_dump(!empty($meta1['table']) && $meta1['table'] == 'test');
var_dump(!empty($meta2['table']) && $meta2['table'] == 'test');

Resulted in this output:

bool(false)
bool(false)

But I expected this output instead:

bool(true)
bool(true)

PHP Version

PHP 8.3.0-dev

Operating System

Ubuntu 20.04.6 LTS

@nielsdos
Copy link
Member

I can't seem to reproduce this. What's the Sqlite version on your system?
Can you also please modify the var_dump in the test code to print out all data ?

var_dump($meta1);
var_dump($meta2);

@CViniciusSDias
Copy link
Contributor Author

Sure. Here it goes:

$ sqlite3 --version
3.39.4 2022-09-29 15:55:41 a29f9949895322123f7c38fbe94c649a9d6e6c9cd0c3b41c96d694552f26b309

var_dump($meta1, $meta2) output:

array(7) {
  ["native_type"]=>
  string(6) "string"
  ["pdo_type"]=>
  int(2)
  ["sqlite:decl_type"]=>
  string(11) "VARCHAR(10)"
  ["flags"]=>
  array(0) {
  }
  ["name"]=>
  string(6) "field1"
  ["len"]=>
  int(-1)
  ["precision"]=>
  int(0)
}
array(7) {
  ["native_type"]=>
  string(6) "string"
  ["pdo_type"]=>
  int(2)
  ["sqlite:decl_type"]=>
  string(11) "VARCHAR(10)"
  ["flags"]=>
  array(0) {
  }
  ["name"]=>
  string(6) "field1"
  ["len"]=>
  int(-1)
  ["precision"]=>
  int(0)
}

@KapitanOczywisty
Copy link

KapitanOczywisty commented Jun 20, 2023

@CViniciusSDias Can you check if you have sqlite compiled with ENABLE_COLUMN_METADATA?

$db = new PDO("sqlite::memory:");
$result = $db->query('PRAGMA compile_options');
print_r($result->fetchAll(PDO::FETCH_COLUMN));

or

echo "PRAGMA compile_options;" | sqlite3

@CViniciusSDias
Copy link
Contributor Author

Sure.

Result from PHP:

Array
(
    [0] => ATOMIC_INTRINSICS=1
    [1] => COMPILER=gcc-9.4.0
    [2] => DEFAULT_AUTOVACUUM
    [3] => DEFAULT_CACHE_SIZE=-2000
    [4] => DEFAULT_FILE_FORMAT=4
    [5] => DEFAULT_JOURNAL_SIZE_LIMIT=-1
    [6] => DEFAULT_MMAP_SIZE=0
    [7] => DEFAULT_PAGE_SIZE=4096
    [8] => DEFAULT_PCACHE_INITSZ=20
    [9] => DEFAULT_RECURSIVE_TRIGGERS
    [10] => DEFAULT_SECTOR_SIZE=4096
    [11] => DEFAULT_SYNCHRONOUS=2
    [12] => DEFAULT_WAL_AUTOCHECKPOINT=1000
    [13] => DEFAULT_WAL_SYNCHRONOUS=2
    [14] => DEFAULT_WORKER_THREADS=0
    [15] => ENABLE_FTS3
    [16] => ENABLE_FTS4
    [17] => ENABLE_FTS5
    [18] => ENABLE_GEOPOLY
    [19] => ENABLE_MATH_FUNCTIONS
    [20] => ENABLE_RTREE
    [21] => MALLOC_SOFT_LIMIT=1024
    [22] => MAX_ATTACHED=10
    [23] => MAX_COLUMN=2000
    [24] => MAX_COMPOUND_SELECT=500
    [25] => MAX_DEFAULT_PAGE_SIZE=8192
    [26] => MAX_EXPR_DEPTH=1000
    [27] => MAX_FUNCTION_ARG=127
    [28] => MAX_LENGTH=1000000000
    [29] => MAX_LIKE_PATTERN_LENGTH=50000
    [30] => MAX_MMAP_SIZE=0x7fff0000
    [31] => MAX_PAGE_COUNT=1073741823
    [32] => MAX_PAGE_SIZE=65536
    [33] => MAX_SQL_LENGTH=1000000000
    [34] => MAX_TRIGGER_DEPTH=1000
    [35] => MAX_VARIABLE_NUMBER=32766
    [36] => MAX_VDBE_OP=250000000
    [37] => MAX_WORKER_THREADS=8
    [38] => MUTEX_PTHREADS
    [39] => SYSTEM_MALLOC
    [40] => TEMP_STORE=1
    [41] => THREADSAFE=1
)

Result from sqlite3:

ATOMIC_INTRINSICS=1
COMPILER=gcc-9.4.0
DEFAULT_AUTOVACUUM
DEFAULT_CACHE_SIZE=-2000
DEFAULT_FILE_FORMAT=4
DEFAULT_JOURNAL_SIZE_LIMIT=-1
DEFAULT_MMAP_SIZE=0
DEFAULT_PAGE_SIZE=4096
DEFAULT_PCACHE_INITSZ=20
DEFAULT_RECURSIVE_TRIGGERS
DEFAULT_SECTOR_SIZE=4096
DEFAULT_SYNCHRONOUS=2
DEFAULT_WAL_AUTOCHECKPOINT=1000
DEFAULT_WAL_SYNCHRONOUS=2
DEFAULT_WORKER_THREADS=0
ENABLE_DBPAGE_VTAB
ENABLE_DBSTAT_VTAB
ENABLE_EXPLAIN_COMMENTS
ENABLE_FTS3
ENABLE_FTS4
ENABLE_FTS5
ENABLE_GEOPOLY
ENABLE_MATH_FUNCTIONS
ENABLE_RTREE
ENABLE_STMTVTAB
MALLOC_SOFT_LIMIT=1024
MAX_ATTACHED=10
MAX_COLUMN=2000
MAX_COMPOUND_SELECT=500
MAX_DEFAULT_PAGE_SIZE=8192
MAX_EXPR_DEPTH=1000
MAX_FUNCTION_ARG=127
MAX_LENGTH=1000000000
MAX_LIKE_PATTERN_LENGTH=50000
MAX_MMAP_SIZE=0x7fff0000
MAX_PAGE_COUNT=1073741823
MAX_PAGE_SIZE=65536
MAX_SQL_LENGTH=1000000000
MAX_TRIGGER_DEPTH=1000
MAX_VARIABLE_NUMBER=32766
MAX_VDBE_OP=250000000
MAX_WORKER_THREADS=8
MUTEX_PTHREADS
SYSTEM_MALLOC
TEMP_STORE=1
THREADSAFE=1

@CViniciusSDias
Copy link
Contributor Author

Is it possible to add this check as one of the tests pre-conditions, so it doesn't fail when this flag is disabled?

@KapitanOczywisty
Copy link

--SKIPIF--
<?php
$db = new PDO("sqlite::memory:");
$options = $db->query('PRAGMA compile_options')->fetchAll(PDO::FETCH_COLUMN);
if(!in_array('ENABLE_COLUMN_METADATA', $options, true))
    die("skip sqlite3 must be compiled with SQLITE_ENABLE_COLUMN_METADATA");
?>

@CViniciusSDias
Copy link
Contributor Author

I'll prep this PR. :-D

nielsdos added a commit that referenced this issue Jun 22, 2023
* PHP-8.1:
  Fix GH-11492: Make test failure: ext/pdo_sqlite/tests/bug_42589.phpt
nielsdos added a commit that referenced this issue Jun 22, 2023
* PHP-8.2:
  Fix GH-11492: Make test failure: ext/pdo_sqlite/tests/bug_42589.phpt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants