Skip to content
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

sqlite: reading schema information causes error #5133

Closed
jpgerdeman opened this issue Dec 20, 2021 · 5 comments
Closed

sqlite: reading schema information causes error #5133

jpgerdeman opened this issue Dec 20, 2021 · 5 comments

Comments

@jpgerdeman
Copy link

jpgerdeman commented Dec 20, 2021

Bug Report

Q A
BC Break yes
Version 3.2.0

Summary

Loading fixtures into a sqlite database causes an error, as sqlite schema is being inspected.

  • PHP Version: 7.4.25
  • Doctrine DBAL: 3.2.0
  • OS: epcentos7

sqlite extension is loaded.

php -i | grep sqlite
/etc/php.d/20-sqlite3.ini,
/etc/php.d/30-pdo_sqlite.ini,
PDO drivers => mysql, sqlite
pdo_sqlite
sqlite3
sqlite3.extension_dir => no value => no value

Current behaviour

When trying to load a fixture into a sqlite database following error is thrown:

Doctrine\DBAL\Exception\SyntaxErrorException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1 near "(": syntax error

This is caused by the following SQL statements

SELECT * FROM PRAGMA_TABLE_INFO (?)
SELECT * FROM PRAGMA_INDEX_INFO (?)

When I revert the changes from commit 55259d5
everything works as expected.

How to reproduce

Following code reproduces the error. Note, only PDO is used not doctrine DBAL

<?php

$pdo = new PDO( 'sqlite:'.__DIR__.'/test.db');
$stmt = $pdo->prepare('SELECT * FROM PRAGMA_TABLE_INFO (?)');
if( !$stmt instanceof PDOStatement )
{
    echo "Error occured\n";
    echo "\n";
    echo "Error Code: ".$pdo->errorCode()."\n";
    $info = $pdo->errorInfo();
    foreach( $info as $k => $v )
    {
        echo "   $k => $v\n";
    }
    exit(128);
}

echo "No syntax Error detected \n";


/// outputs
Error occured

Error Code: HY000
   0 => HY000
   1 => 1
   2 => near "(": syntax error

Expected behaviour

The Fixtures are loaded without error

@morozov
Copy link
Member

morozov commented Dec 21, 2021

@jpgerdeman could you attach your test.db or provide the steps to build it to reproduce the issue?

@lenada
Copy link

lenada commented Jan 18, 2022

The described issue seems related to the underlying sqlite3(lib) version.
On centos 7.9 I can reproduce the issue (against an empty test.db file).

On centos 8.5 or macOS with phpbrew the error does not occur.
A wild guess would be that SQLite defensive mode flag (only available from SQLite 3.26+) prevents it.

@BnitoBzh
Copy link

I have the same issue, on Travis CI when running my Laravel project tests with sqlite.
This problem appears from version 3.20

Here is the error : SQLSTATE[HY000]: General error: 1 no such table: PRAGMA_TABLE_INFO

My tests are run with php 8.0.9

@morozov
Copy link
Member

morozov commented Feb 9, 2022

We decided that this issue is not worth fixing. We recommend that the API consumers upgrade their libmysql at least to version 3.16.0.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants