Hello Inoue-san,
Thanks for your psqlodbc fix.
I did test with the patch that atteched in the following mail.
It works fine.
When QR_REALLOC_return_with_error return FALSE, executing API
correctly results in failure.
These are logs of my "out of memory" test.
psqlodbc log:
------------
[0.376]PQsendQuery: 00000000003F5FA0 'SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9 FROM t42 LIMIT
100000'
[0.387] nFields: 9
[0.390] fieldname='col1', adtid=25, adtsize=-1, atttypmod=-1 (rel,att)=(26258,1)
[0.392] fieldname='col2', adtid=25, adtsize=-1, atttypmod=-1 (rel,att)=(26258,2)
snip
[1.426] 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3)
[1.429]QR_REALLOC_error
[1.431] Getting result from PGresult failed
mylog:
------
[9820-1.520] environ.c[ER_ReturnError]259: szSqlState = 'S1001',len=63, szError='(null)'
[9820-1.521] pgapi30.c[PGAPI_GetDiagField]390: leaving 0
[9820-1.521]odbcapi30w[SQLGetDiagFieldW]364: Entering Handle=(3,0000000000406AB0) Rec=2 Id=4
info=(00000000002BDC20,12)
[9820-1.523] pgapi30.c[PGAPI_GetDiagField]92: entering rec=2
[9820-1.523] environ.c[ER_ReturnError]202: entering status = 4, msg = #Out of memory while reading tuples.;
memory allocation error???#
[9820-1.525] pgapi30.c[PGAPI_GetDiagField]390: leaving 100
[9820-6.945]psqlodbc.c[DllMain]137: DETACHING PSQLODBC35W.DLL
Thanks,
Haruka Takatsuka
On Mon, 12 Mar 2018 16:06:50 +0900
"Inoue, Hiroshi" <h-inoue@dream.email.ne.jp> wrote:
> Hi TAKATSUKA-san,
>
> sorry for the late reply.
>
> On 2018/02/27 18:33, TAKATSUKA Haruka wrote:
> > Hello, psqlODBC team.
> >
> > When we fetch large data via psqlodbc, we sometimes fail to
> > get all rows completely without any API's error responses;
> > SQLExecDirect returns SQL_SUCCESS and SQLFetch returns just SQL_NODATA.
> > But there are QR_REALLOC_error reported in mylog at that time.
> >
> > I reproduced it by tweaking QR_REALLOC_return_with_error macro
> > to intentionally fail to allocate memory frequently.
> >
> > I propose the patch attached.
> > It makes the code in CC_send_query_append() go out the while-loop immediately
> > after CC_from_PGresult() at the case PORES_BAD_RESPONSE, PORES_FATAL_ERROR or PORES_NO_MEMORY_ERROR.
>
> Thanks for the bug report.
> By applying your patch, subsequent queries after ALLOC errors are
> rejected unfortunately
> with the error message 'another command is already in progress'.
>
> I propose the patch attached. Does the patch work well in your test cases?
>
> regards,
> Hiroshi Inoue