BLOB v mySQL 3.22.xx

Honza Pazdziora adelton na informatics.muni.cz
Čtvrtek Srpen 17 09:54:35 CEST 2000


On Thu, Aug 17, 2000 at 08:17:48AM +0200, Zdeněk Mazanec wrote:
> 
> Spis bych radsi php. Nicmene ani letmym pohledem na perldoc mysql.pm
> jsem zadnou chytrost neobjevil. Snad jen ze v perlu by slo ten sileny

Ta chytrost spociva v bindovanych parametrech. Tedy v tom, ze se
o detaily quotovani a tak vubec nemusite starat.

> dlouhy eskejpovany string dobre pripradit. To ovsem asi resesi
> otazku, co si s dotazem dlouhym n mega pocne parser. Nejspis se
> vykoruje :-(

Ale ne, proc by to delal. Jediny problem je s max_allowed_packet, kdy
se Vam muze stat, ze tak dlouha data proste na ten server
neprenesete:

$ perl -MDBI -e '
	my $dbh = DBI->connect("dbi:mysql:test", undef, undef,
						{ RaiseError => 1});
	$dbh->do("create table b_ad_blob (data longblob)");
	$dbh->do("insert into b_ad_blob values (?)", {}, "0123456789" x 300000);
	my $length = $dbh->selectrow_array("select length(data) from b_ad_blob");
	print "Length is $length\n"
	'
Length is 3000000
$ perl -MDBI -e '
	my $dbh = DBI->connect("dbi:mysql:test", undef, undef,
						{ RaiseError => 1});
	$dbh->do("create table b_ad_blob (data longblob)");
	$dbh->do("insert into b_ad_blob values (?)", {}, "0123456789" x 500000);
	my $length = $dbh->selectrow_array("select length(data) from b_ad_blob");
	print "Length is $length\n"
	'
DBD::mysql::db do failed: MySQL server has gone away at -e line 1.

a v error logu je

000817  9:44:21  Aborted connection 7 to db: 'test' user: 'user' (Got a packet bigger than 'max_allowed_packet')


http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#BLOB
	The maximum size of a BLOB or TEXT object is determined by its type,
	but the largest value you can actually transmit between the client
	and server is determined by the amount of available memory and the
	size of the communications buffers. You can change the message
	buffer size, but you must do so on both the server and client ends.
	See section 12.2.3 Tuning server parameters. 

max_allowed_packet 
	The maximum size of one packet. The message buffer is initialized
	to net_buffer_length bytes, but can grow up to max_allowed_packet
	bytes when needed. This value by default is small, to catch big
	(possibly wrong) packets. You must increase this value if you are
	using big BLOB columns. It should be as big as the biggest BLOB you
	want to use. 

Ale samozrejme tenhle problem budete mit s jakymkoli interfacem
a ostrani se tak, ze spustite mysqld s

	-O max_allowed_packet=pozadovana_velikost

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton na fi.muni.cz | http://www.fi.muni.cz/~adelton/
 .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain, ...
------------------------------------------------------------------------


Další informace o konferenci Test