Hi,
db_readdump.php failes on the follow tabledump:
--snip-- CREATE TABLE Global ( ID int(10) unsigned NOT NULL auto_increment, TSTAMP timestamp(14) NOT NULL, Keyname varchar(255) NOT NULL default '', Value mediumtext NOT NULL, Number int(10) unsigned NOT NULL default '0', PRIMARY KEY (ID), KEY Keyname (Keyname) ) TYPE=MyISAM COMMENT='global memory';
INSERT INTO Global VALUES (209,20010731131330,'Matrix','('dadada')',1); INSERT INTO Global VALUES (210,20010731131330,'Matrix','dadada',2); --snap--
mysql_die results:
Fehler in der Syntax bei '; INSERT INTO Global VALUES (210,20010731131330,'Matrix','dadad' in Zeile 1. ^ here is the problem.
if you remove the parenthesis in the second row, readdump has no problems.
The problem in split_sql_file is row 1480 which try to detect the last ')' char.
also you can see another problem here. db_readdump.php3 ignore the $lang variable ...
Regards,
-- Steve
(210,20010731131330,'Matrix','dadad' in Zeile 1. ^ here is the problem.
Not exactly. :) It's in fact there: (209,20010731131330,'Matrix','('dadada')',1); ^ because of that line of code in lib.inc.php3:
1480: if ($last_char == $in_string && $char == ')') { 1481: $in_string = FALSE; 1482: }
if you remove the parenthesis in the second row, readdump has no problems.
Yes, that's the question I was asking to pete kelly about split_sql().
Actually, there is another big bug in this function that is here since the very begining of phpMyAdmin. Try that kind of manual SQL insert and it won't work: insert into table values ('\');insert into table values ('\');
The thing is that you have to know if there is an odd number of backslashes before a quote to know if it is escaped or not. Previously, split_sql_file() only checked if there was a backslash before a quote. But that backslash could be escaped by another backslash. The new alorithm I coded should be ok in that matter.
I've already recoded the function and I just managed to commit my changes (curiously I had to try to connect to cvs.sf.net with ssh to create my home directory there and then be able to connect to cvs via ssh...)
The problem in split_sql_file is row 1480 which try to detect the last ')' char.
Exactly. And that's a quick hack (Pete didn't answer my question about it in my message "a bit of story about split_string()").
Benjamin
Hi
Re: **********************
1480: if ($last_char == $in_string && $char == ')') { 1481: $in_string = FALSE; 1482: } if you remove the parenthesis in the second row, readdump has no problems. Yes, that's the question I was asking to pete kelly about split_sql().
***********************
Yes I added that line and it was to fix an error involving round brackets.
To be completely honest there is no real fix to this and other smaller bugs using the current system and layout. The problem is that readdump.php is set-up to try and handle too many different types of queries. On one hand it has to be able to accept backups from files, on the other it has to be able to accept single or multiple, escaped and non-escaped queries.
Actually, there is another big bug in this function that is here since the very begining of phpMyAdmin. Try that kind of manual SQL insert and it won't work: insert into table values ('\');insert into table values ('\');
This problem can be fixed with some quite complex code, but is will make the code so slow it will be absolutely useless for database/table restoration.
The only solution I can think of is to split the database restore code from the normal queries text box and to limit the queries text box to just one query at a time. Also include a tick box to let the code know if the data is pre-escaped or not.
So the choice is to either live with the current small bugs or rethink and redesign the whole section.
I have included a small test table containing lots of different symbols, this was the test data used to verify the current system.
Pete Kelly
----- Original Message ----- From: "Benjamin Gandon" gandon@isia.cma.fr To: phpmyadmin-devel@lists.sourceforge.net Sent: Friday, August 03, 2001 2:06 AM Subject: Re: [Phpmyadmin-devel] split_sql_file produces sometimes wrong pieces
(210,20010731131330,'Matrix','dadad' in Zeile 1. ^ here is the problem.
Not exactly. :) It's in fact there: (209,20010731131330,'Matrix','('dadada')',1); ^ because of that line of code in lib.inc.php3:
1480: if ($last_char == $in_string && $char == ')') { 1481: $in_string = FALSE; 1482: }
if you remove the parenthesis in the second row, readdump has no problems.
Yes, that's the question I was asking to pete kelly about split_sql().
Actually, there is another big bug in this function that is here since the very begining of phpMyAdmin. Try that kind of manual SQL insert and it won't work: insert into table values ('\');insert into table values ('\');
The thing is that you have to know if there is an odd number of backslashes before a quote to know if it is escaped or not. Previously, split_sql_file() only checked if there was a backslash before a quote. But that backslash could be escaped by another backslash. The new alorithm I coded should be ok in that matter.
I've already recoded the function and I just managed to commit my changes (curiously I had to try to connect to cvs.sf.net with ssh to create my home directory there and then be able to connect to cvs via ssh...)
The problem in split_sql_file is row 1480 which try to detect the last ')' char.
Exactly. And that's a quick hack (Pete didn't answer my question about it in my message "a bit of story about split_string()").
Benjamin
Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Steve Alberty a écrit :
Hi,
db_readdump.php failes on the follow tabledump:
--snip-- CREATE TABLE Global ( ID int(10) unsigned NOT NULL auto_increment, TSTAMP timestamp(14) NOT NULL, Keyname varchar(255) NOT NULL default '', Value mediumtext NOT NULL, Number int(10) unsigned NOT NULL default '0', PRIMARY KEY (ID), KEY Keyname (Keyname) ) TYPE=MyISAM COMMENT='global memory';
INSERT INTO Global VALUES (209,20010731131330,'Matrix','('dadada')',1); INSERT INTO Global VALUES (210,20010731131330,'Matrix','dadada',2);
Steve,
I don't understand. I cut&paste your example in the current cvs version and I get correct results.
Then I dump the table and I get:
INSERT INTO Global (ID, TSTAMP, Keyname, Value, Number) VALUES (209,20010731131330,'Matrix','('dadada')',1); INSERT INTO Global (ID, TSTAMP, Keyname, Value, Number) VALUES (210,20010731131330,'Matrix','dadada',2);
Marc