Re: figuring out why I am having this issue

From: "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk>
To: "Joel Fradkin" <jfradkin(at)wazagua(dot)com>
Cc: <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: figuring out why I am having this issue
Date: 2005-09-01 14:05:55
Message-ID: E7F85A1B5FF8D44C8A1AF6885BC9A0E4AC9DF6@ratbert.vale-housing.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

> -----Original Message-----
> From: Joel Fradkin [mailto:jfradkin(at)wazagua(dot)com]
> Sent: 01 September 2005 14:48
> To: Dave Page
> Subject: RE: [ODBC] figuring out why I am having this issue
>
> What if the
> size it thinks the field is is wrong?

It defaults the max_longvarchar_size if the DB doesn't return a value.
Note that this is for the column though, not the individual field.

I suppose what could be happening is this:

1) The app queries (using SQLDescribeCol) the results for the data type
etc.
2) The app allocates a buffer based on the size reported for the notes
column.
3) The app reads a notes field (using SQLGetData), which reports the
actual field size.
4) It keeps reading chunks of data until it gets to the end, and
somewhere along the line, overflows the buffer allocated, eg:

char szData[max_longvarchar_size];
char szChunk[1024];

// Get the data in chunks
do
{
retcode = SQLGetData(hStmt, 1, SQL_C_CHAR, szChunk,
sizeof(szChunk), &cbData);
strcat(szData, szChunk);

} while (retcode != SQL_SUCCESS && retcode != SQL_NO_DATA);

> This is not an issue for all data in my table (I have a huge amount of
> records it works fine for). I noticed this notes field is
> using some odd
> char like the 1/2 char you know where it makes it small etc.
> Maybe it is not
> calculating the size of this particular note field.

I doubt it - for strings that's handled here:

void
set_tuplefield_string(TupleField *tuple_field, const char *string)
{
tuple_field->len = strlen(string);
tuple_field->value = malloc(strlen(string) + 1);
strcpy(tuple_field->value, string);
}

Regards, Dave

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Joel Fradkin 2005-09-01 14:42:51 Re: figuring out why I am having this issue
Previous Message Alexandra - Gestão XXI Sistemas e Soluções 2005-09-01 13:43:15 Fw: psqlodbc - PostgreSql 8.0 - Errors accessing tables using ODBC - PostgreSql 8.0