Backup/restore with encoded data
Posted by: Lars Annerstedt
Date: July 27, 2005 03:25AM

I have a backup of some encoded (ENCODE(str,key_str)) data. When I do restore some data becomes corrupt after decoding.

Step 1:
====
CREATE TABLE `test` (
`cardid` char(20) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Step 2:
====
Add ten records '0000000000000000', '1111111111111111', ... '9999999999999999' to table test.

Step 3:
====
Run UPDATE cardid set cardid=encode(cardid,'test') and You should have encoded data.

Step 4:
====
Do a backup
========================================================
-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version 4.1.13-nt-log


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;


--
-- Create schema test
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ test;
USE test;

--
-- Table structure for table `test`.`test`
--

DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`cardid` char(20) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `test`.`test`
--

/*!40000 ALTER TABLE `test` DISABLE KEYS */;
INSERT INTO `test` (`cardid`) VALUES
('é\'^°–v”ßmˆ›\"²'),
('~±•È\'\0áŸIúŒ\rµ$'),
(' Åâ¼Pt–vè=?jûyÂP'),
('Ý6i„¡B£<èY¿/¬…'),
('Í&~”¶R´,ÿI¨?»’'),
('‘Zz#Èëép¢õcæZÏ'),
('™Qr(Ààâx©þkíRÄ'),
('ì%\\µ”s–\rÝhŠ™\'°'),
('O‰¤ð8Ð:®qË&½5„'),
('å\"[¼“z‘Úa?ž.·');
/*!40000 ALTER TABLE `test` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

========================================================

Step 5:
====
Do restore
Expected data from SELECT DECODE(cardid,'test') FROM TEST should be
'0000000000000000'
'1111111111111111'
'2222222222222222'
'3333333333333333'
'4444444444444444'
'5555555555555555'
'6666666666666666'
'7777777777777777'
'8888888888888888'
'9999999999999999'

but instead I get
0000000000000000
1111111111111111
2222222222d)$íÇÂ
3333333333333333
4444444444444444
5555555555555555
6666666666666666
7777777777777777
8888888888888888
99999999999B?´.o

Don't know if it's a bug or what? Any suggestions?
Running W2K, Admin 1.1.0rc, QB 1.1.13 and 4.1.13

Options: ReplyQuote


Subject
Written By
Posted
Backup/restore with encoded data
July 27, 2005 03:25AM
July 29, 2005 12:56AM
July 29, 2005 02:40AM
July 29, 2005 05:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.