Skip to content

ext/pgsql: adding pg_set_error_context_visibility. #11395

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 2 commits into from

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Jun 7, 2023

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.

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.
Comment on lines 2843 to 2849
if (ZEND_NUM_ARGS() == 1) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &visibility) == FAILURE) {
RETURN_THROWS();
}
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Considering we have deprecated the fetching of the default link I would rather not introduce a new function with this functionality. Would also make the stubs correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

oky doky

Comment on lines 2859 to 2863
if (visibility & (PQSHOW_CONTEXT_NEVER|PQSHOW_CONTEXT_ERRORS|PQSHOW_CONTEXT_ALWAYS)) {
RETURN_LONG(PQsetErrorContextVisibility(pgsql, visibility));
} else {
RETURN_FALSE;
}
Copy link
Member

Choose a reason for hiding this comment

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

Make this a ValueError in case of a wrong value?

@devnexen devnexen force-pushed the pgsql_error_update branch from 8e15b79 to de6a771 Compare June 9, 2023 18:33
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.

Minor nits but LGTM.

Do not forget to add an entry in UPGRADING about the new function

Comment on lines 974 to 975
/** @param PgSql\Connection|int $connection */
function pg_set_error_context_visibility($connection, int $visibility = UNKNOWN): int|false {}
Copy link
Member

@Girgias Girgias Jun 13, 2023

Choose a reason for hiding this comment

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

Since the visibility is not optional anymore and it doesn't return false on failure.

Suggested change
/** @param PgSql\Connection|int $connection */
function pg_set_error_context_visibility($connection, int $visibility = UNKNOWN): int|false {}
function pg_set_error_context_visibility(PgSql\Connection $connection, int $visibility): int {}

Comment on lines 24 to 28
if (function_exists('pg_set_error_context_visibility')) {
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_NEVER);
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ERRORS);
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ALWAYS);
}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like it's always defined?

@devnexen devnexen force-pushed the pgsql_error_update branch from de6a771 to 427a632 Compare June 13, 2023 12:08
@@ -951,6 +970,9 @@ function pg_exit_pipeline_mode(PgSql\Connection $connection): bool {}
function pg_pipeline_sync(PgSql\Connection $connection): bool {}
function pg_pipeline_status(PgSql\Connection $connection): int {}
#endif

/** @param PgSql\Connection|int $connection */
Copy link
Member

Choose a reason for hiding this comment

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

This comment is not needed any more now.
Feel free to remove this when merging if CI is happy.

@remicollet
Copy link
Member

This breaks build on old RHEL 7
See pr #11495

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.

3 participants