Commit graph

852 commits

Author SHA1 Message Date
Jakub Zelenka
81dc935945
Merge branch 'PHP-8.3' 2024-02-27 23:08:58 +00:00
Jakub Zelenka
0306983fa4
Merge branch 'PHP-8.2' into PHP-8.3 2024-02-27 23:03:52 +00:00
Jakub Zelenka
330b26e04c
Revert "Fix GH-13519: PGSQL_CONNECT_FORCE_RENEW with persistent connections."
This reverts commit b9a9790be0.
2024-02-27 23:03:28 +00:00
David Carlier
c0ba573c4f Merge branch 'PHP-8.3' 2024-02-27 00:31:54 +00:00
David Carlier
12f52365a5 Merge branch 'PHP-8.2' into PHP-8.3 2024-02-27 00:31:05 +00:00
David Carlier
b9a9790be0 Fix GH-13519: PGSQL_CONNECT_FORCE_RENEW with persistent connections.
persistent connections did not take in account this flag, after the
usual link sanity checks, we remove its entry.

Close GH-13519
2024-02-27 00:30:48 +00:00
Niels Dossche
5941cdaaad
Fix ZTS crashes with persistent resources in modules (#13381)
On shutdown in ZTS the following happens:
- https://github.com/php/php-src/blob/master/Zend/zend.c#L1124-L1125
  gets executed. This destroys global persistent resources and destroys
  the modules. Furthermore, the modules are unloaded too.
- Further down, `ts_free_id(executor_globals_id)` gets executed, which
  calls `executor_globals_dtor`. This function destroys persistent
  resources for each thread.

Notice that in the last step, the modules that the persistent resource
belong to may already have been destroyed. This means that accessing
globals will cause a crash (I previously fixed this with ifdef magic),
or when the module is dynamically loaded we'll try jumping to a
destructor that is no longer loaded in memory. These scenarios cause
crashes.

It's not possible to move the `ts_free_id` call upwards, because that
may break assumptions of callers, and furthermore this would deallocate
the executor globals structure, which means that any access to those
will cause a segfault.

This patch adds a new API to the TSRM that allows running a callback on
a certain resource type. We use this API to destroy the persistent
resources in all threads prior to the module destruction, and keep the
rest of the resource dtor intact.

I verified this fix on Apache with postgres, both dynamically and
statically.

Fixes GH-12974.
2024-02-13 21:43:03 +01:00
David Carlier
aa2e921ef7 Merge branch 'PHP-8.3' 2024-02-08 22:42:55 +00:00
David Carlier
a9c01b92b2 Merge branch 'PHP-8.2' into PHP-8.3 2024-02-08 22:42:19 +00:00
George Barbarosie
452e008f4f Fix GH-13354: ext/pgsql: pg_execute, pg_send_query_params and_send_execute null value by reference.
For these, when passing null values by refence, queries return erroneous values unlike
pg_query_params behaving as expected.

close GH-13355.
2024-02-08 22:42:04 +00:00
Máté Kocsis
d6a0b3af68
Implement PDO driver-specific subclasses
RFC: https://wiki.php.net/rfc/pdo_driver_specific_subclasses
Closes GH-12804

Co-Authored-By: Danack <Danack@basereality.com>
2024-01-11 23:22:41 +01:00
Niels Dossche
20a15ee70b Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
2023-12-27 20:16:44 +01:00
Niels Dossche
42575ac966 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
2023-12-27 20:16:32 +01:00
Niels Dossche
77ac1e8592 Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
On ZTS, the global variables are stored in dynamically allocated memory.
When the module gets shut down this memory is released. After the module
is shut down, only then are the persistent resources cleared. Normally
this isn't an issue, but pgsql and odbc refer to the globals to modify
some counters, after the globals have been freed.
Fix this by guarding the modification.

Closes GH-13032.
2023-12-27 20:14:23 +01:00
David Carlier
70091492d5 Merge branch 'PHP-8.3' 2023-12-23 17:16:04 +00:00
David Carlier
0c8e45e71f Merge branch 'PHP-8.2' into PHP-8.3 2023-12-23 17:15:06 +00:00
David Carlier
d98a45d08c ext/pgsql: pgsql.allow_persistent, no need to use such large type for boolean state.
also ext/odbc, simplifying odd comparison with non persistent connections.

Close GH-12976
2023-12-23 17:14:48 +00:00
Máté Kocsis
beaf1e814a Deprecate calling pg_fetch_result(), pg_field_prtlen(), and pg_field_is_null() with 2 arguments 2023-12-04 22:27:59 +01:00
David Carlier
2ef4785dac Merge branch 'PHP-8.3' 2023-11-27 18:20:38 +00:00
David Carlier
be2d460979 Merge branch 'PHP-8.2' into PHP-8.3 2023-11-27 18:20:27 +00:00
David Carlier
b12c85293d Merge branch 'PHP-8.1' into PHP-8.2 2023-11-27 18:19:02 +00:00
ddv
3f57bd80f6 Fix phpGH-12763: PGSQL pg_untrace(): Argument #1 ($connection) must be of type resource or null, PgSql\Connection given. 2023-11-27 18:18:46 +00:00
Jakub Zelenka
107ed64e2e
Merge branch 'PHP-8.3' 2023-11-20 16:24:57 +00:00
Jakub Zelenka
1e66e6ae73
Revert incomplete PG pipeline addition
Closes GH-12735
2023-11-20 16:22:29 +00:00
David Carlier
994d19d500 Merge branch 'PHP-8.3' 2023-11-10 16:08:08 +00:00
Dmitriy Degtyaryov
63898008c0 Fix GH-9344: pgsql pipeline mode proposal.
Adding pg_send_flush_request.
Fix freeze after next execute pg_send_* on PQgetResult in _php_pgsql_link_has_results.
Set nonblocking for pipelining mode.
No flush client buffer in pg_send_* for pipelining mode.

Close GH-12644
2023-11-10 16:06:04 +00:00
David CARLIER
045dc10b1b
ext/pgsql: cleanup the 3rd protocol is supported since circa 2010. (#12465) 2023-10-18 05:28:47 +01:00
Omar Emara
75da0d7c45 PGSQL: Allow unconditional selection in pg_select
Previously, pg_select did not allow unconditional selection, where an
empty ids array would result in a function failure.

This patch implements two changes:
- Make the ids array an optional parameter.
- Allow the ids array to be empty.

In both cases, unconditional selection happen, which is equivalent to
pg_query('SELECT * FROM <table>;').

Two test cases were added to test the aforementioned changes.

Close GH-5332
2023-10-08 18:22:50 +01:00
Ilija Tovilo
692cea5cbc
Use zend_error_noreturn for E_ERROR consistently
To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes GH-12204
2023-09-14 11:44:55 +02:00
Ilija Tovilo
82aa4253f1 Fix some uouv in ext/pgsql 2023-07-31 15:18:13 +02:00
Máté Kocsis
7ae0273ba3 Make the $row param of pg_fetch_result(), pg_field_prtlen() and pg_field_is_null() nullable 2023-07-18 12:59:21 +02:00
Remi Collet
21aaf3321f
check PQsetErrorContextVisibility availability (libpq >= 9.6) 2023-06-21 08:47:59 +02:00
David Carlier
1cc563f521 Merge branch 'PHP-8.2' 2023-06-18 13:48:04 +01:00
David Carlier
bc45b34b30 Merge branch 'PHP-8.1' into PHP-8.2 2023-06-18 13:45:30 +01:00
David CARLIER
f194cdf852 ext/pgsql: fix PGtrace invalid free issue.
disable trace when closing the connection, is a no op if there is no stream
attached to it.

Close GH-11403
2023-06-18 13:44:39 +01:00
David CARLIER
dd8514a0bd ext/pgsql: adding pg_set_error_context_visibility.
another level of context for pg_last_error/pg_result_error() to include
or not the context in those. PQSHOW_CONTEXT_ERRORS being the default.

Close GH-11395
2023-06-13 18:07:39 +01:00
George Peter Banyard
d5ad75108e
More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
David CARLIER
16a63d7b07 ext/pgsql: php_pgsql_convert converts E_NOTICE to TypeError/ValueError exceptions.
Close GH-11238
2023-06-05 15:31:39 +01:00
David CARLIER
f31d253849 ext/pgsql adding PGSQL_ERRORS_SQLSTATE constant support.
Close GH-11181
2023-05-05 15:08:27 +01:00
David CARLIER
2e0f75ec14
ext/pgsql: pg_lo_read addressing the todo. (#11159) 2023-05-05 12:41:52 +01:00
David Carlier
7ec8ae12c4 ext/pgsql: pg_trace allow to refine its trace mode via 2 new constants.
- PGSQL_TRACE_SUPPRESS_TIMESTAMPS.
- PGSQL_TRACE_REGRESS_MODE to have a more verbose and observable
output to check possible regressions.

Close GH-11041
2023-05-05 11:05:03 +01:00
David CARLIER
84c185c8ba ext/pgsql: pg_cancel_query internal update.
Removing (obsolete) PGrequestCancel usage in favor of the thread-safe
 PQcancel/PQfreeCancel pair.

Close GH-11081
2023-05-05 10:58:48 +01:00
David CARLIER
6a9061e0af Fix GH-9344: pgsql pipeline mode proposal.
Adding pg_enter_pipeline_mode, pg_exit_pipeline_mode,
pg_pipeline_sync and pg_pipeline_status.

Close GH-10868
2023-04-28 20:53:11 +01:00
Máté Kocsis
945db3cd61
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix ZPP of pg_lo_export()
2023-04-27 18:53:49 +02:00
Máté Kocsis
a2d90aaef2
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix ZPP of pg_lo_export()
2023-04-27 18:51:19 +02:00
Máté Kocsis
f0149c5c0b
Fix ZPP of pg_lo_export()
Closes GH-11132
2023-04-27 18:50:09 +02:00
David Carlier
b19f556349 Merge branch 'PHP-8.2' 2023-03-18 07:10:57 +00:00
David Carlier
892f833807 Merge branch 'PHP-8.1' into PHP-8.2 2023-03-18 07:10:06 +00:00
David CARLIER
5adeed3051 ext/psql: pg_meta_data, extended mode, fix typo for pseudo typtype.
Closes GH-10865.
2023-03-18 07:09:13 +00:00
David CARLIER
feb82d91b9
pgsql_insert fix unit tests (#10860) 2023-03-15 22:57:25 +00:00