Bug #74967 [Opn->Dup]: mysqli.reconnect = 1: MYSQLI_OPT_INT_AND_FLOAT_NATIVE lost
| From: | cmb@php.net | Date: | Wed, 22 Dec 2021 11:22:28 +0000 |
| Subject: | Bug #74967 [Opn->Dup]: mysqli.reconnect = 1: MYSQLI_OPT_INT_AND_FLOAT_NATIVE lost | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-238533@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74967&edit=1
ID: 74967
Updated by: cmb@php.net
Reported by: spam2 at rhsoft dot net
Summary: mysqli.reconnect = 1:
MYSQLI_OPT_INT_AND_FLOAT_NATIVE lost
-Status: Open
+Status: Duplicate
Type: Bug
Package: MySQLi related
Operating System: Linux
PHP Version: 7.0.21
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Closing as duplicate of <https://github.com/php/php-src/issues/7808>.
Previous Comments:
------------------------------------------------------------------------
[2020-11-06 18:53:19] noname at withgod dot jp
Indeed, if it was only MYSQLI_OPT_INT_AND_FLOAT_NATIVE, I just reordered it and it worked.
* https://gist.github.com/withgod/d939042686ea4ddcccd24853623bc16c#file-log-php74-2-log
It's simple, but I didn't realize... :(
It's just a simplified program for testing purposes.
As you say, the options before establishing a connection are still a problem that cannot be set this
way.
I think it's possible to reconnect with the appropriate options if can reconnect without
problems, or at least notify me with an Exception or something to indicate that the connection
failed.
thanks your support!
------------------------------------------------------------------------
[2020-11-06 11:06:23] nikic@php.net
I see, that makes sense.
I think the documentation is simply wrong here. mysqli_options() only needs to be called before
real_connect() if you want to set options that affect how the connection is established. For
something like MYSQLI_OPT_INT_AND_FLOAT_NATIVE, it should be fine to set after the connection has
been established.
That said, we should still be preserving it...
------------------------------------------------------------------------
[2020-11-06 11:02:38] noname at withgod dot jp
thread's owner says mysqli.reconnect, which is probably incorrect.
I have confirmed that this happens when using mysqlnd, not mysqli.
* https://www.php.net/manual/en/mysqli.options.php
>mysqli_options() should be called after mysqli_init() and before mysqli_real_connect().
The use of options in mysqli is set before the connection is started, and there seems to be no way
to set the options after the connection is resumed.
A sample code and results are attached.
* https://gist.github.com/withgod/d939042686ea4ddcccd24853623bc16c
It seems to work fine on php74, but the options are disabled and the results don't match.
------------------------------------------------------------------------
[2020-11-05 16:29:25] egegega at sgegeg dot com
the point is that the php code is always the same just with the difference using persistent
connections you randomly lose strict types of results
anyways, I stopped using persistent connections at all because they do more harm than anything else
and even disallowed them on the servers
------------------------------------------------------------------------
[2020-11-05 15:58:32] nikic@php.net
From a cursory look, mysqli.reconnect is a libmysqlclient only option, while
MYSQLI_OPT_INT_AND_FLOAT_NATIVE is a mysqlnd only option, so both of those cannot be in use at the
same time.
I'm assuming that this is rather referring to the reconnect that happens when mysqli_connect()
reuses an existing persistent connection.
But I believe that reconnect loses all options -- and more generally, it is expected that
mysqli_connect() is followed by setting all the necessary options, as you do not know whether you
get back a new connection or a reused existing one.
As such, I'm not really sure what the reported bug is.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=74967
--
Edit this bug report at https://bugs.php.net/bug.php?id=74967&edit=1