I have a model called Product with an attribute called file of
type :binary (DB BLOB). If I do product.save (where product is an
instance of my Product model), here is SQL statement that the mysql
adapter for Ruby will do:
PRODUCT COLUMNS(NAME, PRICE, FILE) VALUES(‘PROD1’,
All is hunky dory for as long as my BLOB is not too big. If the blob
is say 8MB (not that big actually),there is a problem:
The buffer used by the mysql server(max_allowed_packet) to hold the
commands must be at least 16MB (two bytes for hexadecimal
representation). This is an unecessarily huge number for holding SQL
Is there a way to tell ruby to use a host variable in the SQL
statement (i.e. VALUES(‘PROD1’, 4.56, :blobvar) instead of the literal
format in the example above. I cannot believe this problem has never
been seen before? Imagine if the BLOB data I need to store is 100MB?
Your help is much appreciated.