pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 靳骄阳 <jinjiaoyang@smail.nju.edu.cn>
To: pgsql-odbc <pgsql-odbc@postgresql.org>
Subject: SQLNumResultCols does not have a timeout
Date: Mon, 6 May 2024 15:44:55 +0800
Message-ID: <tencent_19D47A7E4615ED57765B47F2@qq.com> (raw)

Hello,
       I stuck in SQLNumResultCols 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:
    SQLHENV henv;
    SQLHDBC hdbc;
    SQLRETURN retcode;
    
    SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
    SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);

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

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

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

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

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

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




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


Thanks
Jin

Message-ID: <tencent_19D47A7E4615ED57765B47F2@qq.com>
Permalink:  ../tencent_19D47A7E4615ED57765B47F2@qq.com/
Also on:    postgresql.org/message-id/tencent_19D47A7E4615ED57765B47F2@qq.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: jinjiaoyang@smail.nju.edu.cn
  Subject: Re: SQLNumResultCols does not have a timeout
  In-Reply-To: <tencent_19D47A7E4615ED57765B47F2@qq.com>
  References: <tencent_19D47A7E4615ED57765B47F2@qq.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox