Bug #55978 Improvement Mysql Date Manipulation Language
Submitted: 13 Aug 2010 18:54 Modified: 16 Oct 2010 9:57
Reporter: Vitaliy Kaplenko Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: DML Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[13 Aug 2010 18:54] Vitaliy Kaplenko
Description:
Now correct mysql syntax is:
INSERT INTO file_table (id,file) VALUES(NULL,LOAD_FILE("/file_on_server_machine"));

Required mysql syntax for mysql users is:
INSERT INTO FILE file_table (id,file) VALUES(NULL,LOAD_FILE("/file_on_client_machine"));

By this improvement mysql users can insert any files into a TEXT or BLOB fields of a table by an mysql instruction only.

How to repeat:
Now correct mysql syntax is:
INSERT INTO file_table (id,file) VALUES(NULL,LOAD_FILE("/file_on_server_machine"));

Required mysql syntax for mysql users is:
INSERT INTO FILE file_table (id,file) VALUES(NULL,LOAD_FILE("/file_on_client_machine"));

By this improvement mysql users can insert any files into a TEXT or BLOB fields of a table by an mysql instruction only.
[13 Aug 2010 19:07] Vitaliy Kaplenko
I'm sorry, must be:
INSERT INTO LOCAL file_table (id,file) VALUES(NULL,LOAD_FILE("/file_on_client_machine"));
[16 Aug 2010 6:57] Vitaliy Kaplenko
A better variant of syntax for inserting any files, on client side, into a TEXT or BLOB fields of a table by an MySQL instructions only is:

INSERT INTO file_table (id,file) VALUES(NULL,LOAD_FILE_LOCAL("/file_on_client_machine"));

Function LOAD_FILE_LOCAL() is not a part of MySQL now.
[16 Sep 2010 9:57] Susanne Ebrecht
I am not sure if this will be possible.

Did you think about localisation/globalisation already?
[16 Sep 2010 10:08] Susanne Ebrecht
What I mean here is:

For loading a file your client encoding should be 'binary'.
For char, varchar, text your client encoding should match to your environment (just to have an example let us say utf8).

What when you have a table where you want to insert e.g. images and usual text into the same row?

You need to set client encoding to environment encoding for the text so that the text will get stored correct.

Means you will use SET NAMES utf8.

The system now will think that your image also is utf8 encoded but it is binary encoded. Means system thinks its utf8 and will try to convert it to wrong binary values and you will get gibberish.
[16 Oct 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".