Commit graph

429 commits

Author SHA1 Message Date
Kamil Tekiela
d902b3a844
Replace macro with inline function (#7365) 2021-08-13 20:03:26 +01:00
Nikita Popov
b80767e219 Remove MYSQLND_SZ_T_SPEC
In favor of %zu, which msvc has supported for quite a while already.
2021-08-12 15:29:06 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Nikita Popov
57f06b6058 Fix more mysqlnd debug printf formats
These didn't show up on my system...
2021-06-16 16:23:30 +02:00
Nikita Popov
3acdab864d Fix printf formats in mysql debug logging
Enable printf format verification and fix the reported errors.
2021-06-16 16:09:06 +02:00
George Peter Banyard
aca6aefd85
Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
3a867b9827 Fixed bug #80808
If the ZEROFILL flag is set for a field, do not convert it into
an integer (text protocol) or convert it explicitly into a padded
string (binary protocol).
2021-03-02 10:59:34 +01:00
Nikita Popov
fc1a012c49 Fix Windows build
Don't add to a void pointer.
2021-02-23 12:23:08 +01:00
Nikita Popov
771b0bd1df Remove free_chunk API
This API only works in very limited circumstances -- relying on
it will invariably lead to leaks. The correct way to "free" something
from the pool is to use the checkpoint API.
2021-02-23 11:46:34 +01:00
Nikita Popov
1fc4c89214 Fixed bug #80761
When row data split across multiple packets, allocate a temporary
buffer that can be reallocated, and only copy into the row buffer
pool arena once we know the final size. This avoids quadratic
memory usage for very large results.
2021-02-23 11:17:31 +01:00
Nikita Popov
6bfe1aa19a Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle incomplete result set metadata more gracefully
2021-02-16 15:35:01 +01:00
Nikita Popov
edb9229b8b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle incomplete result set metadata more gracefully
2021-02-16 15:34:47 +01:00
Nikita Popov
9552cf6b84 Handle incomplete result set metadata more gracefully
Rather than segfaulting because sname is missing lateron, report
a FAIL here. As this indicates a server bug, the errors is reported
as an out of band warning, rather than a client error.

This fixes the PHP side of bug #80713.
2021-02-16 15:34:14 +01:00
Christoph M. Becker
3b08b422a7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74779: x() and y() truncating floats to integers
2021-02-05 13:12:30 +01:00
Christoph M. Becker
4be5b4aa25 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74779: x() and y() truncating floats to integers
2021-02-05 13:12:03 +01:00
Christoph M. Becker
3f8d21b922 Fix #74779: x() and y() truncating floats to integers
We must not use the locale dependent `atof()`, but instead use the
(hopefully) locale independent `zend_strtod()`, when converting string
representations of floating point numbers which are sent by the server.

Closes GH-6665.
2021-02-05 13:09:59 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
33e904915e MySQLnd: Clean up and optimize mysqlnd result set handling
This is a larger overhaul of the mysqlnd result set infrastructure:

 * Drop support for two different types of buffered results sets
   ("c" and "zval"). Possibly these made sense at some earlier
   time, but now (with minor adjustments) one option is strictly
   worse than the other. Buffered result sets already buffer the
   full row packets, from which zvals can be decoded. The "zval"
   style additionally also buffered the decoded zvals. As result
   sets, even buffered ones, are generally only traversed once,
   this just ends up wasting memory. Now, a potentially useful
   variation here would be to buffer the decoded zvals instead of
   the row packets, but that's not what the code was doing.
 * To make it really strictly better, pre-allocate the zval row
   buffer and reuse it for all rows. Previously the "c" style always
   allocated a new buffer for each row.
 * The fetch_row API now provides a populated zval[]. The task of
   populating an array is deferred to fetch_row_into, which also
   avoids duplicating this code in multiple places. The fetch_row_c
   API is also implemented on top of fetch_row now, rather than
   duplicating large parts of the code.
 * The row fetching code for prepared statements and normal result
   sets has been mostly merged. These already used the same
   infrastructure, but prepared statements used separate row
   fetching functions that were nearly the same as the normal ones.
   This requires passing the stmt into the result set, rather than
   just a flag. The only part that remains separate is reading of
   unbuffered results in the presence of PS cursors.
2020-12-17 10:15:02 +01:00
Nikita Popov
1c29db19d4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #67983
2020-12-16 10:54:36 +01:00
Nikita Popov
1a66d64717 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #67983
2020-12-16 10:53:48 +01:00
Nikita Popov
315f3f8dc9 Fixed bug #67983
We need to check the BIT case first, otherwise it will get skipped
in INT_AND_FLOAT_NATIVE mode.
2020-12-16 10:52:27 +01:00
Nikita Popov
6bda0c14f5 MySQLnd: Simplify management of zval row buffer
Something odd was being done here, with the row packet having a
flag for whether it should allocate the zval buffer, which would
then get moved into the result set.

Keep the management of this buffer purely at the result set level.
This also allows us to easily reuse the same buffer for all results,
rather than allocating a new one for each fetch.
2020-12-15 12:00:05 +01:00
Nikita Popov
141eb346b0 Remove MYSQLND_STRING_TO_INT_CONVERSION define
This has been unconditionally enabled for a long time already
(the actual conversion is behind an additional runtime flag).
2020-12-14 12:03:43 +01:00
Nikita Popov
5d9bd14ccc MySQLnd: Remove some unnecessary allocator failure checks
emalloc/pemalloc are infallible.
2020-12-14 11:58:43 +01:00
Nikita Popov
24a19cc232 Suppress stream errors in mysqlnd
mysqlnd currently sets error_reporting=0 to suppress errors while
writing to streams. Unfortunately these errors are still visible
to userland error handlers, which is a source of confusion.
See for example https://bugs.php.net/bug.php?id=80412.

Instead add a stream flag that suppresses the emission of
read/write errors in the first place, and set it in mysqlnd.

I think it might be useful to have this option for userland as
well in the future, but for now this is just an internal
mechanism.

Closes GH-6458.
2020-11-30 15:06:28 +01:00
Nikita Popov
ce7c2cc05d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Report gone away error in one more place
2020-10-29 12:47:22 +01:00
Nikita Popov
78b44ddeba Report gone away error in one more place 2020-10-29 12:46:55 +01:00
Nikita Popov
d784c65cca Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Retain QUIT_SEND connection state
2020-10-29 10:39:58 +01:00
Nikita Popov
24537a73c0 Retain QUIT_SEND connection state
If the server goes away while reading a packet, don't go back into
the READY state. This will just cause broken pipe errors down the
line.
2020-10-29 10:36:03 +01:00
Nikita Popov
246b8b20b2 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #65825
2020-10-28 17:15:42 +01:00
Nikita Popov
a66d73db4b Fixed bug #65825
Set error_info when we fail to read a packet, instead of throwing
a warning. Additionally we also need to populate the right
error_info in rowp_read -- we'll later take the error from the
packet, not the connection.

No test case, as this is hard to reliably test. I'm using the
test case from:
https://github.com/php/php-src/pull/2131#issuecomment-538374838
2020-10-28 17:15:27 +01:00
Nikita Popov
392f0abf68 Avoid ubsan warning due to memcpy null
This showed up in ext/mysqli/tests/mysqli_change_user.phpt on azure
today. Not seeing it locally though, and also not sure why it decided
to show up now...
2020-09-16 10:30:13 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
twosee
83a77015ad Add helper APIs for maybe-interned string creation
Add ZVAL_CHAR/RETVAL_CHAR/RETURN_CHAR as a shortcut for using
ZVAL_INTERNED_STRING and ZSTR_CHAR.

Add zend_string_init_fast() as a helper for the empty string /
one char interned string / zend_string_init() pattern.

Also add corresponding ZVAL_STRINGL_FAST etc macros.

Closes GH-5684.
2020-06-08 15:31:52 +02:00
twosee
7d6a0ba808 Fix expression warnings and break warnings
Close GH-5675.
2020-06-07 10:41:11 +02:00
George Peter Banyard
1330359515 Fix [-Wundef] warning in MySQLnd extension 2020-05-18 00:37:20 +02:00
Nikita Popov
172010a08d Merge branch 'PHP-7.4'
* PHP-7.4:
  Don't use VLA in mysqlnd auth
2020-02-18 16:18:50 +01:00
Nikita Popov
9d31a42a30 Don't use VLA in mysqlnd auth
We use alloca instead of VLA. This should also allow building
this code on Windows.
2020-02-18 16:17:56 +01:00
Nikita Popov
184f118d3f Merge branch 'PHP-7.4'
* PHP-7.4:
  Handle empty password fast path in caching_sha2_password
  Handle error response during caching_sha2_password auth
  Add support for caching_sha2_password in change user authentication
  Fix unix socket check during caching_sha2_password
  Support auth switch request during caching sha2 auth
2019-12-27 17:31:27 +01:00
Nikita Popov
813d4a00b4 Handle error response during caching_sha2_password auth
In particular, this fixes handling of expired passwords.
2019-12-27 17:27:45 +01:00
Nikita Popov
6225137b4a Support auth switch request during caching sha2 auth 2019-12-27 17:27:04 +01:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Christoph M. Becker
a18f53ec2c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  fix the problem for connect_attr, set db condition, and add a new attribute _server_host
2019-08-20 13:35:17 +02:00
Christoph M. Becker
3771d66142 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  fix the problem for connect_attr, set db condition, and add a new attribute _server_host
2019-08-20 13:33:45 +02:00
Qianqian Bu
cdf16c010a fix the problem for connect_attr, set db condition, and add a new attribute _server_host 2019-08-20 13:31:58 +02:00
Andrey Hristov
1da15600ae Merge branch 'PHP-7.3' into PHP-7.4 2019-06-21 16:33:01 +03:00
Andrey Hristov
8326f95fe3 Merge branch 'PHP-7.2' into PHP-7.3 2019-06-21 16:32:13 +03:00
Andrey Hristov
102c64e827 Add explicit cast to uint32_t.
It works even without it but explicit stuff is better. The compiler probably converts the 16-bit
uint16_t to uint32_t before doing the shift.
2019-06-21 16:31:56 +03:00
Nikita Popov
22765160da Fix incorrect shift in mysqlnd_wireprotocol
This one looks like a genuine bug: We're shifting a uint16_t by
16 bits. On x86 that likely results in no shift happening.
2019-06-19 15:09:00 +02:00