Thread: pgsql-odbc SQLGetDiagRec() API issue.

pgsql-odbc SQLGetDiagRec() API issue.

From
Tukaram Gaikwad
Date:

Hi team,

 

We killed Postgress node and called SQLExecute().

 

SQLExecute() function fail and return -1, to get diagnostic info I called SQLGetDiagRec()

this function but it gives me SQLState as "00000" which is SQL_SUCCESS,

in failure case which wrong.

 

Actually it should give NO_CONNECTION SQLState.


PostgreSQL running vesion on env: psql (PostgreSQL) 12.1

 

CODE Snippet.

 

long retcode = SQLExecute(this->m_OdbcStmt);

 

SQLCHAR     messageText[SQL_MAX_MESSAGE_LENGTH + 1] = {0};

SQLCHAR     state[SQL_SQLSTATE_SIZE + 1] = {0};

SQLSMALLINT textLength = SQL_MAX_MESSAGE_LENGTH + 1;

             

SQLSMALLINT idx = 1;

sqlgetdiagrecret = SQLGetDiagRec(SQL_HANDLE_STMT,

                                                          this->m_OdbcStmt,

                                                          idx,            //record Number

                                                          state,                      //

                                                          &o_errorNo,       //native Error Pointer

                                                          messageText,    //Message Text

                                                          SQL_MAX_MESSAGE_LENGTH + 1, //buffer length

                                                          &textLength     //length of message text

                                                          );

 Please help us to resolve this issue.    

Re: pgsql-odbc SQLGetDiagRec() API issue.

From
Craig Ringer
Date:
On Wed, 9 Dec 2020 at 17:55, Tukaram Gaikwad <tukaramgaikwad10@gmail.com> wrote:

Hi team,

 

We killed Postgress node and called SQLExecute().

 

SQLExecute() function fail and return -1, to get diagnostic info I called SQLGetDiagRec()

this function but it gives me SQLState as "00000" which is SQL_SUCCESS,

in failure case which wrong.

 

Actually it should give NO_CONNECTION SQLState.


PostgreSQL running vesion on env: psql (PostgreSQL) 12.1

 

CODE Snippet.

 

long retcode = SQLExecute(this->m_OdbcStmt);

 

SQLCHAR     messageText[SQL_MAX_MESSAGE_LENGTH + 1] = {0};

SQLCHAR     state[SQL_SQLSTATE_SIZE + 1] = {0};

SQLSMALLINT textLength = SQL_MAX_MESSAGE_LENGTH + 1;

             

SQLSMALLINT idx = 1;

sqlgetdiagrecret = SQLGetDiagRec(SQL_HANDLE_STMT,

                                                          this->m_OdbcStmt,

                                                          idx,            //record Number

                                                          state,                      //

                                                          &o_errorNo,       //native Error Pointer

                                                          messageText,    //Message Text

                                                          SQL_MAX_MESSAGE_LENGTH + 1, //buffer length

                                                          &textLength     //length of message text

                                                          );

 Please help us to resolve this issue.    


I suggest starting with a complete and compileable test case.

Re: pgsql-odbc SQLGetDiagRec() API issue.

From
Craig Ringer
Date:


On Thu, 10 Dec 2020, 15:09 Tukaram Gaikwad, <tukaramgaikwad10@gmail.com> wrote:
Hi Craig,

I can't share source code my company, it against policy.

Then write a new program that demonstrates the issue in a self contained way.

How is anyone supposed to help you if there's only a tiny fragment of the relevant code shown? And none of the runtime context, database state etc.

If you can't collect enough info to allow someone to see what's going on, you may wish to look at the various commercial support providers instead. That way you can have NDAs and so on. See https://www.postgresql.org/support/professional_support/ . Note that I work for one of them so I'm hardly independent.