Skip to content

ext/pgsql: adding postgresql 17 new libpq wrapper call. #14571

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

Closed
wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

pg_set_chunked_rows_mode to allow to fetch results in chunk of max N rows.

@devnexen devnexen force-pushed the pg_set_chunked_rows_mode branch 2 times, most recently from 9181959 to ccb8fb8 Compare June 14, 2024 19:54
@devnexen devnexen marked this pull request as ready for review June 14, 2024 20:10
@devnexen devnexen requested a review from kocsismate as a code owner June 14, 2024 20:10
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists("pg_set_chunked_rows_mode")) die("pg_set_chunked_rows_mode unsupported");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests it borked otherwise due to an invalid SKIPIF section

Suggested change
if (!function_exists("pg_set_chunked_rows_mode")) die("pg_set_chunked_rows_mode unsupported");
if (!function_exists("pg_set_chunked_rows_mode")) die("skip pg_set_chunked_rows_mode unsupported");

Comment on lines 6270 to 6272
/** can still fail if it is not allowed e.g. already fetched results **/

RETURN_LONG((zend_long)PQsetChunkedRowsMode(link->conn, (int)size));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What value is returned on failure? 0 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. it might be more appropriate to return a bool then.

@devnexen devnexen force-pushed the pg_set_chunked_rows_mode branch from ccb8fb8 to c4e9aed Compare June 15, 2024 17:33
@@ -6248,3 +6246,29 @@ PHP_FUNCTION(pg_socket_poll)

RETURN_LONG((zend_long)PQsocketPoll(socket, (int)read, (int)write, (int)ts));
}

#if defined(HAVE_PG_SET_CHUNKED_ROWS_MODE)
PHP_FUNCTION(pg_set_chunked_rows_mode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the function confuses me, is this setting a "mode" or the number of rows to chunk?

Copy link
Member Author

@devnexen devnexen Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"mode" refers to chunk mode vs single row mode (which is another libpq call, thus the exposition of PGSQL_TUPLES_CHUNK constant to differentiate it) but yes it set the number of rows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it possibly make sense to name the function we expose to userland in a slightly more sensible way? I think just replacing mode with size would possibly do.

And thus it mean, it can only fail if trying to set up a chunk size for results that cannot be chunked?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can do indeed.

pg_set_chunked_rows_mode to allow to fetch results in chunk of max N rows.
@devnexen devnexen force-pushed the pg_set_chunked_rows_mode branch from c4e9aed to 99f8c2f Compare June 15, 2024 18:22
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better to me :) Don't forget to add an UPGRADING entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants