-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ext/pgsql: adding pg_close_stmt. #14584
Conversation
ext/pgsql/config.m4
Outdated
@@ -71,6 +71,7 @@ if test "$PHP_PGSQL" != "no"; then | |||
AC_CHECK_LIB(pq, PQchangePassword, AC_DEFINE(HAVE_PG_CHANGE_PASSWORD,1,[PostgreSQL 17 or later])) | |||
AC_CHECK_LIB(pq, PQsocketPoll, AC_DEFINE(HAVE_PG_SOCKET_POLL,1,[PostgreSQL 17 or later])) | |||
AC_CHECK_LIB(pq, PQsetChunkedRowsMode, AC_DEFINE(HAVE_PG_SET_CHUNKED_ROWS_SIZE,1,[PostgreSQL 17 or later])) | |||
AC_CHECK_LIB(pq, PQclosePrepared, AC_DEFINE(HAVE_PG_CLOSE_STMT,1,[PostgreSQL 17 or later])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, now you just need to do rebase against the master branch and check it like this:
PHP_CHECK_LIBRARY([pq], [PQclosePrepared],
[AC_DEFINE([HAVE_PG_CLOSE_STMT], [1], [PostgreSQL 17 or later])],,
[$PGSQL_LIBS])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. I ll even wait your libpq bump merged.
ext/pgsql/pgsql.stub.php
Outdated
@@ -974,6 +974,9 @@ function pg_socket_poll($socket, int $read, int $write, int $timeout = -1): int | |||
#ifdef HAVE_PG_SET_CHUNKED_ROWS_SIZE | |||
function pg_set_chunked_rows_size(Pgsql\Connection $connection, int $size): bool {} | |||
#endif | |||
#ifdef HAVE_PG_CLOSE_STMT | |||
function pg_close_stmt(Pgsql\Connection $connection, string $stmt_name): Pgsql\Result|false {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$statement_name
is the consistent param name with the existing params.
function pg_close_stmt(Pgsql\Connection $connection, string $stmt_name): Pgsql\Result|false {} | |
function pg_close_stmt(Pgsql\Connection $connection, string $statement_name): Pgsql\Result|false {} |
edb0556
to
cde1c80
Compare
cde1c80
to
4419d1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 comments but seems reasonable otherwise
ext/pgsql/pgsql.c
Outdated
if (!pgsql_result) { | ||
RETURN_FALSE; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly?
if (!pgsql_result) { | |
RETURN_FALSE; | |
} else { | |
if (pgsql_result != PGRES_COMMAND_OK) { | |
RETURN_FALSE; | |
} else { |
ext/pgsql/pgsql.c
Outdated
if (!pgsql_result) { | ||
RETURN_FALSE; | ||
} else { | ||
pgsql_result_handle *pg_result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable shadowing
up to postgresql 17, when done with a prepared statement, we could release it with DEALLOCATE sql command which is fine ; until we want to implement a cache solution based on statement ids. Since PostgreSQL 17, PQclosePrepared uses internally the `close` protocol allowing to reuse the statement name while still freeing it. Since the close protocol implementation had been added on libpq within this release, no way to reimplement it.
4419d1b
to
0d3bb58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget the UPGRADING entry :)
up to postgresql 17, when done with a prepared statement, we could release it with DEALLOCATE sql command which is fine ; until we want to implement a cache solution based on statement ids. Since PostgreSQL 17, PQclosePrepared uses internally the `close` protocol allowing to reuse the statement name while still freeing it. Since the close protocol implementation had been added on libpq within this release, no way to reimplement it. close phpGH-14584
up to postgresql 17, when done with a prepared statement, we could release it with DEALLOCATE sql command which is fine ; until we want to implement a cache solution based on statement ids.
Since PostgreSQL 17, PQclosePrepared uses internally the
close
protocol allowing to reuse the statement name while still freeing it. Since the close protocol implementation had been added on libpq within this release, no way to reimplement it.