php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71422 Bogus ORA-01438: value larger than specified precision allowed for this column
Submitted: 2016-01-20 16:46 UTC Modified: 2016-04-14 04:05 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: alvaro at demogracia dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.6.17 OS: Windows 7
Private report: No CVE-ID: None
 [2016-01-20 16:46 UTC] alvaro at demogracia dot com
Description:
------------
After upgrading from PHP/5.6.10 to 5.6.17 it's no longer possible to insert 
3 (int) in a NUMBER(1,0) column because now it triggers:

ORA-01438: value larger than specified precision allowed for this column

Test script:
---------------
CREATE TABLE TEST (
	FORMATO_IMPORTACION_ID NUMBER(1,0) DEFAULT 1 NOT NULL
);


<?php

$value = 3;

$conn = oci_connect('test', 'test', '//example.com/xe');
$stmt = oci_parse($conn, 'INSERT INTO TEST (FORMATO_IMPORTACION_ID) VALUES (:formato_importacion_id)');
oci_bind_by_name($stmt, ':formato_importacion_id', $value, -1, SQLT_INT);
oci_execute($stmt);




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-21 11:41 UTC] alvaro at demogracia dot com
PHP/7 branches are apparently not affected by this regression.
 [2016-01-22 09:09 UTC] alvaro at demogracia dot com
Related?

Fix bug 68298 (PHP OCI8 OCI int overflow)
https://github.com/php/php-src/commit/3060dfd92e0126e92b1501dba807bfcd44bef53a
 [2016-01-28 09:47 UTC] alvaro at demogracia dot com
I've found more broken stuff. I'd say that using SQLT_INT is in general no longer functional. Switching to SQLT_CHR is not a valid workaround for all situations since certain queries may fail if they expect a number and receive a string.


CREATE TABLE TEST (
	TEST_ID NUMBER(*,0) NOT NULL,
	LABEL VARCHAR2(50 CHAR),
	CONSTRAINT TEST_PK PRIMARY KEY (TEST_ID)
);
INSERT INTO TEST (TEST_ID, LABEL) VALUES (1, 'Foo');
COMMIT;
SELECT * FROM TEST WHERE TEST_ID=1;


<?php

$conn = oci_connect('test', 'test', '//hera.mina.s/xe');

// Query returns one row
$stmt = oci_parse($conn, 'SELECT LABEL AS RAW_QUERY FROM TEST WHERE TEST_ID=1');
oci_execute($stmt);
while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
	var_dump($row);
}

// Bind parameters do not return results...
$stmt = oci_parse($conn, 'SELECT LABEL AS NUMERIC_BIND_PARAMETER FROM TEST WHERE TEST_ID=:test_id');
$value = 1;
oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_INT);
oci_execute($stmt);
while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
	var_dump($row);
}

// ... unless we stringify them
$stmt = oci_parse($conn, 'SELECT LABEL AS STRING_BIND_PARAMETER FROM TEST WHERE TEST_ID=:test_id');
$value = 1;
oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_CHR);
oci_execute($stmt);
while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
	var_dump($row);
}
 [2016-02-09 04:34 UTC] sixd@php.net
This doesn't reproduce on OS X.
 [2016-02-09 04:34 UTC] sixd@php.net
-Assigned To: +Assigned To: sixd
 [2016-03-02 15:17 UTC] alvaro at demogracia dot com
I've just verified that it works fine up to PHP/5.6.15 (first affected version is 5.6.16) and (as already mentioned) PHP/7.0.x is not affected. I'm using latest Oracle Instant Client release (12.1.0.2.0). My stack is 32-bit.

If there's any specific test I can do please feel free to ask.
 [2016-04-11 09:04 UTC] truly dot apito at gmail dot com
I'm on 32.bit version of PHP 7.0.5 for Windows, using oci 2.1.0, instant client 11.2 both run/ compile-time. Using the same test script as alvaro, i produced the same error. My OSX 10.11.4/PHP 7.0.4 runs it fine, though.
 [2016-04-14 03:58 UTC] sixd@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8f2e6da8066d4f0b4c3846aeba14f894ef8b02ed
Log: Fixed bug #71422 (Fix ORA-01438: value larger than specified precision allowed for this column)
 [2016-04-14 03:58 UTC] sixd@php.net
-Status: Assigned +Status: Closed
 [2016-04-14 04:05 UTC] sixd@php.net
Test out the latest PHP 5.6 code.  If all is OK, I will make a new PECL package.
 [2016-04-14 04:13 UTC] sixd@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8f2e6da8066d4f0b4c3846aeba14f894ef8b02ed
Log: Fixed bug #71422 (Fix ORA-01438: value larger than specified precision allowed for this column)
 [2016-04-14 04:13 UTC] sixd@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8f2e6da8066d4f0b4c3846aeba14f894ef8b02ed
Log: Fixed bug #71422 (Fix ORA-01438: value larger than specified precision allowed for this column)
 [2016-04-15 10:16 UTC] alvaro at demogracia dot com
Works fine for me with php-5.6-ts-windows-vc11-x86-rd1e81a5

PHP 5.6.21-dev (cli) (built: Apr 14 2016 02:39:53)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC