-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Conversation
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.
ext/pgsql/pgsql.c
Outdated
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 { |
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.
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.
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.
oky doky
ext/pgsql/pgsql.c
Outdated
if (visibility & (PQSHOW_CONTEXT_NEVER|PQSHOW_CONTEXT_ERRORS|PQSHOW_CONTEXT_ALWAYS)) { | ||
RETURN_LONG(PQsetErrorContextVisibility(pgsql, visibility)); | ||
} else { | ||
RETURN_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.
Make this a ValueError in case of a wrong value?
8e15b79
to
de6a771
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.
Minor nits but LGTM.
Do not forget to add an entry in UPGRADING about the new function
ext/pgsql/pgsql.stub.php
Outdated
/** @param PgSql\Connection|int $connection */ | ||
function pg_set_error_context_visibility($connection, int $visibility = UNKNOWN): int|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.
Since the visibility is not optional anymore and it doesn't return false on failure.
/** @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 {} |
ext/pgsql/tests/07optional.phpt
Outdated
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); | ||
} |
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.
It looks like it's always defined?
de6a771
to
427a632
Compare
@@ -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 */ |
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.
This comment is not needed any more now.
Feel free to remove this when merging if CI is happy.
This breaks build on old RHEL 7 |
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.