Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: max_allowed_packet

by gmax (Abbot)
on Jun 14, 2004 at 11:37 UTC ( #366505=note: print w/replies, xml ) Need Help??

in reply to max_allowed_packet

Here is a simple recipe to get the value of "max_allowed_packet".

my $dbh = DBI->connect('dbi:mysql:dbname', 'user', 'pwd') or die "$DBI::errstr\n"; my (undef, $max_allowed_packet) = $dbh->selectrow_array( qq{show variables LIKE ? }, undef, "max_allowed_packet" ) ; printf "max_allowed_packet => %.2f MB\n", $max_allowed_packet / (1024 +*1024);
Sample output:
max_allowed_packet => 3.00 MB

SHOW VARIABLES returns a 2-column dataset, with a label in the first column and a value in the second one. Thus you need to get the second column with the value you need.

Check DBI Recipes for more on idioms, and Handling huge BLOB fields with DBI and MySQL for a sample program that checks max_allowed_packet to do something practical.

 _  _ _  _  
(_|| | |(_|><

Replies are listed 'Best First'.
Re^2: max_allowed_packet
by js1 (Monk) on Jun 14, 2004 at 19:13 UTC

    Thanks gmax, that was very useful.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://366505]
erix mopes
[karlgoethebier]: Discipulus: Perhaps i should add some more of these idiots to my sig?
[karlgoethebier]: Discipulus: There are countries were people get imprisoned for things like this...
[1nickt]: Are there enough bytes for all the idiots you would need to include?
[choroba]: I find it more entertaining to have something clever there
[Discipulus]: ys Karl i know; there are also children who die in mines where precious metals for phones are taken

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-06-22 12:00 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.