Hi !
mysql 5.0 is _really_ cool.
this bug should be reproducable:
( cat table.sql ; ./populate.pl ; ./perfect_game.pl 32 ) | mysql test
after that executing the same procedure with same parameter again,
the connection is lost:
----------------------------------------------------------------------
mysql> call self_and_up(10000);
+-------+
| id |
+-------+
| 10000 |
| 1999 |
| 399 |
| 79 |
| 15 |
| 2 |
+-------+
6 rows in set (0.20 sec)
Query OK, 0 rows affected (0.20 sec)
mysql> call self_and_up(10000);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
----------------------------------------------------------------------
use cut and paste:
======================================================================
table.sql
======================================================================
-- table.sql
drop table if exists node;
create table node ( id int unsigned not null,
rid int unsigned not null,
msg text not null,
primary key(id),
unique index(rid,id)
);
----------------------------------------------------------------------
======================================================================
populate.pl
======================================================================
#!/usr/bin/perl
# populate.pl - [EMAIL PROTECTED]
our $level = 0;
our $parent = 0;
our @nodes;
sub rec() {
for my $i (1..$lim) {
my $node = $parent*$lim+$i;
$nodes[$level] = $node;
print "insert into node (id, rid, msg) values ($node, $parent, \"".join("-", 0,
@nodes[0..$level])."\");\n";
{
local $parent = $node;
local $level = $level+1;
rec() if $level < $rec_depth;
}
}
}
sub populate_table(@) {
my %args = @_;
{
local $lim = $args{count} || 2;
local $rec_depth = $args{depth} || 2;
rec;
}
}
populate_table count => 5, depth => 6;
----------------------------------------------------------------------
======================================================================
perfect_game.pl
======================================================================
#!/usr/bin/perl
# perfect_game.pl - [EMAIL PROTECTED]
sub query_parents_union(@) {
my %a = @_;
my $level = $a{max_level} || 0;
my $proc = $a{proc} || "dummy";
my $s = "select ". join(",", map( { "n0.$_" } @{$a{fields}}));
my $o = "drop procedure if exists $proc;\n"
."delimiter |\n"
."create procedure $proc (IN v INT)\n"
."begin\n";
for(my $x = 0; $x <= $level; $x++) {
$o .= "\n($s\n\tfrom ".join(", ", map( { "$a{table} as n$_" } (
0..$x)))."\n\twhere ("
."\n\t\t("
.join(" and ", map( { "n$_.$a{id} = ".(($_ >= $x) ? "v" :
"n".($_+1).".$a{rid}") } (0..$x))).")"
."\n\t\t)\n)";
$o .="\nunion" if $x != $level;
}
$o
.";\n"
."end |\n"
."delimiter ;\n"
}
my $limit = $ARGV[0] || 0;
print query_parents_union(table => 'node', id => 'id', rid => 'rid', fields => [
'id' ], proc => "self_and_up", max_level => $limit);
----------------------------------------------------------------------
--
ciao -
Stefan
" aclocal - emit a warning if -ac kernel is used. "
Stefan Traby Linux/ia32 office: +49-721-3523165
Mathystr. 18-20 V/8 Linux/alpha cell: +XX-XXX-XXXXXXX
76133 Karlsruhe Linux/sparc http://graz03.kwc.at
Germany Linux/arm mailto:[EMAIL PROTECTED]
Europe Linux/mips mailto:[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]