pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
8+ messages / 2 participants
[nested] [flat]

* 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
@ 2016-01-18 19:31 John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  0 siblings, 1 reply; 8+ messages in thread

From: John Kew @ 2016-01-18 19:31 UTC (permalink / raw)
  To: pgsql-odbc


We have been testing the new postgres driver and we found an issue with the SQL_ATTR_ROW_ARRAY_SIZE attribute. We use this attribute to request row sets in chunks with can align with cache boundaries and so-forth; it is a general optimization we use with a number of data sources. With 9.05 though, executing a query which returns a result set > SQL_ATTR_ROW_ARRAY_SIZE will result in the second fetch of rows being duplicates of the first fetch.


So let's say we set this attribute to 84 (m_rowsToFetch) and use the m_rowStatus array to count the success rows.


SQLSetStmtAttrW( hstmt[repeatIndex], SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)m_rowsToFetch, SQL_IS_UINTEGER );

SQLSetStmtAttr( hstmt[repeatIndex], SQL_ATTR_ROW_STATUS_PTR, &m_rowStatus[0], 0 );



We then create two queries  - the first of which returns 24 rows normally and the second which returns 120 rows. The first query will return the correct results for both 9.03 and 9.05; 24 rows. The second query will perform two fetch operations. For 9.03 the first fetch returns 84 rows and the second 36 rows, correctly totaling 120 rows. For 9.05 we get 84 and 84 on the fetch counts, and it appears the second query has duplicate content.


I believe you could modify one of the bulk* tests to exhibit this behavior; or we can sanitize a small part of our regression suite and release a full repro in code.


-John

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
@ 2016-01-19 20:46 ` John Kew <jkew@tableau.com>
  2016-01-20 11:03   ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 1 reply; 8+ messages in thread

From: John Kew @ 2016-01-19 20:46 UTC (permalink / raw)
  To: pgsql-odbc

Folks,


As promised here is a repro of the issue we are seeing using some generated data in a temp table. The first query returns the correct results for both 9.0.3 and 9.0.5; whereas the second returns the wrong results with 9.0.5 only.


---------

#include <windows.h>
#include <sqlext.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>




namespace {

    std::vector<SQLUSMALLINT> m_rowStatus;

    SQLHENV henv = SQL_NULL_HANDLE;
    SQLHDBC hdbc = SQL_NULL_HANDLE;
    SQLHSTMT hstmt = SQL_NULL_HANDLE;
    SQLRETURN ret;

    SQLCHAR buffer[SQL_MAX_MESSAGE_LENGTH];
    SQLSMALLINT bufSize = SQL_MAX_MESSAGE_LENGTH;

    void ReportError( SQLSMALLINT handleType, SQLHANDLE handle ) {
        SQLCHAR sqlState[6] = { 0 }, msg[SQL_MAX_MESSAGE_LENGTH] = { 0 };
        SQLINTEGER nativeError;
        SQLSMALLINT recNumber = 1, msgLen = SQL_MAX_MESSAGE_LENGTH;
        SQLRETURN sret;

        while ( (sret = SQLGetDiagRec( handleType, handle, recNumber, sqlState, &nativeError,
            msg, SQL_MAX_MESSAGE_LENGTH, &msgLen )) != SQL_NO_DATA && SQL_SUCCEEDED( sret ) ) {
            std::cerr << "SqlState      = " << sqlState << std::endl
                << "NativeError   = " << nativeError << std::endl
                << "Msg           = " << msg << std::endl
                << "MsgLen        = " << msgLen << std::endl;
            recNumber++;
        }
        std::cerr << "SQLGetDiagRec returned " << sret << std::endl;
    }


    void connect( const std::string &url ) {

        // Set up environment handle
        ret = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        // Set up environment attributes
        ret = SQLSetEnvAttr( henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0 );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_ENV, henv );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        // Set up connect handle
        ret = SQLAllocHandle( SQL_HANDLE_DBC, henv, &hdbc );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        // Establish connection
        ret = SQLDriverConnect(
            hdbc,
            SQL_NULL_HANDLE,
            (SQLCHAR *)url.c_str(),
            (SQLSMALLINT)url.size(),
            buffer,
            SQL_MAX_MESSAGE_LENGTH,
            &bufSize,
            SQL_DRIVER_NOPROMPT );

        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }
    }

    void disconnect() {
        SQLDisconnect( hdbc );
        SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
        SQLFreeHandle( SQL_HANDLE_ENV, henv );
    }

    void createTempTable( const int numRowsInTable ) {

        SQLHSTMT hstmt = SQL_NULL_HANDLE;

        ret = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_STMT, hstmt );
            SQLDisconnect( hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        std::string createTable;
        createTable = "create temp table postgres_test as (";
        createTable += "SELECT generate_series( 1, " + std::to_string( numRowsInTable ) + " ) AS dim1, ";
        createTable += "md5( random()::text ) AS dim2, md5( random()::text ) AS dim3, md5( random()::text ) AS dim4, ";
        createTable += "md5( random()::text ) AS dim5, md5( random()::text ) AS dim6, random() AS meas1";
        createTable += ")";

        std::cout << std::endl << createTable << std::endl;

        // Execute the command
        ret = SQLExecDirect( hstmt, (SQLCHAR *)createTable.c_str(), SQL_NTS );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_STMT, hstmt );
            SQLFreeHandle( SQL_HANDLE_STMT, hstmt );
            SQLDisconnect( hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        SQLFreeHandle( SQL_HANDLE_STMT, hstmt );
    }


    int runQuery( const std::string &query, const int rowArraySize ) {

        // Establish rowArraySize

        ret = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_STMT, hstmt );
            SQLDisconnect( hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        ret = SQLSetStmtAttrW( hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)rowArraySize, SQL_IS_UINTEGER );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_STMT, hstmt );
            SQLDisconnect( hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }
        m_rowStatus.resize( rowArraySize );
        ret = SQLSetStmtAttr( hstmt, SQL_ATTR_ROW_STATUS_PTR, &m_rowStatus[0], 0 );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_STMT, hstmt );
            SQLDisconnect( hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        // Execute the query

        ret = SQLExecDirect( hstmt, (SQLCHAR *)query.c_str(), SQL_NTS );
        if ( !SQL_SUCCEEDED( ret ) ) {
            ReportError( SQL_HANDLE_STMT, hstmt );
            SQLFreeHandle( SQL_HANDLE_STMT, hstmt );
            SQLDisconnect( hdbc );
            SQLFreeHandle( SQL_HANDLE_DBC, hdbc );
            SQLFreeHandle( SQL_HANDLE_ENV, henv );
            exit( -1 );
        }

        if ( rowArraySize != 1 )
           std::cerr << "   rows returned by query with rowArraySize=" << rowArraySize << ":" << std::endl;

        // Fetch and iterate through m_rowStatus to count rows fetched

        int totalRows = 0;
        int fetchIdx = 0;
        while ( (ret = SQLFetch( hstmt )) != SQL_NO_DATA && SQL_SUCCEEDED( ret ) ) {
            fetchIdx++;

            SQLULEN validRowsExported = 0;
            for ( SQLULEN row = 0; row < rowArraySize; ++row )
            {
                if ( m_rowStatus[row] == SQL_PARAM_SUCCESS ||
                    m_rowStatus[row] == SQL_PARAM_SUCCESS_WITH_INFO )
                    validRowsExported++;
                else
                    break;
            }

            totalRows += (int)validRowsExported;
            if  ( rowArraySize != 1 )
                std::cout << "      fetchIdx=" << fetchIdx << ", fetched rows=" << validRowsExported << ", total rows=" << totalRows << std::endl;
        }

        SQLFreeHandle( SQL_HANDLE_STMT, hstmt );

        return totalRows;
    }


    void runTest( const std::string &url, const std::string &query, const int rowArraySize ) {

        // execute query using rowArraySize 1

        int rowsReturnedByQuery = runQuery( query, 1 );
        std::cerr << "   with rowArraySize 1, number of rows returned by query is " << rowsReturnedByQuery << std::endl;

        // execute query using specified rowArraySize

        if ( rowsReturnedByQuery != runQuery( query, rowArraySize ) ){
            std::cerr << "Fetch rows failed!" << std::endl;
        }
    }
}


/*
* Timing executing single query statement
* args[0]: database url
* args[1]: number of rows to insert into the temp table
* args[2]: rowArraySize to use in the test
*
* Examples:
* url                                                                                                                                                                                                                                            numRowsInTable rowArraySize
* "DRIVER={PostgreSQL Unicode(x64)};DATABASE=TestV1;SERVER=postgres.test.tsi.lan;UID=test;PWD=password;PORT=5432;BOOLSASCHAR=0;LFCONVERSION=0;UseDeclareFetch=1" 120            14
*/
int main( int argc, char* argv[] ) {

    std::string url = argv[1];
    int numRowsInTable = atoi( argv[2] );
    int rowArraySize = atoi( argv[3] );

    connect( url );
    createTempTable( numRowsInTable );

    std::string query;


    // Run test for query that appears to work for all rowArraySize values when numRowsInTable == 120

    query = "SELECT \"postgres_test\".\"dim1\" AS \"dim1\", substring(\"postgres_test\".\"dim2\",1,1) AS \"dim2\", substring(\"postgres_test\".\"dim3\",1,1) AS \"dim3\",";
    query += " substring(\"postgres_test\".\"dim4\",1,1) AS \"dim4\", substring(\"postgres_test\".\"dim5\",1,1) AS \"dim5\", SUM(\"postgres_test\".\"meas1\") AS \"sum:meas1:ok\",";
    query += " substring(\"postgres_test\".\"dim6\",1,1) AS \"dim6\"";
    query += " FROM \"postgres_test\" \"postgres_test\"";
    query += " WHERE substring(\"postgres_test\".\"dim2\",1,1) IN ('a','b','c')";
    query += " GROUP BY 1,  2,  3,  4,  5,  7";

    std::cout << std::endl << query << std::endl << std::endl;

    runTest( url, query, rowArraySize );


    // Run test for query that appears to work for few rowArraySize values when numRowsInTable == 120
    // It consistently succeeds for rowArraySize values <=8,10,12,15,20 but fails for most other values.

    query = "SELECT \"postgres_test\".\"dim1\" AS \"dim1\", \"postgres_test\".\"dim2\" AS \"dim2\", \"postgres_test\".\"dim3\" AS \"dim3\",";
    query += " \"postgres_test\".\"dim4\" AS \"dim4\", \"postgres_test\".\"dim5\" AS \"dim5\", SUM(\"postgres_test\".\"meas1\") AS \"sum:meas1:ok\",";
    query += " \"postgres_test\".\"dim6\" AS \"dim6\"";
    query += " FROM \"postgres_test\" \"postgres_test\"";
    query += " GROUP BY 1,  2,  3,  4,  5,  7";

    std::cout << std::endl << query << std::endl << std::endl;

    runTest( url, query, rowArraySize );


    disconnect();

    return 0;
}




________________________________
From: John Kew
Sent: Monday, January 18, 2016 11:31 AM
To: pgsql-odbc@postgresql.org
Subject: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute



We have been testing the new postgres driver and we found an issue with the SQL_ATTR_ROW_ARRAY_SIZE attribute. We use this attribute to request row sets in chunks with can align with cache boundaries and so-forth; it is a general optimization we use with a number of data sources. With 9.05 though, executing a query which returns a result set > SQL_ATTR_ROW_ARRAY_SIZE will result in the second fetch of rows being duplicates of the first fetch.


So let's say we set this attribute to 84 (m_rowsToFetch) and use the m_rowStatus array to count the success rows.


SQLSetStmtAttrW( hstmt[repeatIndex], SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)m_rowsToFetch, SQL_IS_UINTEGER );

SQLSetStmtAttr( hstmt[repeatIndex], SQL_ATTR_ROW_STATUS_PTR, &m_rowStatus[0], 0 );



We then create two queries  - the first of which returns 24 rows normally and the second which returns 120 rows. The first query will return the correct results for both 9.03 and 9.05; 24 rows. The second query will perform two fetch operations. For 9.03 the first fetch returns 84 rows and the second 36 rows, correctly totaling 120 rows. For 9.05 we get 84 and 84 on the fetch counts, and it appears the second query has duplicate content.


I believe you could modify one of the bulk* tests to exhibit this behavior; or we can sanitize a small part of our regression suite and release a full repro in code.


-John

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
@ 2016-01-20 11:03   ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-20 12:24     ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 1 reply; 8+ messages in thread

From: Inoue, Hiroshi @ 2016-01-20 11:03 UTC (permalink / raw)
  To: John Kew <jkew@tableau.com>; +Cc: pgsql-odbc

Hi John,

Thanks for the test case.

On 2016/01/20 5:46, John Kew wrote:
>
> Folks,
>
>
> As promised here is a repro of the issue we are seeing using some 
> generated data in a temp table. The first query returns the correct 
> results for both 9.0.3 and 9.0.5; whereas the second returns the wrong 
> results with 9.0.5 only.
>
>
>

The result seems to be right here.

SELECT "postgres_test"."dim1" AS "dim1", "postgres_test"."dim2" AS 
"dim2", "postgres_test"."dim3" AS "dim3", "postgres_test"."dim4" AS 
"dim4", "postgres_test"."
dim5" AS "dim5", SUM("postgres_test"."meas1") AS "sum:meas1:ok", 
"postgres_test"."dim6" AS "dim6" FROM "postgres_test" "postgres_test" 
GROUP BY 1, 2,  3,  4, 5,  7

    with rowArraySize 1, number of rows returned by query is 120
    rows returned by query with rowArraySize=84:
       fetchIdx=1, fetched rows=84, total rows=84
       fetchIdx=2, fetched rows=36, total rows=120

regards,
Hiroshi Inoue

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-20 11:03   ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2016-01-20 12:24     ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 12:08       ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 1 reply; 8+ messages in thread

From: Inoue, Hiroshi @ 2016-01-20 12:24 UTC (permalink / raw)
  To: John Kew <jkew@tableau.com>; +Cc: pgsql-odbc

Oops I'm sorry.
I was testing other drivers.

regards,
Hiroshi Inoue

On 2016/01/20 20:03, Inoue, Hiroshi wrote:
> Hi John,
>
> Thanks for the test case.
>
> On 2016/01/20 5:46, John Kew wrote:
>>
>> Folks,
>>
>>
>> As promised here is a repro of the issue we are seeing using some 
>> generated data in a temp table. The first query returns the correct 
>> results for both 9.0.3 and 9.0.5; whereas the second returns the 
>> wrong results with 9.0.5 only.
>>
>>
>>
>
> The result seems to be right here.
>
> SELECT "postgres_test"."dim1" AS "dim1", "postgres_test"."dim2" AS 
> "dim2", "postgres_test"."dim3" AS "dim3", "postgres_test"."dim4" AS 
> "dim4", "postgres_test"."
> dim5" AS "dim5", SUM("postgres_test"."meas1") AS "sum:meas1:ok", 
> "postgres_test"."dim6" AS "dim6" FROM "postgres_test" "postgres_test" 
> GROUP BY 1, 2,  3,  4, 5,  7
>
>    with rowArraySize 1, number of rows returned by query is 120
>    rows returned by query with rowArraySize=84:
>       fetchIdx=1, fetched rows=84, total rows=84
>       fetchIdx=2, fetched rows=36, total rows=120
>
> regards,
> Hiroshi Inoue
>
> このメッセージにウイルス は検出されませんでした。
> AVG によってチェックされました - www.avg.com <http://www.avg.com;
> バージョン: 2015.0.6176 / ウイルスデータベース:4522/11441 - リリース 
> 日:2016/01/19
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-20 11:03   ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-20 12:24     ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2016-01-22 12:08       ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 16:40         ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Inoue, Hiroshi @ 2016-01-22 12:08 UTC (permalink / raw)
  To: John Kew <jkew@tableau.com>; +Cc: pgsql-odbc

Hi John,

I can reproduce the case now and have a trial patch.
Could you test it?

regards,
Hiroshi Inoue

On 2016/01/20 21:24, Inoue, Hiroshi wrote:
> Oops I'm sorry.
> I was testing other drivers.
>
> regards,
> Hiroshi Inoue
>
> On 2016/01/20 20:03, Inoue, Hiroshi wrote:
>> Hi John,
>>
>> Thanks for the test case.
>>
>> On 2016/01/20 5:46, John Kew wrote:
>>>
>>> Folks,
>>>
>>>
>>> As promised here is a repro of the issue we are seeing using some 
>>> generated data in a temp table. The first query returns the correct 
>>> results for both 9.0.3 and 9.0.5; whereas the second returns the 
>>> wrong results with 9.0.5 only.
>>>
>>>
>>>
>>
>> The result seems to be right here.
>>
>> SELECT "postgres_test"."dim1" AS "dim1", "postgres_test"."dim2" AS 
>> "dim2", "postgres_test"."dim3" AS "dim3", "postgres_test"."dim4" AS 
>> "dim4", "postgres_test"."
>> dim5" AS "dim5", SUM("postgres_test"."meas1") AS "sum:meas1:ok", 
>> "postgres_test"."dim6" AS "dim6" FROM "postgres_test" "postgres_test" 
>> GROUP BY 1, 2,  3,  4, 5,  7
>>
>>    with rowArraySize 1, number of rows returned by query is 120
>>    rows returned by query with rowArraySize=84:
>>       fetchIdx=1, fetched rows=84, total rows=84
>>       fetchIdx=2, fetched rows=36, total rows=120
>>
>> regards,
>> Hiroshi Inoue
>>
>> このメッセージにウイ ルス は検出されませんでした。
>> AVG によってチェックされました - www.avg.com <http://www.avg.com;
>> バージョン: 2015.0.6176 / ウイルスデータベース:4522/11441 - リリー 
>> ス日:2016/01/19
>>
>
> このメッセージにウイルス は検出されませんでした。
> AVG によってチェックされました - www.avg.com <http://www.avg.com;
> バージョン: 2015.0.6176 / ウイルスデータベース:4522/11442 - リリース 
> 日:2016/01/20
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-20 11:03   ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-20 12:24     ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 12:08       ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2016-01-22 16:40         ` John Kew <jkew@tableau.com>
  2016-01-23 12:43           ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 1 reply; 8+ messages in thread

From: John Kew @ 2016-01-22 16:40 UTC (permalink / raw)
  To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>; +Cc: pgsql-odbc

We would be happy to.


-John


________________________________
From: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
Sent: Friday, January 22, 2016 4:08 AM
To: John Kew
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute

Hi John,

I can reproduce the case now and have a trial patch.
Could you test it?

regards,
Hiroshi Inoue

On 2016/01/20 21:24, Inoue, Hiroshi wrote:
Oops I'm sorry.
I was testing other drivers.

regards,
Hiroshi Inoue

On 2016/01/20 20:03, Inoue, Hiroshi wrote:
Hi John,

Thanks for the test case.

On 2016/01/20 5:46, John Kew wrote:

Folks,


As promised here is a repro of the issue we are seeing using some generated data in a temp table. The first query returns the correct results for both 9.0.3 and 9.0.5; whereas the second returns the wrong results with 9.0.5 only.



The result seems to be right here.

SELECT "postgres_test"."dim1" AS "dim1", "postgres_test"."dim2" AS "dim2", "postgres_test"."dim3" AS "dim3", "postgres_test"."dim4" AS "dim4", "postgres_test"."
dim5" AS "dim5", SUM("postgres_test"."meas1") AS "sum:meas1:ok", "postgres_test"."dim6" AS "dim6" FROM "postgres_test" "postgres_test" GROUP BY 1, 2,  3,  4, 5,  7

   with rowArraySize 1, number of rows returned by query is 120
   rows returned by query with rowArraySize=84:
      fetchIdx=1, fetched rows=84, total rows=84
      fetchIdx=2, fetched rows=36, total rows=120

regards,
Hiroshi Inoue

?????????? ?? ????????????
AVG ????????????? - www.avg.com<http://www.avg.com;

?????: 2015.0.6176 / ??????????:4522/11441 - ?????:2016/01/19


???????????? ????????????
AVG ????????????? - www.avg.com<http://www.avg.com;
?????: 2015.0.6176 / ??????????:4522/11442 - ?????:2016/01/20

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-20 11:03   ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-20 12:24     ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 12:08       ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 16:40         ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
@ 2016-01-23 12:43           ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-25 21:26             ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Inoue, Hiroshi @ 2016-01-23 12:43 UTC (permalink / raw)
  To: John Kew <jkew@tableau.com>; +Cc: pgsql-odbc

Hi,

Please try the attached patch.
Or please try the drivers on testing for 9.5.0101 at
  http://www.ne.jp/asahi/inocchichichi/entrance/psqlodbc/
.

regards,
Hiroshi Inoue

On 2016/01/23 1:40, John Kew wrote:
>
> We would be happy to.
>
>
> -John
>
>
>
> ------------------------------------------------------------------------
> *From:* Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
> *Sent:* Friday, January 22, 2016 4:08 AM
> *To:* John Kew
> *Cc:* pgsql-odbc@postgresql.org
> *Subject:* Re: [ODBC] Re: 9.0.5 issue - duplicate rows returned when 
> using SQL_ATTR_ROW_ARRAY_SIZE attribute
> Hi John,
>
> I can reproduce the case now and have a trial patch.
> Could you test it?
>
> regards,
> Hiroshi Inoue
>
> On 2016/01/20 21:24, Inoue, Hiroshi wrote:
>>
>>>
>>
>

-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc

Attachments:

row_array_size.patch (text/x-diff, 1.4K) download diff --git a/connection.c b/connection.c index 8d2d7e7..86d7da7 100644 --- a/connection.c +++ b/connection.c @@ -1886,7 +1886,7 @@ inolog("Discarded the first SAVEPOINT\n"); * called from QR_next_tuple and must return * immediately. */ - if (!CC_from_PGresult(res, stmt, self, cursor, &pgres)) + if (!CC_from_PGresult(res, stmt, NULL, cursor, &pgres)) { retres = NULL; break; diff --git a/qresult.c b/qresult.c index 7f3445b..5848959 100644 --- a/qresult.c +++ b/qresult.c @@ -592,6 +592,8 @@ QR_from_PGresult(QResultClass *self, StatementClass *stmt, ConnectionClass *conn Int2 dummy1, dummy2; int cidx; +if (NULL != conn) +{ /* First, get column information */ QR_set_conn(self, conn); @@ -660,6 +662,7 @@ inolog("!![%d].PGType %u->%u\n", i, PIC_get_pgtype(ipdopts->parameters[i]), CI_g } } } +} /* Then, get the data itself */ @@ -670,10 +673,13 @@ inolog("!!%p->cursTup=%d total_read=%d\n", self, self->cursTuple, self->num_tota if (!QR_once_reached_eof(self) && self->cursTuple >= (Int4) self->num_total_read) self->num_total_read = self->cursTuple + 1; +if (NULL != conn) +{ /* Force a read to occur in next_tuple */ QR_set_next_in_cache(self, 0); QR_set_rowstart_in_cache(self, 0); self->key_base = 0; +} /* * Also fill in command tag. (Typically, it's SELECT, but can also be
^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute
  2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-19 20:46 ` Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-20 11:03   ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-20 12:24     ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 12:08       ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-01-22 16:40         ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
  2016-01-23 12:43           ` Re: Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2016-01-25 21:26             ` John Kew <jkew@tableau.com>
  0 siblings, 0 replies; 8+ messages in thread

From: John Kew @ 2016-01-25 21:26 UTC (permalink / raw)
  To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>; +Cc: pgsql-odbc

It looks like the patch passes fixes the issue! We will let you know if we see anything else.


-John


________________________________
From: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
Sent: Saturday, January 23, 2016 4:43 AM
To: John Kew
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute

Hi,

Please try the attached patch.
Or please try the drivers on testing for 9.5.0101 at
 http://www.ne.jp/asahi/inocchichichi/entrance/psqlodbc/
.

regards,
Hiroshi Inoue

On 2016/01/23 1:40, John Kew wrote:

We would be happy to.


-John


________________________________
From: Inoue, Hiroshi <h-inoue@dream.email.ne.jp><mailto:h-inoue@dream.email.ne.jp>
Sent: Friday, January 22, 2016 4:08 AM
To: John Kew
Cc: pgsql-odbc@postgresql.org<mailto:pgsql-odbc@postgresql.org>
Subject: Re: [ODBC] Re: 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute

Hi John,

I can reproduce the case now and have a trial patch.
Could you test it?

regards,
Hiroshi Inoue

On 2016/01/20 21:24, Inoue, Hiroshi wrote:

^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2016-01-25 21:26 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 19:31 9.0.5 issue - duplicate rows returned when using SQL_ATTR_ROW_ARRAY_SIZE attribute John Kew <jkew@tableau.com>
2016-01-19 20:46 ` John Kew <jkew@tableau.com>
2016-01-20 11:03   ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2016-01-20 12:24     ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2016-01-22 12:08       ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2016-01-22 16:40         ` John Kew <jkew@tableau.com>
2016-01-23 12:43           ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2016-01-25 21:26             ` John Kew <jkew@tableau.com>

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