Here's something weird: text strings containing newlines seem to have a
backslash character added when the data is exported from the database.
(MySQL 3.23.37 on Solaris--yes we're upgrading to .54)
I entered the string "123\n456" (the "\n" is a newline, octal 012) into
a column defined as "text". It appears to be OK in the table:
mysql> select review from MsReviews where msid=55038 and
msreviewid=1;
+---------+
| review |
+---------+
| 123
456 |
+---------+
1 row in set (0.04 sec)
The data should contain only seven characters, which it does:
mysql> select length(review) from MsReviews where msid=55038 and
msreviewid=1;
+----------------+
| length(review) |
+----------------+
| 7 |
+----------------+
1 row in set (0.00 sec)
And MySQL recognizes the newline:
mysql> select ascii(substring(Review,4,1)) from MsReviews where
msid=55038 and
msreviewid=1;
+------------------------------+
| ascii(substring(Review,4,1)) |
+------------------------------+
| 10 |
+------------------------------+
1 row in set (0.01 sec)
However, when I read the data out to a file...
mysql> select review into outfile '/tmp/MS55038rev1.txt' from
MsReviews where
msid=55038 and msreviewid=1;
Query OK, 1 row affected (0.00 sec)
mysql> quit
Bye
The newline seems to have had a "\" (backslash, octal 134) inserted
before it:
mss (mrb)% more /tmp/MS55038rev1.txt
123\
456
And the file is now 9 bytes long instead of the expected 8 bytes:
mss (mrb)% wc -c /tmp/MS55038rev1.txt
9 /tmp/MS55038rev1.txt
The new character is the ASCII backslash "\":
mss (mrb)% od -c /tmp/MS55038rev1.txt
0000000 1 2 3 \ \n 4 5 6 \n
0000011
mss (mrb)% od -b /tmp/MS55038rev1.txt
0000000 061 062 063 134 012 064 065 066 012
0000011
Can anybody explain what is going on?
Michael R. Boudreau
Senior Electronic Publishing Developer
The University of Chicago Press
1427 E. 60th Street
Chicago, IL 60637
773-753-3298
---------------------------------------------------------------------
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
- Re: backslash before newline Michael Boudreau
- Re: backslash before newline Keith C. Ivey
- Re: backslash before newline Dan Nelson