473,550 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysqldump, BLOBs, and the null character

I'll start off by saying I am using MySQL v4.0 and my question is...how
do I get mysqldump to dump the actual binary values store in a blob?
Here is an example:

-- Create a test table
create table dummy(col1 blob);
-- Next insert a null ascii character (0)
insert into dummy values (char(0));
-- To verify there is actually something there type:
select length(col1) from dummy;
-- You should see a value of "1" reprenting the null char
-- Now, dump the dummy table using mysqldump
mysqldump --tab=/tmp <db_name> dummy
-- Now look at the content of /tmp/dummy.txt and you will
-- see that the contents are a literal "/0" (no quotes of
-- course). If you do an octal dump:
od -c /tmp/dummy.txt
-- you get:

0000000 \ 0 \n
0000003

-- showing the literal \ and 0 (along with a newline)

If you use the "select into dumpfile" command you get the actual binary
value. For example if you type:

select col1
into dumpfile '/tmp/dummy.dat'
from dummy;

and then do an octal dump on the resulting file (od -c /tmp/dummy.dat)
you get:

0000000 \0
0000001

Indicating a single byte/character that is the null character.

How do I get all of the binary data in my blob columns to dump using
mysqldump?
I should say that I seem to only see this problem with the NULL
character (ascii=0).

Thanks,
Greg

Aug 20 '05 #1
1 4671
Well, I figured out the answer to my own problem. It seems that
mysqldump escapes botht the null, tab, and newline characters when
dumping them to a file. If you want to get a pure dump with no escape
character (/) and the blob appearing in the dump file exactly as it is
stored then you must supply mysqldump the command line option:
--fields-escaped-by=""

That's it.
Greg

Gr************* @gmail.com wrote:
I'll start off by saying I am using MySQL v4.0 and my question is...how
do I get mysqldump to dump the actual binary values store in a blob?
Here is an example:

-- Create a test table
create table dummy(col1 blob);
-- Next insert a null ascii character (0)
insert into dummy values (char(0));
-- To verify there is actually something there type:
select length(col1) from dummy;
-- You should see a value of "1" reprenting the null char
-- Now, dump the dummy table using mysqldump
mysqldump --tab=/tmp <db_name> dummy
-- Now look at the content of /tmp/dummy.txt and you will
-- see that the contents are a literal "/0" (no quotes of
-- course). If you do an octal dump:
od -c /tmp/dummy.txt
-- you get:

0000000 \ 0 \n
0000003

-- showing the literal \ and 0 (along with a newline)

If you use the "select into dumpfile" command you get the actual binary
value. For example if you type:

select col1
into dumpfile '/tmp/dummy.dat'
from dummy;

and then do an octal dump on the resulting file (od -c /tmp/dummy.dat)
you get:

0000000 \0
0000001

Indicating a single byte/character that is the null character.

How do I get all of the binary data in my blob columns to dump using
mysqldump?
I should say that I seem to only see this problem with the NULL
character (ascii=0).

Thanks,
Greg


Aug 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2617
by: Erik Leunissen | last post by:
L.S. I've observed unexpected behaviour regarding the usage of the '#' flag in the conversion specification in the printf() family of functions. Did I detect a bug, or is there something wrong with my expectations regarding the effect of the following code: printf("NULL as hex: %#4.2x\n", '\0');
8
7373
by: lasek | last post by:
Hi all, a simple question, look at this code below: char acName="Claudio"; unsigned int uiLen; uiLen=strlen(acName); printf("Length of acName variable %u",uiLen); //uiLen >>>> 7
15
2121
by: ehabaziz2001 | last post by:
Hi, Till now I do not understand how the null character automatically added to the end of the string and it is not an element of the string array . All books said the null character (\0) added automatically to the end of the string. Let say char name="123456789" If entered the name in a loop;
3
4672
by: Danny Tuppeny | last post by:
Hi all, I'm trying to send a null character as a string delimiter through a TcpClient (code below). It's to connect to this poker bot room: http://games.cs.ualberta.ca/webgames/poker/bots.html My code is as below, but I never get a response. I'm assuming my transmission is ending at the null character (the debug statement certainly...
1
1987
by: asenthil | last post by:
Hai, i had tried to write a string which is fetched from a database into a file.... Here are my codings to write that fetched string into a text file... HANDLE hFile; DWORD wmWritten; hFile =CreateFile"D:\\test.text",GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
14
3005
by: mast2as | last post by:
Hi everyone, I am trying to implement some specs which specify that an array of parameter is passed to a function as a pointer to an array terminated by a NULL chatacter. That seemed fairly easy to implement. I had a special Malloc function that would allocated the number of needed bytes for the objects i needed to store + 1 additional byte...
2
1789
AmberJain
by: AmberJain | last post by:
Hello everyone, Right now I am learning C and I'm using a BORLAND TURBO C++ 3.0 compiler to compile my programs. Well I am facing a problem with one of my program which I got as my assignment. I simply want user to input a string and a character and then to search if the string contains the character. well the problem is that I was unable to...
8
2430
by: Gary | last post by:
When you declare an array of chars and store a string in it, where is the position of the null character \0? And what happens to the unused memory locations? #include <stdio.h> int main(void) { char gstring2 = "dudes"; gstring2 = 'a'; printf("%s \n", gstring2);
4
292
by: jameskuyper | last post by:
mkeles84 wrote: The other responses you've received have explained why 'name' needs to contain a Null-Terminated Character String (NTCS). However, it occurred to me that you might not be aware of why creating a NTCS is normally not very difficult. For instance, the second "MEHMET" in your program causes a piece of memory to be allocated...
0
7488
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7999
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5129
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3532
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3517
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1978
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1094
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.