Hi,
In the C API, is there any way to execute a query, store all the
results, and somehow find the maximum realized width for each of the
fields before fetching each row?
Otherwise there is no way to efficiently retrieve string data. The
best you can do is either allocate a static buffer of 64K (max size
for a blob) or some smaller buffer that may not actually be able to
contain all the data.
In fact, all the mysql documentation examples, both on in the manual
and in the test/client_test.c file that comes with the source
distribution, seem to choose the latter approach, arbitrarily fixing
the max size of their strings to, say, 255 bytes, binding using that
as the buffer_length, and then fetch()ing. In my application I need to
ensure that I get all the data, so this is unacceptable.
I have tried using mysql_get_metadata() after
mysql_stmt_store_result(), but even then the max_length value for the
fields in question is always set to 0, not the maximum size of the
field for the returned results.
What I would love to do is somehow get the field width right before
fetching each row so that I can allocate the right-sized buffer for
it. Or, less ideally, tell mysql to allocate memory for me.
Does anyone know of a way to do this?
I am using MySQL version 4.1.1-alpha-standard on RedHat Linux 9,
installed from the RPMs (server, client, devel) on the mysql.com
website.
Thanks very much,
AJ