Bugfix: Don't use a ruby string outside of the stack, GC can snag out from under us.
(Thanks Michael!) FossilOrigin-Name: bbcafda1bc42bf6deb5ac30acf620b0a3e020154e7d82f0140d2118ca29961fb
This commit is contained in:
parent
e9b476a4d7
commit
fb6d4fba95
3 changed files with 8 additions and 20 deletions
1
.pryrc
1
.pryrc
|
|
@ -12,5 +12,4 @@ rescue Exception => e
|
||||||
end
|
end
|
||||||
|
|
||||||
db = MDBX::Database.open( 'tmp/testdb', max_collections: 50 )
|
db = MDBX::Database.open( 'tmp/testdb', max_collections: 50 )
|
||||||
#db = MDBX::Database.open( 'tmp/testdb', duplicate_keys: true )
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,14 @@ rmdbx_set_subdb( VALUE self, VALUE name )
|
||||||
if ( db->txn )
|
if ( db->txn )
|
||||||
rb_raise( rmdbx_eDatabaseError, "Unable to change collection: transaction open" );
|
rb_raise( rmdbx_eDatabaseError, "Unable to change collection: transaction open" );
|
||||||
|
|
||||||
db->subdb = NIL_P( name ) ? NULL : StringValueCStr( name );
|
xfree( db->subdb );
|
||||||
|
db->subdb = NULL;
|
||||||
|
|
||||||
|
if ( ! NIL_P(name) ) {
|
||||||
|
size_t len = RSTRING_LEN( name ) + 1;
|
||||||
|
db->subdb = malloc( len );
|
||||||
|
strlcpy( db->subdb, StringValuePtr(name), len );
|
||||||
|
}
|
||||||
|
|
||||||
/* Reset the db handle and issue a single transaction to reify
|
/* Reset the db handle and issue a single transaction to reify
|
||||||
the collection.
|
the collection.
|
||||||
|
|
@ -786,8 +793,6 @@ rmdbx_database_initialize( int argc, VALUE *argv, VALUE self )
|
||||||
db->settings.db_flags = db->settings.db_flags | MDBX_DB_ACCEDE;
|
db->settings.db_flags = db->settings.db_flags | MDBX_DB_ACCEDE;
|
||||||
db->settings.env_flags = db->settings.env_flags | MDBX_ACCEDE;
|
db->settings.env_flags = db->settings.env_flags | MDBX_ACCEDE;
|
||||||
}
|
}
|
||||||
/* opt = rb_hash_delete( opts, ID2SYM( rb_intern("duplicate_keys") ) ); */
|
|
||||||
/* if ( RTEST(opt) ) db->settings.db_flags = db->settings.db_flags | MDBX_DUPSORT; */
|
|
||||||
opt = rb_hash_delete( opts, ID2SYM( rb_intern("exclusive") ) );
|
opt = rb_hash_delete( opts, ID2SYM( rb_intern("exclusive") ) );
|
||||||
if ( RTEST(opt) ) db->settings.env_flags = db->settings.env_flags | MDBX_EXCLUSIVE;
|
if ( RTEST(opt) ) db->settings.env_flags = db->settings.env_flags | MDBX_EXCLUSIVE;
|
||||||
opt = rb_hash_delete( opts, ID2SYM( rb_intern("lifo_reclaim") ) );
|
opt = rb_hash_delete( opts, ID2SYM( rb_intern("lifo_reclaim") ) );
|
||||||
|
|
@ -815,12 +820,6 @@ rmdbx_database_initialize( int argc, VALUE *argv, VALUE self )
|
||||||
opt = rb_hash_delete( opts, ID2SYM( rb_intern("writemap") ) );
|
opt = rb_hash_delete( opts, ID2SYM( rb_intern("writemap") ) );
|
||||||
if ( RTEST(opt) ) db->settings.env_flags = db->settings.env_flags | MDBX_WRITEMAP;
|
if ( RTEST(opt) ) db->settings.env_flags = db->settings.env_flags | MDBX_WRITEMAP;
|
||||||
|
|
||||||
/* Bail early on incompatible options. FIXME: I don't think this is true. */
|
|
||||||
/* if ( db->settings.max_collections > 0 && */
|
|
||||||
/* rmdbx_flag_enabled( db->settings.db_flags, MDBX_DUPSORT ) ) { */
|
|
||||||
/* rb_raise( rb_eArgError, "Collections and multiple values per key are mutually exclusive options." ); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
if ( rb_hash_size_num(opts) > 0 ) {
|
if ( rb_hash_size_num(opts) > 0 ) {
|
||||||
rb_raise( rb_eArgError, "Unknown option(s): %"PRIsVALUE, opts );
|
rb_raise( rb_eArgError, "Unknown option(s): %"PRIsVALUE, opts );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,16 +173,6 @@ RSpec.describe( MDBX::Database ) do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# context 'duplicate keys' do
|
|
||||||
#
|
|
||||||
# let( :db ) { described_class.open( TEST_DATABASE.to_s, max_collections: 5, duplicate_keys: true ) }
|
|
||||||
#
|
|
||||||
# after( :each ) do
|
|
||||||
# db.close
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
context 'collections' do
|
context 'collections' do
|
||||||
|
|
||||||
let!( :db ) { described_class.open( TEST_DATABASE.to_s, max_collections: 5 ) }
|
let!( :db ) { described_class.open( TEST_DATABASE.to_s, max_collections: 5 ) }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue