Bug #80083 [Com]: Optimizer pass 6 removes variables used for data binding
Edit report at https://bugs.php.net/bug.php?id=80083&edit=1
ID: 80083
Comment by: calvin at cmpct dot info
Reported by: calvin at cmpct dot info
Summary: Optimizer pass 6 removes variables used for data
binding
Status: Open
Type: Bug
Package: opcache
Operating System: IBM i 7.2
PHP Version: 7.4.10
Block user comment: N
Private report: N
New Comment:
Yeah, I agree this is API is malpractice. (Looking at the db2 binding code and having it manipulate
local/global scope symbol tables when no other modules did so was a bit of a head-scratcher.)
Changing the db2 API would probably result in a breaking change though, and most code on ibm_db2
instead of (PDO_)ODBC is legacy; so I suspect most users running into this will either detune
opcache or migrate to ODBC. (Of course, this is the IBM i perspective. I don't know what LUW
people are doing here; perhaps they consider that extension more important.)
Previous Comments:
------------------------------------------------------------------------
[2020-09-10 15:39:17] nikic@php.net
The db2 extension needs to change its API to not work on variable names -- it needs to accept
variables by reference instead.
------------------------------------------------------------------------
[2020-09-10 15:24:44] calvin at cmpct dot info
Description:
------------
I'm not sure if this is an ibm_db2 module bug or an opcache bug, but I figured I'd report
here first.
Script, debug output at different optimization levels, and a diff between them available in this
gist (let me know if anything else is needed for repro and I can add to it): https://gist.github.com/NattyNarwhal/09679e177b11de22aeceaaffdc62012b
The summary is when optimizer pass 6 (DFA) runs through the program, it elides the variables used
for a data bound stored procedure call using the ibm_db2 extension, resulting in failure. Masking
the bit for pass 6 out (that is, setting optimization level 0x7FFEBFFF to 0x7FFEBFDF) is enough to
mitigate the failure.
Expected result:
----------------
Résultat : bar (or whatever the stored procedure used sets)
Actual result:
--------------
PHP Warning: db2_execute(): Value Not Bound in /home/calvin/test/gautier.php on line 31
PHP Warning: db2_execute(): Binding Error 3 in /home/calvin/test/gautier.php on line 31
Résultat :
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80083&edit=1
Thread (8 messages)