Skip to content

Commit 32aff25

Browse files
kocsismatenikic
andcommitted
Convert resources to objects in ext/pgsql
Closes GH-6791 Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
1 parent 57a635c commit 32aff25

26 files changed

+1207
-1251
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ PHP NEWS
9898
. PDO SQLite:
9999
. Fixed bug #38334 (Proper data-type support for PDO_SQLITE). (Nikita)
100100

101+
- PgSQL:
102+
. Convert resource<pgsql link> to object \PgSql\Connection. (Máté)
103+
. Convert resource<pgsql result> to object \PgSql\Result. (Máté)
104+
. Convert resource<pgsql large object> to object \PgSql\Lob. (Máté)
105+
101106
- PSpell:
102107
. Convert resource<pspell> to object \PSpell\Dictionary. (Sara)
103108
. Convert resource<pspell config> to object \PSpell\Config. (Sara)

UPGRADING

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ PHP 8.1 UPGRADE NOTES
120120
types. You can restore the previous behavior by enabling the
121121
PDO::ATTR_STRINGIFY_FETCHES option.
122122

123+
- PgSQL:
124+
. The PgSQL functions now accept and return, respectively, \PgSql\Connection
125+
objects instead of "pgsql link" resources. Return value checks using
126+
is_resource() should be replaced with checks for `false`.
127+
. The PgSQL functions now accept and return, respectively, \PgSql\Result
128+
objects instead of "pgsql result" resources. Return value checks using
129+
is_resource() should be replaced with checks for `false`.
130+
. The PgSQL functions now accept and return, respectively, \PgSql\Lob
131+
objects instead of "pgsql large object" resources. Return value checks
132+
using is_resource() should be replaced with checks for `false`.
133+
123134
- PSpell:
124135
. The PSpell functions now accept and return, respectively, PSpell\Dictionary objects
125136
instead of "pspell" resources. Return value checks using is_resource()

Zend/Optimizer/zend_func_info.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,19 +658,17 @@ static const func_info_t func_infos[] = {
658658
F1("session_encode", MAY_BE_FALSE | MAY_BE_STRING),
659659

660660
/* ext/pgsql */
661-
FN("pg_connect", MAY_BE_FALSE | MAY_BE_RESOURCE),
662-
FN("pg_pconnect", MAY_BE_FALSE | MAY_BE_RESOURCE),
663661
F1("pg_dbname", MAY_BE_STRING),
664662
F1("pg_options", MAY_BE_STRING),
665663
F1("pg_port", MAY_BE_STRING),
666664
F1("pg_tty", MAY_BE_STRING),
667665
F1("pg_host", MAY_BE_STRING),
668666
F1("pg_version", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_NULL),
669667
F1("pg_parameter_status", MAY_BE_FALSE | MAY_BE_STRING),
670-
F1("pg_query", MAY_BE_FALSE | MAY_BE_RESOURCE),
671-
F1("pg_query_params", MAY_BE_FALSE | MAY_BE_RESOURCE),
672-
F1("pg_prepare", MAY_BE_FALSE | MAY_BE_RESOURCE),
673-
F1("pg_execute", MAY_BE_FALSE | MAY_BE_RESOURCE),
668+
F1("pg_query", MAY_BE_FALSE | MAY_BE_OBJECT),
669+
F1("pg_query_params", MAY_BE_FALSE | MAY_BE_OBJECT),
670+
F1("pg_prepare", MAY_BE_FALSE | MAY_BE_OBJECT),
671+
F1("pg_execute", MAY_BE_FALSE | MAY_BE_OBJECT),
674672
FN("pg_last_notice", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY ),
675673
F1("pg_field_name", MAY_BE_STRING),
676674
F1("pg_field_type_oid", MAY_BE_LONG | MAY_BE_STRING),
@@ -683,7 +681,7 @@ static const func_info_t func_infos[] = {
683681
F1("pg_fetch_all_columns", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
684682
F1("pg_last_oid", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
685683
F1("pg_lo_create", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
686-
F1("pg_lo_open", MAY_BE_FALSE | MAY_BE_RESOURCE),
684+
F1("pg_lo_open", MAY_BE_FALSE | MAY_BE_OBJECT),
687685
F1("pg_lo_read", MAY_BE_FALSE | MAY_BE_STRING),
688686
F1("pg_lo_import", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
689687
F1("pg_copy_to", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -694,13 +692,13 @@ static const func_info_t func_infos[] = {
694692
F1("pg_escape_identifier", MAY_BE_FALSE | MAY_BE_STRING),
695693
F1("pg_result_error", MAY_BE_FALSE | MAY_BE_STRING),
696694
F1("pg_result_error_field", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
697-
F1("pg_get_result", MAY_BE_FALSE | MAY_BE_RESOURCE),
695+
F1("pg_get_result", MAY_BE_FALSE | MAY_BE_OBJECT),
698696
F1("pg_result_status", MAY_BE_LONG | MAY_BE_STRING),
699697
F1("pg_get_notify", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
700-
F1("pg_socket", MAY_BE_FALSE | MAY_BE_RESOURCE),
698+
F1("pg_socket", MAY_BE_FALSE | MAY_BE_OBJECT),
701699
F1("pg_meta_data", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
702700
F1("pg_convert", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
703-
F1("pg_insert", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_RESOURCE | MAY_BE_STRING),
701+
F1("pg_insert", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_OBJECT | MAY_BE_STRING),
704702
F1("pg_update", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
705703
F1("pg_delete", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
706704
F1("pg_select", MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),

0 commit comments

Comments
 (0)