473,765 Members | 2,034 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 4688
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
2637
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
7397
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
2148
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
4689
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 only outputs up until the null character). Any ideas?
1
1999
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
3022
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 to save the NULL character /*!
2
1801
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 enter a null character in my input string while program is running. I know that a string in C is...
8
2452
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 for an array of 7 chars, with the contents {'M', 'E', 'H', 'M', 'E', 'T', '\0'}. "MEHMET" itself...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10163
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5276
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.