Commit graph

450 commits

Author SHA1 Message Date
Kamil Tekiela
6c7ff08920
Drop MYSQLI_CURSOR_TYPE_FOR_UPDATE & MYSQLI_CURSOR_TYPE_SCROLLABLE (#15486) 2024-08-19 13:54:40 +02:00
Kamil Tekiela
4baf6a643b
Fix error message and add UPGRADING entry 2024-08-19 13:19:49 +02:00
Kamil Tekiela
c316382acb
Remove MYSQLI_STMT_ATTR_PREFETCH_ROWS constant (#15485)
This feature was never implemented, and since the
beginning, using this constant with mysqlnd would
result in an error.
This feature was only available with libmysqlclient
which can no longer be used with mysqli.
There are no plans to implement it in the future.
2024-08-19 13:04:56 +02:00
Gina Peter Banyard
4f58d5b0df
ext/mysqli: Deprecate passing the parameter to mysqli_store_result() (#15311)
And deprecate the MYSQLI_STORE_RESULT_COPY_DATA constant.

RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_the_second_parameter_to_mysqli_store_result
2024-08-11 19:25:35 +01:00
Peter Kokot
c44834d8ad
Trim trailing whitespace (#14721) 2024-06-29 18:41:45 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Gina Peter Banyard
fd2d869642
Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Arnaud Le Blanc
fd73681c86
Fix GCC warning when using getThis() in a conditional (#13923)
Since GCC 12.x, using getThis() in a conditional yields a warning:

    <source>:12:22: warning: the comparison will always evaluate as 'true' for
                    the address of 'This' will never be NULL [-Waddress]
       12 |     return getThis() ? 2 : 3;
          |                      ^
2024-04-09 19:09:07 +02:00
Ilija Tovilo
47f80ffc77
Remove unnecessary type punnign from mysqli_api.c
value is a long. On big-endian architectures mysql_stmt_attr_get() will write to
the most significant byte. Type punning was used to move that byte to the least
significant one, which is UB. We can avoid this by simply casting to my_bool
(alias of bool). Previously, a comparison against 0 should've been done.
2023-03-10 17:15:46 +01:00
Max Kellermann
d5c649b36b
zend_compiler, ...: use uint8_t instead of zend_uchar (#10621)
`zend_uchar` suggests that the value is an ASCII character, but here,
it's about very small integers.  This is misleading, so let's use a
C99 integer instead.

On all architectures currently supported by PHP, `zend_uchar` and
`uint8_t` are identical.  This change is only about code readability.
2023-02-23 14:56:54 +00:00
Kamil Tekiela
1dc51c7b90
Implement mysqli_execute_query() (#8660) 2022-07-06 12:23:46 +01:00
Kamil Tekiela
d84dfa3292 Remove MYSQLI_USE_MYSQLND constant and all the code with it 2022-05-30 15:28:08 +01:00
David Carlier
15e7e570a5
Fix #81658: MYSQL_OPT_LOAD_DATA_LOCAL_DIR not available in MariaDB
This also introduces the boolean userland constant `MYSQLI_IS_MARIADB`.
2021-12-05 19:11:04 +01:00
Christoph M. Becker
35332503f4
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74544: Integer overflow in mysqli_real_escape_string()
2021-08-10 00:07:45 +02:00
Christoph M. Becker
606829f31f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74544: Integer overflow in mysqli_real_escape_string()
2021-08-10 00:06:58 +02:00
Christoph M. Becker
5977610de1
Fix #74544: Integer overflow in mysqli_real_escape_string()
The patch has been provided by @johannes.

Closes GH-7353.
2021-08-10 00:05:39 +02:00
Kamil Tekiela
cd0cd3d31e
Fix typos (#7327) 2021-08-01 18:03:30 +01:00
Máté Kocsis
01775fa104
Declare tentative return types for ext/mysqli (#6998) 2021-05-26 17:29:58 +02:00
Nikita Popov
b0961f2d04 Remove uses of TRUE/FALSE in mysqli/pdo_mysql
Replace with standard uses of true/false.
2021-05-26 15:07:23 +02:00
Kamil Tekiela
428340dfeb
Add error reporting to mysqli_options (#7036) 2021-05-25 10:42:06 +01: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
Kamil Tekiela
45bad6474e
Mysqli bind in execute (#6271) 2021-04-14 12:52:51 +01:00
Dharman
7e9f6d2a48 Deprecate OO style mysqli::get_client_info method
Deprecate passing connection object to mysqli_get_client_info()

Closes GH-6777.
2021-03-17 20:10:18 +00:00
Darek Slusarczyk
da011a312a Fix #80329: Add option to specify LOAD DATA LOCAL white list folder
* allow the user to specify a folder where files that can be sent
   via LOAD DATA LOCAL can exist
 * add mysqli.local_infile_directory for mysqli
   (ignored if mysqli.allow_local_infile is enabled)
 * add PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY for pdo_mysql
   (ignored if PDO::MYSQL_ATTR_LOCAL_INFILE is enabled)
 * add related tests
 * fixes for building with libmysql 8.x
 * small improvement in existing tests
 * update php.ini-[development|production] files

Closes GH-6448.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-02-23 09:30:46 +01:00
Nikita Popov
1cd33d83db Merge branch 'PHP-8.0'
* PHP-8.0:
  Make mysqli_ssl_set() arguments nullable
2021-02-10 15:33:25 +01:00
Nikita Popov
39c6aaa9cc Make mysqli_ssl_set() arguments nullable
This function internally converts zero length arguments to NULL
argument -- but we should also accept them in the first place.

Null arguments being accepted was actually documented, before
bug #78399 adjusted the docs to match current behavior.
2021-02-10 15:31:27 +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
422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a
conversion was necessary. This distinction no longer makes sense
since PHP 7.

The only difference that was still left is that _ex checked whether
the type is the same first, but the usage of these macros did not
actually distinguish on whether such an inlined check is valuable
or not in a given context.

Also drop the unused convert_to_explicit_type macros.
2021-01-14 12:11:11 +01:00
Nikita Popov
73f989a83b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix/improve mysqli stubs
2021-01-06 11:29:38 +01:00
Dharman
44a311dbbe Fix/improve mysqli stubs
* mysqli_commit $flags default value is 0, not -1.
* A number of functions cannot actually return null.
* mysqli_poll parameter names were incorrect, as this function
  has a different signature from select.
* fetch functions apart from fetch_all can return false on failure.
2021-01-06 11:28:45 +01:00
Nikita Popov
be93e5a120 Make mysqli_stmt_next_result available under libmysql
The libmysqlclient version we require supports mysql_stmt_next_result.
2020-12-18 11:32:41 +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
890e4caf0b Drop support for max_length in mysqli_fetch_fields()
Retain the field, but always populate it with zero. This was
already the case for PS without length updating.

max_length has nothing lost in the field metadata -- it is a
property of the specific result set, and requires scanning the
whole result set to compute. PHP itself never uses max_length
with mysqlnd, it is only exposed in the raw mysqli API.

Keeping it for just that purpose is not worthwhile given the costs
involved. People who actually need this for some reason can easily
calculate it themselves, while making it obvious that the
calculation requires a full result set scan.
2020-12-17 10:01:02 +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
d776c31a34 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle errors during next_result()
2020-11-11 16:03:10 +01:00
Nikita Popov
eda7492604 Handle errors during next_result() 2020-11-11 16:02:52 +01:00
Nikita Popov
d928c58281 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle mysqli errors in more cases
  Sync test with master
2020-10-28 11:37:37 +01:00
Dharman
990bb34891 Handle mysqli errors in more cases
Report errors autocommit, commit, rollback and mysqli_stmt_attr_set.

Additionally, copy the error from conn to stmt when preparing fails,
so these errors are also handled by mysqli_stmt_prepare.

Closes GH-6157.
2020-10-28 11:33:50 +01:00
Nikita Popov
793bf12f8c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #79375
2020-10-28 11:04:32 +01:00
Dharman
b03776adb5 Fix bug #79375
Make sure deadlock errors are properly propagated and reports in
a number of places in mysqli and PDO MySQL.

This also fixes a memory and a segfault that can occur under these
conditions.
2020-10-28 11:01:47 +01:00
Máté Kocsis
d6264b0966
Verify parameter names of function aliases
Closes GH-6335
2020-10-16 10:56:33 +02:00
Máté Kocsis
41b096b392
Promote a few forgotten warnings to exceptions
Closes GH-6211
2020-09-25 12:08:15 +02:00
Máté Kocsis
e950ca13ea
Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Nikita Popov
9d1c7f8b13 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix mysqli build with mysqlnd and without PDO
2020-09-20 10:02:32 +02:00
Bob Weinand
a7544411df Fix mysqli build with mysqlnd and without PDO 2020-09-20 10:02:09 +02:00
Bob Weinand
0741858ca7 Fix mysqli build with mysqlnd and without PDO 2020-09-20 02:57:39 +02:00
Nikita Popov
9962ad6444 Merge branch 'PHP-7.4'
* PHP-7.4:
  Support NO_BACKSLASH_ESCAPES with newer libmysqlclient
2020-09-18 15:26:04 +02:00
Nikita Popov
e6dc9abdb7 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Support NO_BACKSLASH_ESCAPES with newer libmysqlclient
2020-09-18 15:25:35 +02:00
Nikita Popov
70cba36fc9 Support NO_BACKSLASH_ESCAPES with newer libmysqlclient
Requires the use of mysql_real_escape_string_quote().
2020-09-18 15:24:57 +02:00