Javier Mosqueda
07-02-2005, 01:07 AM
Hi again:
I have SuSE Linux 9.2 runing MySQL 4.0.21. and I've been working with MySQL for 2 years with no problems...until today. The case is one in which my perl script reads the query string and according to it, the script performs different tasks.
Task 1 deletes all records in a table and reads a textfile with tab separated records. Newlines are erased, every line is split to fill an array and an insert operation is perfmed on the table for every line in the textfile. That works in part, because the table is erased, loaded with the data in the textfile but there is a PRINT after every "insert" to the table that is not received by the browser WHILE the script runs in FQ, but it works as expected while the script runs in my SuSE.
Task 2 simply "selects all records" from the table and displays them in the browser. This works correct in FQ and my SuSE.
I tried 2 methods of inserting, one connecting and disconnecting to the mysql server for every record inserted. Other method is connect first, insert 334 records and disconnect, but both methods work almost the same, cause with first method I can telnet+mysql and select, I see all the timestamps of every records changed quite quickly (5 seconds or less). 334 records are erased and inserted inserted including one with empty key. After a delay of about 2 minutes, the record with empty key is removed and then the script finishes, but without printing those messages to the browser. Method b doesn't let me see (via telnet) more than few records until connection is over, then I see the 333 records. What I do see are the first and last timestamps:
20050701233604 and
20050701233806, or 0.36 seconds per insert, which I don't see it so bad, the weird thing again is the lack of printout.
The file processed is quite small, less than 70 KB when mysqldump-ed from the table with all the 334 records.
Following is that faulty Task 1
sqlhfastup/down is to connect/disconnect to/from the mysqlserver
sqlhfastrun performs do() with mysql statements.
if ($FORM{'rmp'} == 1) {
&sqlhfastup;
open MIARCHIVO, "$www/tablas/calcmat.csv";
@camporder=("clave","descripcion","grupo","especie","material","marca","um","moneda","precio","margenintegra", "preciosjr","precioalzado","notas","paridad","ppesos");
&sqlhfastrun("delete from calcmat");
while ($linix=<MIARCHIVO>) {
$linix =~ s/\n|\r//g;
undef @campix;
@campix=split /\t/, $linix;
$lx='';
for ($cc=0; $cc<=$#camporder; $cc++) {
if ($cc==0) {
print "<p class=\"forma\">$campix[$cc]</p>";
}
$lx.="$camporder[$cc]=\"$campix[$cc]\",";
}
chop $lx;
&sqlhfastrun("insert into calcmat set $lx");
}
close MIARCHIVO;
&sqlhfastrun("delete from calcmat where clave=\"\"");
print "<p class=\"forma\"><br>Ok!</p>";
&sqlhfastdown;
}
Thanks
(this is the script c t l o b r a located at x m y i n f i n i t y g l a s s)
I have SuSE Linux 9.2 runing MySQL 4.0.21. and I've been working with MySQL for 2 years with no problems...until today. The case is one in which my perl script reads the query string and according to it, the script performs different tasks.
Task 1 deletes all records in a table and reads a textfile with tab separated records. Newlines are erased, every line is split to fill an array and an insert operation is perfmed on the table for every line in the textfile. That works in part, because the table is erased, loaded with the data in the textfile but there is a PRINT after every "insert" to the table that is not received by the browser WHILE the script runs in FQ, but it works as expected while the script runs in my SuSE.
Task 2 simply "selects all records" from the table and displays them in the browser. This works correct in FQ and my SuSE.
I tried 2 methods of inserting, one connecting and disconnecting to the mysql server for every record inserted. Other method is connect first, insert 334 records and disconnect, but both methods work almost the same, cause with first method I can telnet+mysql and select, I see all the timestamps of every records changed quite quickly (5 seconds or less). 334 records are erased and inserted inserted including one with empty key. After a delay of about 2 minutes, the record with empty key is removed and then the script finishes, but without printing those messages to the browser. Method b doesn't let me see (via telnet) more than few records until connection is over, then I see the 333 records. What I do see are the first and last timestamps:
20050701233604 and
20050701233806, or 0.36 seconds per insert, which I don't see it so bad, the weird thing again is the lack of printout.
The file processed is quite small, less than 70 KB when mysqldump-ed from the table with all the 334 records.
Following is that faulty Task 1
sqlhfastup/down is to connect/disconnect to/from the mysqlserver
sqlhfastrun performs do() with mysql statements.
if ($FORM{'rmp'} == 1) {
&sqlhfastup;
open MIARCHIVO, "$www/tablas/calcmat.csv";
@camporder=("clave","descripcion","grupo","especie","material","marca","um","moneda","precio","margenintegra", "preciosjr","precioalzado","notas","paridad","ppesos");
&sqlhfastrun("delete from calcmat");
while ($linix=<MIARCHIVO>) {
$linix =~ s/\n|\r//g;
undef @campix;
@campix=split /\t/, $linix;
$lx='';
for ($cc=0; $cc<=$#camporder; $cc++) {
if ($cc==0) {
print "<p class=\"forma\">$campix[$cc]</p>";
}
$lx.="$camporder[$cc]=\"$campix[$cc]\",";
}
chop $lx;
&sqlhfastrun("insert into calcmat set $lx");
}
close MIARCHIVO;
&sqlhfastrun("delete from calcmat where clave=\"\"");
print "<p class=\"forma\"><br>Ok!</p>";
&sqlhfastdown;
}
Thanks
(this is the script c t l o b r a located at x m y i n f i n i t y g l a s s)