Req #79272 [Com]: Add PDO::ATTR_EMULATE_PREPARES support for SQLite

From: Date: Thu, 25 Mar 2021 01:04:34 +0000
Subject: Req #79272 [Com]: Add PDO::ATTR_EMULATE_PREPARES support for SQLite
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232984@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79272&edit=1

 ID:                 79272
 Comment by:         apostnikov at gmail dot com
 Reported by:        effulgentsia1 at gmail dot com
 Summary:            Add PDO::ATTR_EMULATE_PREPARES support for SQLite
 Status:             Open
 Type:               Feature/Change Request
 Package:            PDO SQLite
 Operating System:   All
 PHP Version:        Next Minor Version
 Block user comment: N
 Private report:     N

 New Comment:

Used to confirm the bug on PHP 8.0.3 with sqlite builded with limit 250000


script is
---
$large_array = range(0, 250001);

$db = new PDO('sqlite::memory:');
$placeholders = implode(', ', array_fill(0, count($large_array), '?'));
$stmt = $db->prepare("SELECT 1 WHERE 42 IN ($placeholders)");
var_dump($stmt->execute($large_array));



---
PHP Fatal error:  Uncaught Error: Call to a member function execute() on bool in /mnt/a.php:7
Stack trace:
#0 {main}
  thrown in /mnt/a.php on line 7

Fatal error: Uncaught Error: Call to a member function execute() on bool in /mnt/a.php:7
Stack trace:
#0 {main}
  thrown in /mnt/a.php on line 7


Previous Comments:
------------------------------------------------------------------------
[2020-02-13 19:45:25] effulgentsia1 at gmail dot com

Description:
------------
MySQL and PostgreSQL have limits of 65535 placeholders for native prepared statements. However, if
more are passed, the PDO drivers fallback to emulating prepares, in which case the only limit is
whatever the database server has configured for its SQL statement length limit (e.g.,
max_allowed_packet for MySQL).


However, SQLite has a default limit of 999 placeholders (https://bugs.php.net/bug.php?id=79269), and
the PDO driver for it does not fallback to emulating prepares, or support the
PDO::ATTR_EMULATE_PREPARES at all.

For Drupal, we use PDO and support MySQL, PostgreSQL, and SQLite. For consistency, it would be
helpful if the PDO driver for SQLite also supported emulated prepares.


Test script:
---------------
Same as in https://bugs.php.net/bug.php?id=79269.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79272&edit=1


Thread (2 messages)

« previous php.bugs (#232984) next »