Re: Biggest Query


Subject: Re: Biggest Query
From: Michael Fowler (michael@shoebox.net)
Date: Tue Jun 04 2002 - 10:45:18 AKDT


On Mon, Jun 03, 2002 at 10:29:08PM -0800, Grant Stockly wrote:
>
> The mysql_real_query() function is what the docs tell me to use for binary
> data.
>
> The function says that the number of bytes to be sent is "unsigned int
> length". How in the world do I put more than 64k of data into an INSERT
> INTO statement?
>
> The Mysql docs say that MEDIUM and LARGE BLOB can handle 16 and
> 2048MB....so HOW do I get the data in there? : )
>
> Anyone have any ideas?

I've never done this, and I've never dealt with the C API, so the below are
just suggestions and pointers.

One thing to worry about is the buffer length limit. You've probably
already dealt with this, seeing as you are able to insert data. But I
figured I should mention it. From section 8.4 of the documentation:

    The communication buffer must be large enough to contain a single SQL
    statement (for client-to-server traffic) and one row of returned data
    (for server-to-client traffic). Each thread's communication buffer is
    dynamically enlarged to handle any query or row up to the maximum limit.
    For example, if you have BLOB values that contain up to 16M of data, you
    must have a communication buffer limit of at least 16M (in both server
    and client). The client's default maximum is 16M, but the default
    maximum in the server is 1M. You can increase this by changing the value
    of the max_allowed_packet parameter when the server is started. See
    section 5.5.2 Tuning Server Parameters.

As to inserting the data directly, there is an example of how to form a
query in the documentation for mysql_real_escape_string(). That, coupled
with mysql_real_query(), should get you your Big String. The length
argument is an unsigned int, which gets you 4G of string with a 32-bit int.
Are you perhaps worried about portability? You could make that a
requirement in your configure or build process, that an int be 4 bytes or
more. I don't see any other mysql API functions for dealing with binary
data.

Let me know if any of that helped.

Michael

--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

--------- To unsubscribe, send email to <aklug-request@aklug.org> with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Tue Jun 04 2002 - 10:45:13 AKDT