SQLNumResultCols does not have a timeout

From: 靳骄阳 <jinjiaoyang(at)smail(dot)nju(dot)edu(dot)cn>
To: pgsql-odbc <pgsql-odbc(at)postgresql(dot)org>
Subject: SQLNumResultCols does not have a timeout
Date: 2024-05-06 07:44:55
Message-ID: tencent_19D47A7E4615ED57765B47F2@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hello,
&nbsp; &nbsp; &nbsp; &nbsp;I stuck in&nbsp;SQLNumResultCols&nbsp;afterunplug my Ethernet cable.

My configuration:
-----------------
server - Linux x86 + postgresql 14.2​
client - Linux x86 + postgresql ODBC 16.00​


Problem description:

--------------------

My code is as follow:
&nbsp; &nbsp; SQLHENV henv;
&nbsp; &nbsp; SQLHDBC hdbc;
&nbsp; &nbsp; SQLRETURN retcode;
&nbsp; &nbsp;
&nbsp; &nbsp; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &amp;henv);
&nbsp; &nbsp; SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);

&nbsp; &nbsp; SQLAllocHandle(SQL_HANDLE_DBC, henv, &amp;hdbc);
&nbsp; &nbsp;
&nbsp; &nbsp; SQLCHAR* connStr = (SQLCHAR*)"DRIVER={PostgreSQL};"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "SERVER=173.20.99.107;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Port=5432;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "DATABASE=cpspg;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UserName=sac;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Password=sac;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Keepalive=1"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "KeepaliveTime=1;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "KeepaliveInterval=1"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Parse=1"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UseServerSidePrepare=0";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //"CHARSET=UTF8;"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //"AUTOCOMMIT=0";

&nbsp; &nbsp; retcode = SQLDriverConnect(hdbc, NULL, connStr, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT);

&nbsp; &nbsp; if (retcode == SQL_SUCCESS || retcode== SQL_SUCCESS_WITH_INFO)
&nbsp; &nbsp; {
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; SQLHANDLE hstmt;

&nbsp; &nbsp; &nbsp; &nbsp; SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &amp;hstmt);
&nbsp; &nbsp; &nbsp; &nbsp; const char* sql_statement = "select now()";
&nbsp; &nbsp; &nbsp; &nbsp; retcode = SQLPrepare(hstmt, (SQLCHAR*)sql_statement, SQL_NTS);
&nbsp; &nbsp; &nbsp; &nbsp; std::string temp;
&nbsp; &nbsp; &nbsp; &nbsp; std::cout << "input something:";
&nbsp; &nbsp; &nbsp; &nbsp; std::cin &gt;&gt; temp;
&nbsp; &nbsp; &nbsp; &nbsp; SQLSMALLINT count;
&nbsp; &nbsp; &nbsp; &nbsp; retcode = SQLNumResultCols(hstmt, &amp;count);
&nbsp; &nbsp; &nbsp; &nbsp; std::cout << "col count is " << count << std::endl;

&nbsp; &nbsp; &nbsp; &nbsp; if (retcode == SQL_SUCCESS || retcode== SQL_SUCCESS_WITH_INFO)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout << "insert success" << std::endl;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HandleDiagnosticRecord(hdbc, SQL_HANDLE_DBC, retcode);
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; //SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_ROLLBACK);
&nbsp; &nbsp; &nbsp; &nbsp; SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
&nbsp; &nbsp; &nbsp; &nbsp; SQLDisconnect(hdbc);
&nbsp; &nbsp; }
&nbsp; &nbsp; else
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; HandleDiagnosticRecord(hdbc, SQL_HANDLE_DBC, retcode);
&nbsp; &nbsp; }

&nbsp; &nbsp; SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
&nbsp; &nbsp; SQLFreeHandle(SQL_HANDLE_ENV, henv);

I&nbsp;unplug my Ethernet cable when wait input and then input something, the program stucked in SQLNumResultCols. Finally got stuck in function&nbsp;PQgetResult and&nbsp;pqWaitTimed.
So my question is: Is this a bug or how to set timeout when the network has lost?

Thanks
Jin

Browse pgsql-odbc by date

  From Date Subject
Next Message Paul Chambre 2024-05-08 11:17:11 Building psqlODBC on newer Visual Studio versions
Previous Message Dave Cramer 2024-04-18 20:16:37 Please test release on github