Hi, Kenneth,

On Fri, 2002-03-08 at 08:48, Kenneth Hylton wrote:
> I've posted this twice before - third time might be the charmer...
> Can anybody help me?
> I am using the C API and am returning a result set from a table with a BLOB
> type item in it.
> When I populate the BLOB fields initially (with all the same data) the
> length is returned properly when I issue SELECT * FROM <table> and decode
> the result set column metadata.
> Meaning, that if I put , "This Blob's for you!" in the column, the value of
> MYSQL_FIELDS.length = 65535 (max of BLOB type) and MYSQL_FIELDS.max_length =
> 21.  
> When I update a few rows and put, "That's OK man, but you still can't have
> my BLOB!" in a few columns, the values for the length of the fields are
> returned funny, or at least, I don't understand why they are returning they
> way they are.
> Meaning the value of the new column length are all set to
> MYSQL_FIELDS.length = 65535 (again, max of BLOB type) and
> MYSQL_FIELDS.max_length = 49.  Problem is, this is even on the unchaged
> rows!  Yuk!
> A little experimentation showed that if I select on only unchanged rows, the
> length is returned as 21.  But, if the result set has one of the changed
> rows in it, the length of all blob fields is returned as 49, when (at least
> to me) it should be 21 or 49.
> In other words, it returns as the BLOB max_length value the value of the
> longest blob in the result set, NOT the max_length of each row.  I inserted
> (and updated) some records in the table with BLOB contents "It's all about
> the BLOB" and I see the same result.  It returns not the length of the BLOB
> for the row, but the length of the longest BLOB field in the result set.  

This is correct behaviour. If you wanted to print out the result in a
table layout, you'll want to know the max length of each column in the
result set. That's why the field is called MYSQL_FIELDS.max_length.

> We are running MySQL 3.23.46-Max on RedHat 7.2 Question:
> 1)    How do I get the actual length of the BLOB column in the row,
> without storing a separate column to maintain BLOB length manually?

mysql_field_lengths(), which you can call after mysql_fetch_row(), and
naturally the result will be unique for each row.

> 2)    If this is not a problem because there is some other way to tell
> where the BLOB buffer ends, please let me know.

See #1.


Regards,
Arjen.

-- 
MySQL Training in Brisbane: 18-22 March, http://www.mysql.com/training/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Arjen G. Lentz <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Technical Writer, Trainer
/_/  /_/\_, /___/\___\_\___/   Brisbane, QLD Australia
       <___/   www.mysql.com


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to