php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71667 "computed" column name behavior is inconsistent with mssql extension
Submitted: 2016-02-25 23:20 UTC Modified: 2016-02-29 15:43 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: adam dot baratz at gmail dot com Assigned: ab (profile)
Status: Closed Package: PDO DBlib
PHP Version: 5.6.19RC1 OS: Linux
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: adam dot baratz at gmail dot com
New email:
PHP Version: OS:

 

 [2016-02-25 23:20 UTC] adam dot baratz at gmail dot com
Description:
------------
The output is inconsistent with the output from executing the same query using the mssql extension (see expected result section for details).

Test script:
---------------
<?php

if (!extension_loaded('pdo_dblib')) {
    die('skip not loaded');
}
require dirname(__FILE__) . '/config.inc';

$stmt = $db->prepare('SELECT 1, 2 AS named, 3');
$stmt->execute();
var_dump($stmt->fetch());


Expected result:
----------------
The mssql extension starts "computed" names at "computed" and uses a sequence to name subsequent columns, not the column number:
https://github.com/php/php-src/blob/PHP-5.6.19/ext/mssql/php_mssql.c#L1225

In this case, the first column should be "computed" and the third should be "computed1."

Additionally, debug mode should not be reporting memory leaks.

Actual result:
--------------
---------------------------------------
/vagrant/pdo_dblib-clean/dblib_stmt.c(106) : Block 0x00000000 status:
NULL
---------------------------------------
array(6) {
  ["computed0"]=>
  string(1) "1"
  [0]=>
  string(1) "1"
  ["named"]=>
  string(1) "2"
  [1]=>
  string(1) "2"
  ["computed2"]=>
  string(1) "3"
  [2]=>
  string(1) "3"
}
[Thu Feb 25 23:04:41 2016]  Script:  '/vagrant/pdo_dblib-clean/tests/timeout.php'
/home/vagrant/php-src/main/spprintf.c(245) :  Freeing 0x7F1E9FB6B518 (79 bytes), script=/vagrant/pdo_dblib-clean/tests/timeout.php
Last leak repeated 1 time
[Thu Feb 25 23:04:41 2016]  Script:  '/vagrant/pdo_dblib-clean/tests/timeout.php'
/vagrant/pdo_dblib-clean/dblib_stmt.c(211) :  Freeing 0x7F1E9FB6D270 (6 bytes), script=/vagrant/pdo_dblib-clean/tests/timeout.php
=== Total 3 memory leaks detected ===

Patches

computed_column_name.diff (last revision 2016-02-25 23:21 UTC by adam dot baratz at gmail dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-29 15:43 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2016-02-29 15:43 UTC] ab@php.net
The leak fix is applied, see the PR page for more info.

Thanks.
 [2016-04-06 12:46 UTC] ab@php.net
Automatic comment on behalf of adam.baratz@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ed3edc2f05c7be9c498aee64de2ad5a796456135
Log: fix bug #71667 (emulate how mssql extension names &quot;computed&quot; columns)
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of adam.baratz@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ed3edc2f05c7be9c498aee64de2ad5a796456135
Log: fix bug #71667 (emulate how mssql extension names &quot;computed&quot; columns)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 11:01:31 2025 UTC