1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

288 Commits

Author SHA1 Message Date
KentarouTakeda
c56e8caaed ext/pgsql, ext/pdo_pgsql: Remove preprocessor guards for symbols predating libpq 10 (#21384)
While working on php/doc-en#5409 to clean up outdated PostgreSQL
version notes in the documentation, I noticed that the source code
also retains #ifdef guards for symbols guaranteed to exist in
libpq >= 10.0 (the minimum enforced in build/php.m4 via
PQencryptPasswordConn).

Removed guards (all confirmed in PostgreSQL 10 documentation):

- `PG_DIAG_{INTERNAL_POSITION,INTERNAL_QUERY}`: libpq 8.0+
- `PG_DIAG_{SCHEMA,TABLE,COLUMN,DATATYPE,CONSTRAINT}_NAME`: libpq 9.3+
- `PG_DIAG_SEVERITY_NONLOCALIZED`: libpq 9.6+
- `CONNECTION_SSL_STARTUP`: libpq 8.0+
- `CONNECTION_CONSUME`: libpq 10.0+

Refs:
- https://www.postgresql.org/docs/10/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD
- https://www.postgresql.org/docs/10/libpq-connect.html#LIBPQ-PQCONNECTSTARTPARAMS
- 53e31d5883/build/php.m4 (L1927)
2026-03-08 05:42:50 +00:00
David Carlier
b16e534f9a Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-21055: Pdo/Pgsql typo for GSS negotiation connection status attribute.
2026-01-28 18:15:04 +00:00
David Carlier
00466a068e Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-21055: Pdo/Pgsql typo for GSS negotiation connection status attribute.
2026-01-28 18:14:53 +00:00
Loïc Saos
3037526810 Fix GH-21055: Pdo/Pgsql typo for GSS negotiation connection status attribute.
close GH-21057
2026-01-28 18:12:08 +00:00
武田 憲太郎
19deb91002 pdo_pgsql: Reset persistent session state on disconnect-equivalent processing
close GH-20572
2025-12-11 20:22:09 +00:00
David Carlier
5668b16ad2 Revert "Pdo\Pgsql: Fix getColumnMeta() for GH-15287 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0)"
This reverts commit 898235127b.
2025-09-29 14:43:51 +01:00
Guillaume Outters
898235127b Pdo\Pgsql: Fix getColumnMeta() for GH-15287 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0)
As stated in the UPGRADING, using the passthrough ("single-row") mode of libpq (introduced in #15287)
forbids passing a new query while the current one's results have not been entirely consumed.
… But I didn't notice that ext/pdo_pgsql internally used new queries to fetch metadata (example use case:
a call to getColumnMeta() while fetch()ing row by row will interleave the getColumnMeta()-triggered
internal query to the database, with the results fetching for the user-called query).

This PR makes those internal calls return NULL for non-essential metadata, instead of letting libpq abort the user-called query.

It moreover includes a small tweak to table oid-to-name translation, with a 1-slot cache.
This may by chance allow the internal call to return something instead of NULL,
but it will nonetheless avoid 30 server calls to get the table name of 30 columns of the same table.

optimize calls to foreach(columns of the same table) getColumnMeta()

- each call queried the DB to know the name associated with the table's OID:
  cache the result between two calls
- make pdo_pgsql_translate_oid_to_table higher-level,
  with the last parameter being the handle instead of the raw connection;
  thus the statement is cleaner, letting the handle do all memory handling on the table oid-to-name translation cache
  (which by the way is a driver feature more than a statement one)

close GH-16249
2025-09-28 22:37:19 +01:00
David Carlier
f7ca8138e7 Merge branch 'PHP-8.4' 2025-07-27 12:56:05 +01:00
David Carlier
279589c3af Merge branch 'PHP-8.3' into PHP-8.4 2025-07-27 12:55:17 +01:00
dixyes
e16df981bf ext/pdo_pgsql: Fix _pdo_pgsql_trim_message bad access
close GH-19239
2025-07-27 12:54:43 +01:00
Jakub Zelenka
545d1536d8 Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 09:34:49 -07:00
Ilija Tovilo
49d94cced0 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GHSA-453j-q27h-5p8x
  Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
  Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
2025-07-01 17:48:00 +02:00
Jakub Zelenka
66bd809ac9 Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 23:01:16 +09:00
David CARLIER
a5196bf3d6 ext/pdo_pgsql: updating copy from according to pgsql extension workflow. (#18175)
mainly using zend_string instead.
2025-03-28 18:24:45 +00:00
Gina Peter Banyard
b757fa812d ext/pdo_{odbc|pgsql}: Use precomputed data_source_len (#17744)
This is already computed by PDO, no need to recompute it again inside the drivers.
2025-02-09 13:10:20 +00:00
Gina Peter Banyard
09791ed1d1 ext/pdo: Convert database_object_handle zval to zend_object* (#17629)
This saves 8 bytes on the PDO statement struct.

We change the PGSQL PDO driver API to take a zend_object* instead of a zval* at the same time.
2025-01-30 18:34:03 +00:00
Kamil Tekiela
3e1138e997 Remove disable_native_prepares 2024-11-25 22:27:43 +01:00
David CARLIER
dbcc77d0c2 Fix GH-15893: Pdo\Pgsql backport fixes from GH-16124 (#16158) 2024-10-03 19:25:39 +01:00
Guillaume Outters
68537fd9f4 Fix / implement GH-15287: add a lazy fetch to Pdo\PgSql
Make Pdo\PgSql accept Pdo::setAttribute(PDO::ATTR_PREFETCH, 0) to enter libpq's single row mode.
This avoids storing the whole result set in memory before being able to call the first fetch().

close GH-15750
2024-09-29 08:33:14 +01:00
武田 憲太郎
7f5e96d030 ext/pdo_pgsql: Expanding COPY input from an array to an iterable
close GH-15893
2024-09-28 11:09:34 +01:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
David CARLIER
54e5e7b507 ext/pdo_pgsql: object initialisation, using smart_str api instead. (#14679) 2024-06-27 05:53:38 +01: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
Peter Kokot
4f450b6264 Bump minimum libpq version to 10.0 (#14628)
This bumps the libpq client-side PostgreSQL library minimum required
version from 9.1 to 10.0.

- Sanity check: PQlibVersion -> PQencryptPasswordConn (available since
  libpq 10.0)
- PQsetErrorContextVisibility (available since libpq 9.6)
- lo_truncate64 (available since libpq 9.3), if 32-bit system doesn't
  support lo_*64 functions, error is returned and functions are always
  available

Additionally, the conditional functions usages in pdo_pgsql and pgsql
extensions that got piled up are cleaned and synced:

- pg_prepare (PQprepare available since libpq 7.4)
- pg_query_params (PQexecParams available since libpq 7.4)
- pg_result_error_field (PQresultErrorField available since libpq 7.4)
- pg_send_prepare (PQsendPrepare available since libpq 7.4)
- pg_send_query_params (PQsendQueryParams available since libpq 7.4)
- pg_set_error_verbosity (PQsetErrorVerbosity available since libpq 7.4)
- pg_transaction_status (PQtransactionStatus available since libpq 7.4)

The Windows libpq version is currently at version 11.4:
https://github.com/winlibs/postgresql

Discussion: https://news-web.php.net/php.internals/123609
Follow-up of GH-14540
2024-06-25 20:50:04 +02:00
Matteo Beccati
715b9aaa09 Implemented PDO Driver specific SQL parsers
RFC: http://wiki.php.net/rfc/pdo_driver_specific_parsers
2024-06-17 23:31:24 +02:00
Guillaume Outters
a9259c0496 Add Pdo\Pgsql::setNoticeCallback() (#14299)
This moves the new method from magically being added to the PDO class from the driver to just be available on the dedicated subclass. 

Drive-by fixes to NEWS and UPGRADING
2024-06-09 03:04:51 +01:00
Peter Kokot
df481ef941 Simplify PDO include paths (#14444)
PDO include paths can be simplified and synced as done in other
extensions: either the project root directory or the phpincludedir (for
the system installation). The 'ext' include is automatically appended
when doing phpize build. In php-src it is only present on Windows build.
The PHP_CHECK_PDO_INCLUDES is left intact working as before and checks
if PDO headers are found.
2024-06-03 12:56:21 +02:00
Gina Peter Banyard
25a5146180 Clean-up unused headers (#14365)
* ext/mbstring.c: clean-up headers and include intrinsics
2024-06-01 17:12:42 +01:00
Guillaume Outters
c265b9085a ext/pdo_pgsql: adding pgsqlSetNoticeCallback
Allows a callback to be triggered on every notice sent by PostgreSQL.

Such notices can be sent with a RAISE NOTICE in PL/pgSQL; in a long running
stored procedure, they prove useful as realtime checkpoint indicators.

close GH-6764
2024-05-22 12:32:11 +01: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
David CARLIER
95f829db13 ext/pdo_pgsql: cleanup the 3rd protocol is supported since circa 2010. (#12464) 2023-10-18 05:29:14 +01:00
SakiTakamachi
b5c287e4b4 Fix GH-12423: Changed to prioritize DSN authentication information over arguments.
Added connection test

Close GH-12424
2023-10-15 20:24:30 +01:00
David CARLIER
ec3daea1d6 ext/pdo_pgsql: connection status update to distinguish from truly bad quality connections.
Close GH-11443
2023-06-13 18:08:06 +01:00
Christoph M. Becker
c8955c078a Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
Max Kellermann
308fd311ea ext/{standard,json,random,...}: add missing includes 2023-01-10 14:19:03 +00:00
Christoph M. Becker
15405c60da Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-9411: PgSQL large object resource is incorrectly closed
2022-09-05 17:28:23 +02:00
Christoph M. Becker
b5cad508fe Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9411: PgSQL large object resource is incorrectly closed
2022-09-05 17:26:13 +02:00
Yurun
6ac3f7c84d Fix GH-9411: PgSQL large object resource is incorrectly closed
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-9411.
2022-09-05 16:37:54 +02:00
George Peter Banyard
bac8ccef09 Remove SIZEOF_OFF_T undef in PDO PGSQL driver (#8301)
This has been introduced as part of fixing https://bugs.php.net/79532 (67f9b0b754) because ``pg_config.h`` was included.

As this is no longer the case we don't need this undef any more.
2022-06-09 13:29:20 +01:00
Christoph M. Becker
926dee1b6f Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix error message allocation of PDO PgSQL
2021-12-12 15:18:32 +01:00
SATO Kentaro
778513f605 Fix error message allocation of PDO PgSQL
Closes GH-7723.
2021-12-12 15:17:36 +01:00
Nikita Popov
efbb2198d4 Return value from ZEND_ATOL
Instead of assigning it as part of the macro itself, which makes
usage quite awkward.
2021-07-12 16:51:24 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +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
George Peter Banyard
ebaeb93c3f Add API to fetch bool value for PDO attribute values
Closes GH-6766
2021-03-17 00:58:01 +00:00
George Peter Banyard
a78aea8948 Refactor PDO's last inserted ID handler to use and return zend_string
Closes GH-6617
2021-01-19 11:54:25 +00:00
George Peter Banyard
94ea8e247b Refactor PDO doer handler to use zend_string 2021-01-19 11:42:39 +00: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