pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBug in convert.c copy_and_convert_field
4+ messages / 2 participants
[nested] [flat]
* Bug in convert.c copy_and_convert_field
@ 2005-02-11 17:28 Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
2005-02-11 18:06 ` Re: Bug in convert.c copy_and_convert_field Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
0 siblings, 1 reply; 4+ messages in thread
From: Paul Cochrane @ 2005-02-11 17:28 UTC (permalink / raw)
To: pgsql-odbc
Hi again list.
I think I've encountered a bug in the file convert.c -
copy_and_convert_field procedure. Unfortunately my C is a little out of
practise not having done it for 10 years or so. Can anyone help? I think
I've traced the error to the default part of the switch around line 850
(that where the dodgy lines are being placed in the mylog file so it's
somewhere before that). Below is a snippet of the mylog showing the
problem. The lines where it is saying DEFAULT: & the ptr part of the
string. In some cases this is correct but in others there are lots of
extra / strange characters. The len field always seems to be correct
however.
The log file ends with a single ' which may explain the error I get on
the server (1) could not receive data from client: Connection reset by
peer and (2) unexpected EOF on client connection
]**** SC_fetch: manual_result
[2052]fetch: cols=13, lf=0, opts = 137569848, opts->bindings =
137610576, buffer[] = 35483564
[2052]type = 1043
[2052]manual_result
[2052]value = ''
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = '',
cbValueMax=129
[2052]DEFAULT: len = 0, ptr = '8Ã3ts'
[2052] SQL_C_CHAR, default: len = 0, cbValueMax = 129,
rgbValueBindRow = ''
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=1, opts = 137569848, opts->bindings =
137610576, buffer[] = 35483695
[2052]type = 1043
[2052]manual_result
[2052]value = 'public'
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = 'public',
cbValueMax=129
[2052]DEFAULT: len = 6, ptr = 'public'
[2052] SQL_C_CHAR, default: len = 6, cbValueMax = 129,
rgbValueBindRow = 'public'
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=2, opts = 137569848, opts->bindings =
137610576, buffer[] = 35483826
[2052]type = 1043
[2052]manual_result
[2052]value = 'LOGIN'
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = 'LOGIN',
cbValueMax=129
[2052]DEFAULT: len = 5, ptr = 'LOGINc'
[2052] SQL_C_CHAR, default: len = 5, cbValueMax = 129,
rgbValueBindRow = 'LOGIN'
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=3, opts = 137569848, opts->bindings =
137610576, buffer[] = 35483957
[2052]type = 21
[2052]manual_result
[2052]value = '0'
[2052]copy_and_convert: field_type = 21, fctype = 5, value = '0',
cbValueMax=2
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=4, opts = 137569848, opts->bindings =
137610576, buffer[] = 35483961
[2052]type = 1043
[2052]manual_result
[2052]value = ''
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = '',
cbValueMax=129
[2052]DEFAULT: len = 0, ptr = '8Ã3 To'
[2052] SQL_C_CHAR, default: len = 0, cbValueMax = 129,
rgbValueBindRow = ''
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=5, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484092
[2052]type = 1043
[2052]manual_result
[2052]value = 'LOGIN_pkey'
[2052]copy_and_convert: field_type = 1043, fctype = 1, value =
'LOGIN_pkey', cbValueMax=129
[2052]DEFAULT: len = 10, ptr = 'LOGIN_pkey'
[2052] SQL_C_CHAR, default: len = 10, cbValueMax = 129,
rgbValueBindRow = 'LOGIN_pkey'
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=6, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484223
[2052]type = 21
[2052]manual_result
[2052]value = '3'
[2052]copy_and_convert: field_type = 21, fctype = 5, value = '3',
cbValueMax=2
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=7, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484227
[2052]type = 21
[2052]manual_result
[2052]value = '1'
[2052]copy_and_convert: field_type = 21, fctype = 5, value = '1',
cbValueMax=2
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=8, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484231
[2052]type = 1043
[2052]manual_result
[2052]value = 'Login'
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = 'Login',
cbValueMax=129
[2052]DEFAULT: len = 5, ptr = 'LoginTo'
[2052] SQL_C_CHAR, default: len = 5, cbValueMax = 129,
rgbValueBindRow = 'Login'
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=9, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484362
[2052]type = 18
[2052]manual_result
[2052]value = 'A'
[2052]copy_and_convert: field_type = 18, fctype = 1, value = 'A',
cbValueMax=2
[2052]DEFAULT: len = 1, ptr = 'AÃ3Nc'
[2052] SQL_C_CHAR, default: len = 1, cbValueMax = 2, rgbValueBindRow
= 'A'
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=10, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484366
[2052]type = 23
[2052]manual_result
[2052]value = '<NULL>'
[2052]copy_and_convert: field_type = 23, fctype = 4, value = '<NULL>',
cbValueMax=4
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=11, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484372
[2052]type = 23
[2052]manual_result
[2052]value = '<NULL>'
[2052]copy_and_convert: field_type = 23, fctype = 4, value = '<NULL>',
cbValueMax=4
[2052]copy_and_convert: retval = 0
[2052]fetch: cols=13, lf=12, opts = 137569848, opts->bindings =
137610576, buffer[] = 35484378
[2052]type = 1043
[2052]manual_result
[2052]value = '<NULL>'
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = '<NULL>',
cbValueMax=129
[2052]copy_and_convert: retval = 0
[2052][[SQLFetch]][2052]PGAPI_ExtendedFetch: stmt=137569712
[2052]SQL_FETCH_NEXT: num_tuples=7, currtuple=0
[2052]PGAPI_ExtendedFetch: new currTuple = 0
[2052]manual_result = 1, use_declarefetch = 1
[2052]**** SC_fetch: manual_result
[2052]fetch: cols=13, lf=0, opts = 137569848, opts->bindings =
137610576, buffer[] = 35483564
[2052]type = 1043
[2052]manual_result
[2052]value = ''
[2052]copy_and_convert: field_type = 1043, fctype = 1, value = '',
cbValueMax=129
[2052]DEFAULT: len = 0, ptr = '8Ã3nTo'
[2052] SQL_C_CHAR, default: len = 0, cbValueMax = 129,
rgbValueBindRow = ''
[2052]copy_and_convert: retval = 0
; This is how the mylog ends
[2052]copy_and_convert: field_type = 1043, fctype = 1, value =
'Classification', cbValueMax=129
[2052]DEFAULT: len = 14, ptr = '
--
Paul Cochrane (paul.m.cochrane@tuht.scot.nhs.uk)
+--------------------------------------------------------
| Tayside Orthopaedic & Rehabilitation Technology Centre
| Ninewells Hospital & Medical School
| Dundee, Scotland, UK.
| DD1 9SY
| Phone: Internal: 36284
| External: +44 (1382) 496284
| Fax: +44 (1382) 496322
+--------------------------------------------------------
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Bug in convert.c copy_and_convert_field
2005-02-11 17:28 Bug in convert.c copy_and_convert_field Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
@ 2005-02-11 18:06 ` Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
0 siblings, 0 replies; 4+ messages in thread
From: Paul Cochrane @ 2005-02-11 18:06 UTC (permalink / raw)
To: pgsql-odbc
Paul Cochrane wrote:
> Hi again list.
>
> I think I've encountered a bug in the file convert.c -
> copy_and_convert_field procedure. Unfortunately my C is a little out
> of practise not having done it for 10 years or so. Can anyone help? I
> think I've traced the error to the default part of the switch around
> line 850 (that where the dodgy lines are being placed in the mylog
> file so it's somewhere before that). Below is a snippet of the mylog
> showing the problem. The lines where it is saying DEFAULT: & the ptr
> part of the string. In some cases this is correct but in others there
> are lots of extra / strange characters. The len field always seems to
> be correct however.
>
> The log file ends with a single ' which may explain the error I get on
> the server (1) could not receive data from client: Connection reset by
> peer and (2) unexpected EOF on client connection
>
I've found a quick fix to this problem. I've simply added a line:
strncpy(ptr+len, "\0", 1);
just before the mylog line on line 850 of convert.c. I believe this
simply ensures that there is a NULL at the end of the string stored in
ptr. There may be a more elegant way to do this but it seems to work.
Now onto the next fault cause it fails again shortly after this.
Bugger! :-(
Paul
--
Paul Cochrane (paul.m.cochrane@tuht.scot.nhs.uk)
+--------------------------------------------------------
| Tayside Orthopaedic & Rehabilitation Technology Centre
| Ninewells Hospital & Medical School
| Dundee, Scotland, UK.
| DD1 9SY
| Phone: Internal: 36284
| External: +44 (1382) 496284
| Fax: +44 (1382) 496322
+--------------------------------------------------------
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Bug in convert.c copy_and_convert_field
@ 2005-02-11 21:14 Dave Page <dpage@vale-housing.co.uk>
2005-02-14 09:57 ` Re: Bug in convert.c copy_and_convert_field Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
0 siblings, 1 reply; 4+ messages in thread
From: Dave Page @ 2005-02-11 21:14 UTC (permalink / raw)
To: Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>; pgsql-odbc
> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Paul Cochrane
> Sent: 11 February 2005 18:06
> To: pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] Bug in convert.c copy_and_convert_field
>
> I've found a quick fix to this problem. I've simply added a line:
>
> strncpy(ptr+len, "\0", 1);
>
> just before the mylog line on line 850 of convert.c. I believe this
> simply ensures that there is a NULL at the end of the string
> stored in
> ptr. There may be a more elegant way to do this but it seems to work.
I don't know if this fix is correct or not, but are you sure that ptr is
big enough to do this without clobbering something else?
Regards, Dave.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Bug in convert.c copy_and_convert_field
2005-02-11 21:14 Re: Bug in convert.c copy_and_convert_field Dave Page <dpage@vale-housing.co.uk>
@ 2005-02-14 09:57 ` Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
0 siblings, 0 replies; 4+ messages in thread
From: Paul Cochrane @ 2005-02-14 09:57 UTC (permalink / raw)
To: Dave Page <dpage@vale-housing.co.uk>; pgsql-odbc
Dave Page wrote:
>
>
>>Subject: Re: [ODBC] Bug in convert.c copy_and_convert_field
>>
>>I've found a quick fix to this problem. I've simply added a line:
>>
>> strncpy(ptr+len, "\0", 1);
>>
>>just before the mylog line on line 850 of convert.c. I believe this
>>simply ensures that there is a NULL at the end of the string
>>stored in
>>ptr. There may be a more elegant way to do this but it seems to work.
>>
>>
>
>I don't know if this fix is correct or not, but are you sure that ptr is
>big enough to do this without clobbering something else?
>
>Regards, Dave.
>
>
To be honest, I'm not entirely sure. I'm guessing that it's OK since the
returned LEN vaule seems to be set correctly. The mylog just returns
rubbish as the string value which I took to be related to not having a
NULL at the end of the string.
Paul
--
Paul Cochrane (paul.m.cochrane@tuht.scot.nhs.uk)
+--------------------------------------------------------
| Tayside Orthopaedic & Rehabilitation Technology Centre
| Ninewells Hospital & Medical School
| Dundee, Scotland, UK.
| DD1 9SY
| Phone: Internal: 36284
| External: +44 (1382) 496284
| Fax: +44 (1382) 496322
+--------------------------------------------------------
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-02-14 09:57 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-11 17:28 Bug in convert.c copy_and_convert_field Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
2005-02-11 18:06 ` Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
2005-02-11 21:14 Re: Bug in convert.c copy_and_convert_field Dave Page <dpage@vale-housing.co.uk>
2005-02-14 09:57 ` Paul Cochrane <paul.m.cochrane@tuht.scot.nhs.uk>
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