php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71916 Two attribute constants use the same value
Submitted: 2016-03-29 11:34 UTC Modified: 2020-04-07 11:18 UTC
From: downsider84 at hotmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 7.0.4 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: downsider84 at hotmail dot com
New email:
PHP Version: OS:

 

 [2016-03-29 11:34 UTC] downsider84 at hotmail dot com
Description:
------------
The constants MYSQL_ATTR_USE_BUFFERED_QUERY and PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT have the same value, 1000.

Setting MYSQL_ATTR_USE_BUFFERED_QUERY when using the pgsql driver causes a "deprecated" warning about PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT. This is non-obvious and potentially difficult to debug.

Test script:
---------------
ini_set("display_errors", 1);
error_reporting(E_ALL);

// change credentials as appropriate
$dbName = "test";
$host = "locahost";
$username = "root";
$password = "";

$pdo = new \PDO("pgsql:$dbName=db;host=$host", $username, $password);
$pdo->setAttribute(\PDO:MYSQL_ATTR_USE_BUFFERED_QUERY, true);

Expected result:
----------------
Deprecated:  PDO::setAttribute(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in [filename] on line [lineno]


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-29 12:18 UTC] krakjoe@php.net
-Status: Open +Status: Verified
 [2016-03-29 12:18 UTC] krakjoe@php.net
This seems to be a flaw in the design of PDO; Drivers with driver specific attributes are instructed to use the same value "PDO_ATTR_DRIVER_SPECIFIC" (1000) to identify their first specific attribute. 

Any two drivers with driver specific attributes are vulnerable to the same problem.

I am not super familiar with PDO, so, unsure how to fix it ...
 [2016-03-29 13:06 UTC] downsider84 at hotmail dot com
I'm not sure there will be a solution, given the policy of starting driver specific constants at 1000 (I can't think of anything comprehensive), so that only leaves us with documenting the issue

After bit of digging, it looks like if a driver implements custom attributes then it has some disclaimer boilerplate saying not to use the constants with other drivers. However, this is tucked away inside the docs for each driver.
Perhaps we should add something to the docs for getAttribute and setAttribute to make the convention more visible?
 [2017-10-24 08:31 UTC] kalle@php.net
-Package: PDO Core +Package: PDO related
 [2020-04-07 11:18 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2020-04-07 11:18 UTC] cmb@php.net
Indeed, doc issue.
 [2021-11-16 14:02 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/af64507ffdd4fe88b2dc19efade2cf6230cde739
Log: Fix #71916: Two attribute constants use the same value
 [2021-11-16 14:02 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC