php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57785 PDO SQLite file with non ASCII char in path
Submitted: 2007-08-14 04:20 UTC Modified: 2020-12-07 14:04 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: fmate144 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: PDO SQLite
PHP Version: 5.6.10 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fmate144 at gmail dot com
New email:
PHP Version: OS:

 

 [2007-08-14 04:20 UTC] fmate144 at gmail dot com
Description:
------------
I have a simple sqlite database file. If in its path is non ASCII characters, the PDO can not open it!

Reproduce code:
---------------
<?php
// In c:\x?x\test.php
// Exception: unable to open database file
$db = new PDO('sqlite:test.db3');
// Work good!
$db = sqlite_open('test.db3', 0666, $sqliteerror);

// In c:\xex\test.php both work good.
?>

Expected result:
----------------
unable to open database file


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-14 05:01 UTC] wiesemann@php.net
(wrong package selection)
 [2009-02-26 11:29 UTC] iisfirewall at 126 dot com
if the path has no asc char,the pdo_sqlite3 will free work.
 [2014-02-26 11:59 UTC] wcode404 at gmail dot com
Test script:
---------------
Create folder (charset windows-1251)
C:\тест\test\

In the command line call a command
C:\тест\test\> php -r "new PDO('sqlite:test.db');"

Expected result:
----------------
Should create a database file

Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1] unable to open database file' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('sqlite:test.db')
#1 {main}
  thrown in Command line code on line 1
 [2015-06-12 12:54 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: PDO_SQLITE +Package: SQLite related -Operating System: WinXP SP2 +Operating System: Windows -PHP Version: Irrelevant +PHP Version: 5.6.10
 [2015-06-12 12:54 UTC] cmb@php.net
I can confirm this issue for CP-1252 with the reproduce script
given by wcode404 (thanks!).

When the relative path ("test.db") is expanded to a an absolute
path by expand_path[1], the path is not UTF-8 encoded, but later
sqlite3_open[2] is called, which expects an UTF-8 encoded
filename. Using sqlite3_open16 instead would work for me, but that's
likely not an option for portability reasons[3]:

| The default encoding will be UTF-8 for databases created using
| sqlite3_open() or sqlite3_open_v2(). The default encoding for
| databases created using sqlite3_open16() will be UTF-16 in the
| native byte order.

The same problem affects the SQLite3 extension, too.

[1] <https://github.com/php/php-src/blob/php-5.6.10/ext/pdo_sqlite/sqlite_driver.c#L764>
[2] <https://github.com/php/php-src/blob/php-5.6.10/ext/pdo_sqlite/sqlite_driver.c#L832>
[3] <https://www.sqlite.org/c3ref/open.html>
 [2016-06-27 16:23 UTC] cmb@php.net
-Package: SQLite related +Package: PDO SQLite
 [2020-12-07 14:04 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-12-07 14:04 UTC] cmb@php.net
This issue is resolved as of PHP 7.1.0; UTF-8 paths are supported
on Windows now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 03 08:01:28 2024 UTC