Re: figuring out why I am having this issue

Поиск
Список
Период
Сортировка
От Joel Fradkin
Тема Re: figuring out why I am having this issue
Дата
Msg-id 000401c5af03$6e850060$797ba8c0@jfradkin
обсуждение исходный текст
Ответ на Re: figuring out why I am having this issue  ("Dave Page" <dpage@vale-housing.co.uk>)
Список pgsql-odbc
I would like to look at this code, but searching the source I am not even
seeing it?

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);

Maybe I am too out of touch with C to be any help, but I should at a minimum
be able to see the code you are referenceing?

Joel Fradkin



-----Original Message-----
From: Dave Page [mailto:dpage@vale-housing.co.uk]
Sent: Thursday, September 01, 2005 10:06 AM
To: Joel Fradkin
Cc: pgsql-odbc@postgresql.org
Subject: RE: [ODBC] figuring out why I am having this issue



> -----Original Message-----
> From: Joel Fradkin [mailto:jfradkin@wazagua.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


В списке pgsql-odbc по дате отправления:

Предыдущее
От: "Dave Page"
Дата:
Сообщение: Re: figuring out why I am having this issue
Следующее
От: "Dave Page"
Дата:
Сообщение: Re: figuring out why I am having this issue