php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67205 insert null value in date column with prepared statement cause HY009 error
Submitted: 2014-05-05 10:32 UTC Modified: 2014-07-25 08:38 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: b0kn16z at gmail dot com Assigned:
Status: Open Package: PDO_IBM (PECL)
PHP Version: Irrelevant OS: i5/OS V7R1
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: b0kn16z at gmail dot com
New email:
PHP Version: OS:

 

 [2014-05-05 10:32 UTC] b0kn16z at gmail dot com
Description:
------------
Zend Server version: 6.3.0 (basic, build: 80622)
PHP version: 5.5.7
PDO_IBM driver version: 1.3.3

Inserting a null value in a column with type date (also timestamp) with a prepared statement cause a PDOException with the following message:
SQLSTATE[HY009]: Invalid use of null pointer: -99999 Fehler bei SQL Call Level Interface aufgetreten. (SQLBindParameter[-99999] at /patched-php-src-5.5.7/php-5.5.7/ext/pdo_ibm/ibm_statement.c:609)

Same problem with the bindParam method.

Inserting a null value in a character column with prepared statements works fine.
Source code blow works properly with PHP 5.3.8 (Zend Sever 5.5.0) and PDO_IBM driver 1.3.2.

"Direct" insert a null like
$db->exec("INSERT INTO DUMMY(foo) VALUES(NULL)");
works fine.

SQL-Trace:
00000018:236584 SQL CLI: SQLAllocHandle ( <Allocate Handle Type> , <Associated Handle> , <Generated Handle> )       
00000018:236584 SQL CLI: SQLAllocHandle INPUT:  Allocate Handle Type: SQL_HANDLE_STMT                               
00000018:236592 SQL CLI: SQLAllocHandle INPUT:  Associated Handle (CONN): 2                                         
00000018:236592 SQL CLI: SQLAllocHandle OUTPUT: Generated Handle: 3                                                 
00000018:236592 SQL CLI: SQLAllocHandle DEBUG: MESSAGE: HANDLE ALLOCATED                                            
00000018:236616 SQL CLI: SQLPrepare ( 3 , <SQL statement> , <statement len> )                                       
00000018:236616 SQL CLI: SQLPrepare INPUT: SQL statement: INSERT INTO xxxxxxx.DUMMY(foo) VALUES(?)                  
00000018:236616 SQL CLI: SQLPrepare INPUT: Statement len: 40                                                        
00000018:248976 SQL CLI: SQLNumResultCols ( 3 , SQLSMALLINT* )                                                      
00000018:248976 SQL CLI: SQLGetInfo ( 2 , 18 , <Buffer val> , 30 , <Buffer len> )                                   
00000018:248992 SQL CLI: SQLGetInfo OUTPUT: Buffer val: 07010                                                       
00000018:248992 SQL CLI: SQLGetInfo OUTPUT: Buffer len: 6                                                           
00000018:249056 SQL CLI: SQLDescribeParam ( 3 , 1 , SQLSMALLINT* , SQLINTEGER* ,  SQLSMALLINT* , SQLSMALLINT* )     
00000018:249064 SQL CLI: SQLBindParameter ( 3 , 1 , 1 , 1 , 91 , 0 , 0 , SQLPOINTER, 0 , SQLINTEGER* )              
00000018:249208 SQL CLI: SQLGetDiagRec ( 3 , 3 , 1 , SQLCHAR* , SQLINTEGER* ,  SQLCHAR* , 512 , SQLSMALLINT* )
00000018:249240 SQL CLI: SQLGetDiagField ( 3 , 3 , 1 , 13 , SQLPOINTER , 518 ,  SQLSMALLINT* )                                                                
00000018:280520 SQL CLI: SQLFreeStmt ( 3 , 1 )                                                
00000018:280560 SQL CLI: SQLDisconnect ( 2 )                                                  
00000018:280608 SQL CLI: SQLFreeHandle ( 2 , 2 )                                              
00000018:280808 SQL CLI: SQLFreeHandle ( 1 , 1 ) 

Test script:
---------------
<?php
error_reporting(-1);

// CREATE TABLE DUMMY (
// 	id INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 CYCLE),
// 	foo DATE)

$db = new PDO('ibm:SERVER', 'USER', 'PASS', array(
	PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
	PDO::ATTR_EMULATE_PREPARES => false));

$stmt = $db->prepare("INSERT INTO xxxxxxx.DUMMY(foo) VALUES(:foo)");
$stmt->bindValue(':foo', null);
$stmt->execute();


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-24 10:21 UTC] rahulpriyadarshi@php.net
You are facing this issue while running you application on PASE or your application is on LUW and DB2 server is on system i?
 [2014-07-25 08:38 UTC] b0kn16z at gmail dot com
I don't know the details of system i and PASE, but I think the Zend Server is running on PASE since we've installed the "Zend Server for IBM i" (from http://www.zend.com/en/products/server/downloads-ibmi). So we use PHP on system i and not on Windows and not on Linux. Hope this helps!
 [2016-12-20 10:51 UTC] geisterpiraten at gmail dot com
I'm encountering the same Error.
Could you teach me,how did you resolve this Error ?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 03:01:31 2024 UTC