mdbx 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a961296e49a7e0e0fee9afbe7d2b92144a23b6295d68c3fc10d2296d5421666
4
- data.tar.gz: 29fd9c1997cb4a6bd6d1f7ce99ccb8cb38651ddc78e34a1a93eb21d55a552505
3
+ metadata.gz: 7eb0c032fc0a9fd7c91e0db5f6bbd876921fac5e886de80651d7eaf6564e7629
4
+ data.tar.gz: 2820244c2ed1c1e6ed8efd6275fd62d4f62d5668f2a2d346056c70aef05b9dd1
5
5
  SHA512:
6
- metadata.gz: 8d04ccf57c5cf613e930339c770acaa28c368eba2345e9b1255e0d2584f2271b9d166bdda8f55f2e27dc360315b00c41c4af7e59829f21611946fa2824975cc7
7
- data.tar.gz: f6d39a0a124cd4bfbf189f439ae765c7aec0a99eb0bc7a8b2e4b7d29141faa99a294d50b4110e0d40ac13349b22b731b2df29f8b2b4a36eb199785c0dba22043
6
+ metadata.gz: 65b7dab9c906a5dc50965ed8561a2eb9965eadf724e38f13fafe67cce6791ab1fca2992463dc9b8459f5ef6c97cb326439944faa7bbe60dc8fb03d41e9cc1f6d
7
+ data.tar.gz: 89c8f70c38f150986b1b76052cc8870e5ab0705af73e59f5db9d20f91a6d201b47a6e2cd8c85a663dd0404a01fb46f10ccda38febfbfb53a19619badeda5889c
checksums.yaml.gz.sig CHANGED
Binary file
data/History.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Release History for MDBX
2
2
 
3
+ ---
4
+ ## v0.3.5 [2023-03-24] Mahlon E. Smith <mahlon@martini.nu>
5
+
6
+ Add support for libmdbx 0.12.x.
7
+
8
+
9
+ Bugfixes:
10
+
11
+ - Ensure transactions are closed if exceptions are raised.
12
+
13
+
14
+ ---
15
+ ## v0.3.4 [2022-12-21] Mahlon E. Smith <mahlon@martini.nu>
16
+
17
+ Bugfixes:
18
+
19
+ - Don't use mdbx_replace() when not using the original value(s)
20
+
21
+
3
22
  ---
4
23
  ## v0.3.3 [2021-10-22] Mahlon E. Smith <mahlon@martini.nu>
5
24
 
data/README.md CHANGED
@@ -2,41 +2,34 @@
2
2
  # Ruby::MDBX
3
3
 
4
4
  home
5
- : https://code.martini.nu/ruby-mdbx
6
-
7
- code
8
- : https://code.martini.nu/ruby-mdbx
5
+ : https://code.martini.nu/fossil/ruby-mdbx
9
6
 
10
7
  docs
11
8
  : https://martini.nu/docs/ruby-mdbx
12
9
 
13
- github
14
- : https://github.com/mahlon/ruby-mdbx
15
-
16
- gitlab
17
- : https://gitlab.com/mahlon/ruby-mdbx
18
-
19
- sourcehut:
20
- : https://hg.sr.ht/~mahlon/ruby-mdbx
10
+ github_mirror
11
+ : https://github.com/mahlonsmith/ruby-mdbx
21
12
 
22
13
 
23
14
  ## Description
24
15
 
25
16
  This is a Ruby (MRI) binding for the libmdbx database library.
26
17
 
18
+ [![Gem Version](https://badge.fury.io/rb/mdbx.svg)](https://badge.fury.io/rb/mdbx)
19
+
27
20
  libmdbx is an extremely fast, compact, powerful, embedded, transactional
28
21
  key-value database, with a permissive license. libmdbx has a specific set
29
22
  of properties and capabilities, focused on creating unique lightweight
30
23
  solutions.
31
24
 
32
25
  For more information about libmdbx (features, limitations, etc), see the
33
- [introduction](https://erthink.github.io/libmdbx/intro.html).
26
+ [introduction](https://libmdbx.dqdkfa.ru).
34
27
 
35
28
 
36
29
  ## Prerequisites
37
30
 
38
- * Ruby 2.6+
39
- * [libmdbx](https://github.com/erthink/libmdbx)
31
+ * Ruby 3.0+
32
+ * [libmdbx](https://gitflic.ru/project/erthink/libmdbx)
40
33
 
41
34
 
42
35
  ## Installation
@@ -339,12 +332,84 @@ Calling `statistics` on a database handle will provide a subset of
339
332
  information about the build environment, the database environment, and
340
333
  the currently connected clients.
341
334
 
335
+ ```bash
336
+ % ruby -rmdbx -rjson -e "puts JSON.generate( MDBX::Database.open( '/tmp/testdb' ).statistics )" | jq
337
+ ```
338
+
339
+ ```json
340
+ {
341
+ "build": {
342
+ "compiler": "FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)",
343
+ "flags": "-DNDEBUG=1 -std=gnu++2b -O2 -pipe -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes -fstack-protector-strong -fno-strict-aliasing -fstack-
344
+ protector-strong",
345
+ "options": {
346
+ "MDBX_DEBUG": 0,
347
+ "MDBX_WORDBITS": 64,
348
+ "BYTE_ORDER": "LITTLE_ENDIAN",
349
+ "MDBX_ENV_CHECKPID": "AUTO",
350
+ "MDBX_TXN_CHECKOWNER": "AUTO",
351
+ "MDBX_64BIT_ATOMIC": "AUTO",
352
+ "MDBX_64BIT_CAS": "AUTO",
353
+ "MDBX_TRUST_RTC": "AUTO",
354
+ "MDBX_ENABLE_REFUND": 1,
355
+ "MDBX_ENABLE_MADVISE": 1,
356
+ "_GNU_SOURCE": "NO",
357
+ "MDBX_LOCKING": "AUTO",
358
+ "MDBX_USE_OFDLOCKS": "AUTO",
359
+ "MDBX_CACHELINE_SIZE": 64,
360
+ "MDBX_CPU_WRITEBACK_INCOHERENT": 0,
361
+ "MDBX_MMAP_INCOHERENT_CPU_CACHE": 0,
362
+ "MDBX_MMAP_INCOHERENT_FILE_WRITE": 0,
363
+ "MDBX_UNALIGNED_OK": 0,
364
+ "MDBX_PNL_ASCENDING": 0
365
+ },
366
+ "target": "x86_64-unknown-freebsd13.1"
367
+ },
368
+ "system_memory": {
369
+ "pagesize": 4096,
370
+ "total_pages": 33522850,
371
+ "avail_pages": 4170509
372
+ },
373
+ "environment": {
374
+ "pagesize": 4096,
375
+ "branch_pages": 0,
376
+ "leaf_pages": 0,
377
+ "overflow_pages": 0,
378
+ "btree_depth": 0,
379
+ "entries": 0,
380
+ "last_txnid": 3,
381
+ "last_reader_txnid": 3,
382
+ "max_readers": 120,
383
+ "readers_in_use": 1,
384
+ "datafile": {
385
+ "size_current": 12288,
386
+ "pages": 3,
387
+ "type": "dynamic",
388
+ "size_lower": 12288,
389
+ "size_upper": 1048576,
390
+ "growth_step": 65536,
391
+ "shrink_threshold": 131072
392
+ }
393
+ },
394
+ "readers": [
395
+ {
396
+ "slot": 0,
397
+ "pid": 16731,
398
+ "thread": 34374492160,
399
+ "txnid": 0,
400
+ "lag": 0,
401
+ "bytes_used": 0,
402
+ "bytes_retired": 0
403
+ }
404
+ ]
405
+ }
406
+ ```
342
407
 
343
408
  ## Contributing
344
409
 
345
- You can check out the current development source with Mercurial via its
346
- [home repo](https://code.martini.nu/ruby-mdbx), or with Git at its
347
- [project mirror](https://gitlab.com/mahlon/ruby-mdbx).
410
+ You can check out the current development source with Fossil via its
411
+ [home repo](https://code.martini.nu/fossil/ruby-mdbx), or with Git at its
412
+ [project mirror](https://github.com/mahlonsmith/ruby-mdbx)
348
413
 
349
414
  After checking out the source, run:
350
415
 
@@ -355,6 +420,19 @@ This will install dependencies, and do any other necessary setup for
355
420
  development.
356
421
 
357
422
 
423
+ ## Reporting Issues
424
+
425
+ Tests are performed against the latest stable MRI Ruby, and I endeavor to test
426
+ against the latest stable libmdbx (as of this writing, the 0.12.x versioning),
427
+ on both x86 and ARM chipsets.
428
+
429
+ Things may work for you in other environments - I'm just not matrix testing
430
+ every possible permutation.
431
+
432
+ Bugs reported against tested environments take precedence over others. Please
433
+ report any issues [here](https://code.martini.nu/fossil/ruby-mdbx/tktnew).
434
+
435
+
358
436
  ## Authors
359
437
 
360
438
  - Mahlon E. Smith <mahlon@martini.nu>
@@ -362,7 +440,7 @@ development.
362
440
 
363
441
  ## License
364
442
 
365
- Copyright (c) 2020-2021 Mahlon E. Smith
443
+ Copyright (c) 2020-2023 Mahlon E. Smith
366
444
  All rights reserved.
367
445
 
368
446
  Redistribution and use in source and binary forms, with or without
@@ -101,16 +101,6 @@ rmdbx_closed_p( VALUE self )
101
101
  }
102
102
 
103
103
 
104
- /*
105
- * Check if a given +flag+ is enabled for flag +val+.
106
- */
107
- int
108
- rmdbx_flag_enabled( val, flag )
109
- {
110
- return ( val & flag ) == flag;
111
- }
112
-
113
-
114
104
  /*
115
105
  * Given a ruby string +key+ and a pointer to an MDBX_val, prepare the
116
106
  * key for usage within mdbx. All keys are explicitly converted to
@@ -178,6 +168,12 @@ rmdbx_open_env( VALUE self )
178
168
  rb_raise( rmdbx_eDatabaseError, "mdbx_env_open: (%d) %s", rc, mdbx_strerror(rc) );
179
169
  }
180
170
 
171
+ /* Force populate the db->dbi handle. Under 0.12.x, getting a
172
+ * 'permission denied' doing this for the first access with a RDONLY
173
+ * for some reason. */
174
+ rmdbx_open_txn( db, MDBX_TXN_READWRITE );
175
+ rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
176
+
181
177
  db->state.open = 1;
182
178
  return Qtrue;
183
179
  }
@@ -199,8 +195,10 @@ rmdbx_clear( VALUE self )
199
195
  rmdbx_open_txn( db, MDBX_TXN_READWRITE );
200
196
  int rc = mdbx_drop( db->txn, db->dbi, false );
201
197
 
202
- if ( rc != MDBX_SUCCESS )
198
+ if ( rc != MDBX_SUCCESS ) {
199
+ rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
203
200
  rb_raise( rmdbx_eDatabaseError, "mdbx_drop: (%d) %s", rc, mdbx_strerror(rc) );
201
+ }
204
202
 
205
203
  rmdbx_close_txn( db, RMDBX_TXN_COMMIT );
206
204
 
@@ -239,8 +237,10 @@ rmdbx_drop( VALUE self, VALUE name )
239
237
  rmdbx_open_txn( db, MDBX_TXN_READWRITE );
240
238
  int rc = mdbx_drop( db->txn, db->dbi, true );
241
239
 
242
- if ( rc != MDBX_SUCCESS )
240
+ if ( rc != MDBX_SUCCESS ) {
241
+ rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
243
242
  rb_raise( rmdbx_eDatabaseError, "mdbx_drop: (%d) %s", rc, mdbx_strerror(rc) );
243
+ }
244
244
 
245
245
  rmdbx_close_txn( db, RMDBX_TXN_COMMIT );
246
246
 
@@ -248,6 +248,12 @@ rmdbx_drop( VALUE self, VALUE name )
248
248
  db->subdb = NULL;
249
249
  rmdbx_close_dbi( db ); /* ensure next access is not in the defunct subdb */
250
250
 
251
+ /* Force populate the new db->dbi handle. Under 0.12.x, getting a
252
+ * 'permission denied' doing this for the first access with a RDONLY
253
+ * for some reason. */
254
+ rmdbx_open_txn( db, MDBX_TXN_READWRITE );
255
+ rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
256
+
251
257
  return self;
252
258
  }
253
259
 
@@ -371,10 +377,9 @@ rmdbx_put_val( VALUE self, VALUE key, VALUE val )
371
377
  rc = mdbx_del( db->txn, db->dbi, &ckey, NULL );
372
378
  }
373
379
  else {
374
- MDBX_val old;
375
380
  MDBX_val data;
376
381
  rmdbx_val_for( self, val, &data );
377
- rc = mdbx_replace( db->txn, db->dbi, &ckey, &data, &old, 0 );
382
+ rc = mdbx_put( db->txn, db->dbi, &ckey, &data, 0 );
378
383
  xfree( data.iov_base );
379
384
  }
380
385
 
@@ -841,7 +846,7 @@ rmdbx_stats( VALUE self )
841
846
  * db.clone => [copy of db]
842
847
  *
843
848
  * Copy the object (clone/dup). The returned copy is closed and needs
844
- * to be reopened before use. This function likely has limited use,
849
+ * to be reopened before use. This function likely has limited use,
845
850
  * considering you can't open two handles within the same process.
846
851
  */
847
852
  static VALUE rmdbx_init_copy( VALUE copy, VALUE orig )
@@ -868,9 +873,9 @@ static VALUE rmdbx_init_copy( VALUE copy, VALUE orig )
868
873
  * Initialization for the MDBX::Database class.
869
874
  */
870
875
  void
871
- rmdbx_init_database()
876
+ rmdbx_init_database( void )
872
877
  {
873
- rmdbx_cDatabase = rb_define_class_under( rmdbx_mMDBX, "Database", rb_cData );
878
+ rmdbx_cDatabase = rb_define_class_under( rmdbx_mMDBX, "Database", rb_cObject );
874
879
 
875
880
  #ifdef FOR_RDOC
876
881
  rmdbx_mMDBX = rb_define_module( "MDBX" );
@@ -3,6 +3,8 @@
3
3
 
4
4
  require 'mkmf'
5
5
 
6
+ $CFLAGS << ' -Wno-suggest-attribute=format'
7
+
6
8
  have_library( 'mdbx' ) or abort "No mdbx library!"
7
9
  have_header( 'mdbx.h' ) or abort "No mdbx.h header!"
8
10
 
@@ -58,13 +58,11 @@ rmdbx_log( const char *level, const char *fmt, va_dcl )
58
58
  }
59
59
 
60
60
 
61
-
62
-
63
61
  /*
64
62
  * MDBX initialization
65
63
  */
66
64
  void
67
- Init_mdbx_ext()
65
+ Init_mdbx_ext( void )
68
66
  {
69
67
  rmdbx_mMDBX = rb_define_module( "MDBX" );
70
68
 
data/lib/mdbx/database.rb CHANGED
@@ -85,7 +85,7 @@ class MDBX::Database
85
85
  ###
86
86
  ### [:no_threadlocal]
87
87
  ### Parallelize read-only transactions across threads. Writes are
88
- ### always thread local. (See MDBX documentatoin for details.)
88
+ ### always thread local. (See MDBX documentation for details.)
89
89
  ###
90
90
  ### [:readonly]
91
91
  ### Reject any write attempts while using this database handle.
@@ -364,7 +364,6 @@ class MDBX::Database
364
364
  protected
365
365
  #########
366
366
 
367
-
368
367
  ### Safely serialize a value, closing any open transaction and re-raising
369
368
  ### if necessary.
370
369
  ###
@@ -391,7 +390,6 @@ class MDBX::Database
391
390
  end
392
391
 
393
392
 
394
-
395
393
  ### Yield and return the block, opening a snapshot first if
396
394
  ### there isn't already a transaction in progress. Closes
397
395
  ### the snapshot if this method opened it.
data/lib/mdbx.rb CHANGED
@@ -13,7 +13,7 @@ module MDBX
13
13
  extend Loggability
14
14
 
15
15
  # The version of this gem.
16
- VERSION = '0.3.3'
16
+ VERSION = '0.3.5'
17
17
 
18
18
 
19
19
  log_as :mdbx
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdbx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mahlon E. Smith
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -34,7 +34,7 @@ cert_chain:
34
34
  49pOzX5KHZLTS9DKeaP/xcGPz6C8MiwQdYrZarr2SHRASX1zFa79rkItO8kE6RDr
35
35
  b6WDF79UvZ55ajtE00TiwqjQL/ZPEtbd
36
36
  -----END CERTIFICATE-----
37
- date: 2021-10-22 00:00:00.000000000 Z
37
+ date: 2024-03-24 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: loggability
@@ -98,34 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '0.15'
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: 0.15.1
101
+ version: '0.22'
105
102
  type: :development
106
103
  prerelease: false
107
104
  version_requirements: !ruby/object:Gem::Requirement
108
105
  requirements:
109
106
  - - "~>"
110
107
  - !ruby/object:Gem::Version
111
- version: '0.15'
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: 0.15.1
108
+ version: '0.22'
115
109
  - !ruby/object:Gem::Dependency
116
- name: rdoc-generator-fivefish
110
+ name: rdoc-generator-sixfish
117
111
  requirement: !ruby/object:Gem::Requirement
118
112
  requirements:
119
113
  - - "~>"
120
114
  - !ruby/object:Gem::Version
121
- version: '0.4'
115
+ version: '0.2'
122
116
  type: :development
123
117
  prerelease: false
124
118
  version_requirements: !ruby/object:Gem::Requirement
125
119
  requirements:
126
120
  - - "~>"
127
121
  - !ruby/object:Gem::Version
128
- version: '0.4'
122
+ version: '0.2'
129
123
  - !ruby/object:Gem::Dependency
130
124
  name: rspec
131
125
  requirement: !ruby/object:Gem::Requirement
@@ -206,15 +200,14 @@ files:
206
200
  - ext/mdbx_ext/stats.c
207
201
  - lib/mdbx.rb
208
202
  - lib/mdbx/database.rb
209
- homepage: https://code.martini.nu/ruby-mdbx
203
+ homepage: https://code.martini.nu/fossil/ruby-mdbx
210
204
  licenses:
211
205
  - BSD-3-Clause
212
206
  metadata:
213
- homepage_uri: https://code.martini.nu/ruby-mdbx
207
+ homepage_uri: https://code.martini.nu/fossil/ruby-mdbx
214
208
  documentation_uri: https://martini.nu/docs/ruby-mdbx
215
209
  changelog_uri: https://martini.nu/docs/ruby-mdbx/History_md.html
216
- source_uri: https://code.martini.nu/ruby-mdbx
217
- post_install_message:
210
+ post_install_message:
218
211
  rdoc_options: []
219
212
  require_paths:
220
213
  - lib
@@ -229,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
222
  - !ruby/object:Gem::Version
230
223
  version: '0'
231
224
  requirements: []
232
- rubygems_version: 3.1.4
233
- signing_key:
225
+ rubygems_version: 3.4.19
226
+ signing_key:
234
227
  specification_version: 4
235
228
  summary: A ruby binding to libmdbx, an improved version of the Lightning Memory Mapped
236
229
  Database.
metadata.gz.sig CHANGED
Binary file