-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Feature Request: Add SQLSTATE return when the pg_connect() failed to the error text #18335
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
Comments
Since changing existing behavior would be a BC break, an RFC would be required. However, if we’re just adding a new function for making connections, an RFC might not be necessary. @devnexen edit: cc: @NattyNarwhal |
It is definitively a fair request. I ll put some more thoughts whether we should add an optional parameter to pg_(*)connect or something else. |
One option would be to give |
You should be able to get the SQLSTATE of a failed connection in the procedural ODBC extension by not specifying a connection. (I don't know if Pg does this, but it seems to be a common pattern with pre-PDO extensions; ibm_db2 also does this.) <?php
odbc_connect("BOGUS", "user", "hunter2");
var_dump(odbc_error());
|
I didn’t know that, thanks. It looks like pgsql doesn’t currently have an equivalent feature, but I think it could be a good option. |
|
@EntertainmentOne ; I spent time to dig into libpq, while there is definitively what we call proper SQLSTATE in a query level, there is no such thing in a connection level though. Would you be able to clarify what you are expecting more precisely ? |
[Resend 2] |
I report here a message from the libpq devs themselves
|
Description
Now, we only get the string desprection, no SQLSTATE.
I must get the SQLSTATE to handle the errors,
Caused by the pg_connect() returns false, I cannot get SQLSTATE by general methods.
Please add this feature to pgsql extension.
The text was updated successfully, but these errors were encountered: