From: Rob Kinyon Date: Sun, 27 Dec 2009 22:32:25 +0000 (-0500) Subject: Fixed problem with large keys over 65535 bytes. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2467cee7a6b37a43d7cdd5b8c9bad5352318f6c3;p=dbsrgits%2FDBM-Deep.git Fixed problem with large keys over 65535 bytes. --- diff --git a/etc/mysql_tables.sql b/etc/mysql_tables.sql index ab9674a..b6d8dc0 100644 --- a/etc/mysql_tables.sql +++ b/etc/mysql_tables.sql @@ -11,9 +11,9 @@ CREATE TABLE datas ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,ref_id BIGINT UNSIGNED NOT NULL ,data_type ENUM( 'S', 'R' ) DEFAULT 'S' - ,`key` TEXT NOT NULL - ,value TEXT - ,class TEXT + ,`key` LONGTEXT NOT NULL + ,value LONGTEXT + ,class LONGTEXT ,FOREIGN KEY (ref_id) REFERENCES refs (id) ON DELETE CASCADE ON UPDATE CASCADE ,UNIQUE INDEX (ref_id, `key` (900) ) diff --git a/lib/DBM/Deep/Engine/DBI.pm b/lib/DBM/Deep/Engine/DBI.pm index 30af59f..34b1ca2 100644 --- a/lib/DBM/Deep/Engine/DBI.pm +++ b/lib/DBM/Deep/Engine/DBI.pm @@ -238,10 +238,10 @@ sub write_value { # See whether or not we are storing ourselves to ourself. # Write the sector as data in this reference (keyed by $key) - my $value_sector = $self->load_sector( $tmpvar->_base_offset ); + my $value_sector = $self->load_sector( $tmpvar->_base_offset, 'refs' ); $sector->write_data({ key => $key, - key_md5 => $self->_apply_digest( $key ), +# key_md5 => $self->_apply_digest( $key ), value => $value_sector, }); $value_sector->increment_refcount; diff --git a/t/10_largekeys.t b/t/10_largekeys.t index 2fe5811..d8d9472 100644 --- a/t/10_largekeys.t +++ b/t/10_largekeys.t @@ -35,24 +35,27 @@ while ( my $dbm_maker = $dbm_factory->() ) { ok( ($test_key eq $key1) || ($test_key eq $key2) || - ($test_key eq $key3) + ($test_key eq $key3), + "First key found", ); $test_key = $db->next_key($test_key); ok( ($test_key eq $key1) || ($test_key eq $key2) || - ($test_key eq $key3) + ($test_key eq $key3), + "Second key found", ); $test_key = $db->next_key($test_key); ok( ($test_key eq $key1) || ($test_key eq $key2) || - ($test_key eq $key3) + ($test_key eq $key3), + "Third key found", ); $test_key = $db->next_key($test_key); - ok( !$test_key ); + ok( !$test_key, "No fourth key" ); } done_testing;