lmdb 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -4
  3. data/Rakefile +48 -0
  4. data/ext/lmdb_ext/extconf.rb +27 -10
  5. data/ext/lmdb_ext/lmdb_ext.c +22 -8
  6. data/lib/lmdb/database.rb +2 -1
  7. data/lib/lmdb/version.rb +1 -1
  8. data/lmdb.gemspec +4 -1
  9. data/spec/lmdb_spec.rb +9 -0
  10. data/vendor/liblmdb/VERSION +1 -0
  11. data/vendor/{libraries/liblmdb → liblmdb}/lmdb.h +18 -63
  12. data/vendor/{libraries/liblmdb → liblmdb}/mdb.c +583 -1480
  13. data/vendor/{libraries/liblmdb → liblmdb}/midl.c +0 -62
  14. data/vendor/{libraries/liblmdb → liblmdb}/midl.h +4 -16
  15. metadata +7 -34
  16. data/CONTRIBUTORS +0 -8
  17. data/behaviour.org +0 -35
  18. data/ext/lmdb_ext/prototypes.sh +0 -4
  19. data/vendor/libraries/liblmdb/.gitignore +0 -24
  20. data/vendor/libraries/liblmdb/COPYRIGHT +0 -20
  21. data/vendor/libraries/liblmdb/Doxyfile +0 -1631
  22. data/vendor/libraries/liblmdb/LICENSE +0 -47
  23. data/vendor/libraries/liblmdb/Makefile +0 -118
  24. data/vendor/libraries/liblmdb/intro.doc +0 -192
  25. data/vendor/libraries/liblmdb/mdb_copy.1 +0 -61
  26. data/vendor/libraries/liblmdb/mdb_copy.c +0 -84
  27. data/vendor/libraries/liblmdb/mdb_drop.1 +0 -40
  28. data/vendor/libraries/liblmdb/mdb_drop.c +0 -135
  29. data/vendor/libraries/liblmdb/mdb_dump.1 +0 -81
  30. data/vendor/libraries/liblmdb/mdb_dump.c +0 -319
  31. data/vendor/libraries/liblmdb/mdb_load.1 +0 -84
  32. data/vendor/libraries/liblmdb/mdb_load.c +0 -492
  33. data/vendor/libraries/liblmdb/mdb_stat.1 +0 -70
  34. data/vendor/libraries/liblmdb/mdb_stat.c +0 -264
  35. data/vendor/libraries/liblmdb/mtest.c +0 -177
  36. data/vendor/libraries/liblmdb/mtest2.c +0 -124
  37. data/vendor/libraries/liblmdb/mtest3.c +0 -133
  38. data/vendor/libraries/liblmdb/mtest4.c +0 -168
  39. data/vendor/libraries/liblmdb/mtest5.c +0 -135
  40. data/vendor/libraries/liblmdb/mtest6.c +0 -141
  41. data/vendor/libraries/liblmdb/sample-bdb.txt +0 -73
  42. data/vendor/libraries/liblmdb/sample-mdb.txt +0 -62
  43. data/vendor/libraries/liblmdb/tooltag +0 -27
@@ -1,81 +0,0 @@
1
- .TH MDB_DUMP 1 "2017/07/31" "LMDB 0.9.70"
2
- .\" Copyright 2014-2021 Howard Chu, Symas Corp. All Rights Reserved.
3
- .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
4
- .SH NAME
5
- mdb_dump \- LMDB environment export tool
6
- .SH SYNOPSIS
7
- .B mdb_dump
8
- [\c
9
- .BR \-V ]
10
- [\c
11
- .BI \-f \ file\fR]
12
- [\c
13
- .BR \-l ]
14
- [\c
15
- .BR \-n ]
16
- [\c
17
- .BR \-v ]
18
- [\c
19
- .BR \-p ]
20
- [\c
21
- .BR \-a \ |
22
- .BI \-s \ subdb\fR]
23
- .BR \ envpath
24
- .SH DESCRIPTION
25
- The
26
- .B mdb_dump
27
- utility reads a database and writes its contents to the
28
- standard output using a portable flat-text format
29
- understood by the
30
- .BR mdb_load (1)
31
- utility.
32
- .SH OPTIONS
33
- .TP
34
- .BR \-V
35
- Write the library version number to the standard output, and exit.
36
- .TP
37
- .BR \-f \ file
38
- Write to the specified file instead of to the standard output.
39
- .TP
40
- .BR \-l
41
- List the databases stored in the environment. Just the
42
- names will be listed, no data will be output.
43
- .TP
44
- .BR \-n
45
- Dump an LMDB database which does not use subdirectories.
46
- .TP
47
- .BR \-v
48
- Use the previous environment state instead of the latest state.
49
- This may be useful if the latest state has been corrupted.
50
- .TP
51
- .BR \-p
52
- If characters in either the key or data items are printing characters (as
53
- defined by isprint(3)), output them directly. This option permits users to
54
- use standard text editors and tools to modify the contents of databases.
55
-
56
- Note: different systems may have different notions about what characters
57
- are considered printing characters, and databases dumped in this manner may
58
- be less portable to external systems.
59
- .TP
60
- .BR \-a
61
- Dump all of the subdatabases in the environment.
62
- .TP
63
- .BR \-s \ subdb
64
- Dump a specific subdatabase. If no database is specified, only the main database is dumped.
65
- .SH DIAGNOSTICS
66
- Exit status is zero if no errors occur.
67
- Errors result in a non-zero exit status and
68
- a diagnostic message being written to standard error.
69
-
70
- Dumping and reloading databases that use user-defined comparison functions
71
- will result in new databases that use the default comparison functions.
72
- \fBIn this case it is quite likely that the reloaded database will be
73
- damaged beyond repair permitting neither record storage nor retrieval.\fP
74
-
75
- The only available workaround is to modify the source for the
76
- .BR mdb_load (1)
77
- utility to load the database using the correct comparison functions.
78
- .SH "SEE ALSO"
79
- .BR mdb_load (1)
80
- .SH AUTHOR
81
- Howard Chu of Symas Corporation <http://www.symas.com>
@@ -1,319 +0,0 @@
1
- /* mdb_dump.c - memory-mapped database dump tool */
2
- /*
3
- * Copyright 2011-2021 Howard Chu, Symas Corp.
4
- * All rights reserved.
5
- *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted only as authorized by the OpenLDAP
8
- * Public License.
9
- *
10
- * A copy of this license is available in the file LICENSE in the
11
- * top-level directory of the distribution or, alternatively, at
12
- * <http://www.OpenLDAP.org/license.html>.
13
- */
14
- #include <stdio.h>
15
- #include <errno.h>
16
- #include <stdlib.h>
17
- #include <string.h>
18
- #include <ctype.h>
19
- #include <unistd.h>
20
- #include <signal.h>
21
- #include "lmdb.h"
22
-
23
- #define Yu MDB_PRIy(u)
24
-
25
- #define PRINT 1
26
- static int mode;
27
-
28
- typedef struct flagbit {
29
- int bit;
30
- char *name;
31
- } flagbit;
32
-
33
- flagbit dbflags[] = {
34
- { MDB_REVERSEKEY, "reversekey" },
35
- { MDB_DUPSORT, "dupsort" },
36
- { MDB_INTEGERKEY, "integerkey" },
37
- { MDB_DUPFIXED, "dupfixed" },
38
- { MDB_INTEGERDUP, "integerdup" },
39
- { MDB_REVERSEDUP, "reversedup" },
40
- { 0, NULL }
41
- };
42
-
43
- static volatile sig_atomic_t gotsig;
44
-
45
- static void dumpsig( int sig )
46
- {
47
- gotsig=1;
48
- }
49
-
50
- static const char hexc[] = "0123456789abcdef";
51
-
52
- static void hex(unsigned char c)
53
- {
54
- putchar(hexc[c >> 4]);
55
- putchar(hexc[c & 0xf]);
56
- }
57
-
58
- static void text(MDB_val *v)
59
- {
60
- unsigned char *c, *end;
61
-
62
- putchar(' ');
63
- c = v->mv_data;
64
- end = c + v->mv_size;
65
- while (c < end) {
66
- if (isprint(*c)) {
67
- if (*c == '\\')
68
- putchar('\\');
69
- putchar(*c);
70
- } else {
71
- putchar('\\');
72
- hex(*c);
73
- }
74
- c++;
75
- }
76
- putchar('\n');
77
- }
78
-
79
- static void byte(MDB_val *v)
80
- {
81
- unsigned char *c, *end;
82
-
83
- putchar(' ');
84
- c = v->mv_data;
85
- end = c + v->mv_size;
86
- while (c < end) {
87
- hex(*c++);
88
- }
89
- putchar('\n');
90
- }
91
-
92
- /* Dump in BDB-compatible format */
93
- static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
94
- {
95
- MDB_cursor *mc;
96
- MDB_stat ms;
97
- MDB_val key, data;
98
- MDB_envinfo info;
99
- unsigned int flags;
100
- int rc, i;
101
-
102
- rc = mdb_dbi_flags(txn, dbi, &flags);
103
- if (rc) return rc;
104
-
105
- rc = mdb_stat(txn, dbi, &ms);
106
- if (rc) return rc;
107
-
108
- rc = mdb_env_info(mdb_txn_env(txn), &info);
109
- if (rc) return rc;
110
-
111
- printf("VERSION=3\n");
112
- printf("format=%s\n", mode & PRINT ? "print" : "bytevalue");
113
- if (name)
114
- printf("database=%s\n", name);
115
- printf("type=btree\n");
116
- printf("mapsize=%"Yu"\n", info.me_mapsize);
117
- if (info.me_mapaddr)
118
- printf("mapaddr=%p\n", info.me_mapaddr);
119
- printf("maxreaders=%u\n", info.me_maxreaders);
120
-
121
- if (flags & MDB_DUPSORT)
122
- printf("duplicates=1\n");
123
-
124
- for (i=0; dbflags[i].bit; i++)
125
- if (flags & dbflags[i].bit)
126
- printf("%s=1\n", dbflags[i].name);
127
-
128
- printf("db_pagesize=%d\n", ms.ms_psize);
129
- printf("HEADER=END\n");
130
-
131
- rc = mdb_cursor_open(txn, dbi, &mc);
132
- if (rc) return rc;
133
-
134
- while ((rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT) == MDB_SUCCESS)) {
135
- if (gotsig) {
136
- rc = EINTR;
137
- break;
138
- }
139
- if (mode & PRINT) {
140
- text(&key);
141
- text(&data);
142
- } else {
143
- byte(&key);
144
- byte(&data);
145
- }
146
- }
147
- printf("DATA=END\n");
148
- if (rc == MDB_NOTFOUND)
149
- rc = MDB_SUCCESS;
150
-
151
- return rc;
152
- }
153
-
154
- static void usage(char *prog)
155
- {
156
- fprintf(stderr, "usage: %s [-V] [-f output] [-l] [-n] [-p] [-v] [-a|-s subdb] dbpath\n", prog);
157
- exit(EXIT_FAILURE);
158
- }
159
-
160
- int main(int argc, char *argv[])
161
- {
162
- int i, rc;
163
- MDB_env *env;
164
- MDB_txn *txn;
165
- MDB_dbi dbi;
166
- char *prog = argv[0];
167
- char *envname;
168
- char *subname = NULL;
169
- int alldbs = 0, envflags = 0, list = 0;
170
-
171
- if (argc < 2) {
172
- usage(prog);
173
- }
174
-
175
- /* -a: dump main DB and all subDBs
176
- * -s: dump only the named subDB
177
- * -n: use NOSUBDIR flag on env_open
178
- * -p: use printable characters
179
- * -f: write to file instead of stdout
180
- * -v: use previous snapshot
181
- * -V: print version and exit
182
- * (default) dump only the main DB
183
- */
184
- while ((i = getopt(argc, argv, "af:lnps:vV")) != EOF) {
185
- switch(i) {
186
- case 'V':
187
- printf("%s\n", MDB_VERSION_STRING);
188
- exit(0);
189
- break;
190
- case 'l':
191
- list = 1;
192
- /*FALLTHROUGH*/;
193
- case 'a':
194
- if (subname)
195
- usage(prog);
196
- alldbs++;
197
- break;
198
- case 'f':
199
- if (freopen(optarg, "w", stdout) == NULL) {
200
- fprintf(stderr, "%s: %s: reopen: %s\n",
201
- prog, optarg, strerror(errno));
202
- exit(EXIT_FAILURE);
203
- }
204
- break;
205
- case 'n':
206
- envflags |= MDB_NOSUBDIR;
207
- break;
208
- case 'v':
209
- envflags |= MDB_PREVSNAPSHOT;
210
- break;
211
- case 'p':
212
- mode |= PRINT;
213
- break;
214
- case 's':
215
- if (alldbs)
216
- usage(prog);
217
- subname = optarg;
218
- break;
219
- default:
220
- usage(prog);
221
- }
222
- }
223
-
224
- if (optind != argc - 1)
225
- usage(prog);
226
-
227
- #ifdef SIGPIPE
228
- signal(SIGPIPE, dumpsig);
229
- #endif
230
- #ifdef SIGHUP
231
- signal(SIGHUP, dumpsig);
232
- #endif
233
- signal(SIGINT, dumpsig);
234
- signal(SIGTERM, dumpsig);
235
-
236
- envname = argv[optind];
237
- rc = mdb_env_create(&env);
238
- if (rc) {
239
- fprintf(stderr, "mdb_env_create failed, error %d %s\n", rc, mdb_strerror(rc));
240
- return EXIT_FAILURE;
241
- }
242
-
243
- if (alldbs || subname) {
244
- mdb_env_set_maxdbs(env, 2);
245
- }
246
-
247
- rc = mdb_env_open(env, envname, envflags | MDB_RDONLY, 0664);
248
- if (rc) {
249
- fprintf(stderr, "mdb_env_open failed, error %d %s\n", rc, mdb_strerror(rc));
250
- goto env_close;
251
- }
252
-
253
- rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn);
254
- if (rc) {
255
- fprintf(stderr, "mdb_txn_begin failed, error %d %s\n", rc, mdb_strerror(rc));
256
- goto env_close;
257
- }
258
-
259
- rc = mdb_open(txn, subname, 0, &dbi);
260
- if (rc) {
261
- fprintf(stderr, "mdb_open failed, error %d %s\n", rc, mdb_strerror(rc));
262
- goto txn_abort;
263
- }
264
-
265
- if (alldbs) {
266
- MDB_cursor *cursor;
267
- MDB_val key;
268
- int count = 0;
269
-
270
- rc = mdb_cursor_open(txn, dbi, &cursor);
271
- if (rc) {
272
- fprintf(stderr, "mdb_cursor_open failed, error %d %s\n", rc, mdb_strerror(rc));
273
- goto txn_abort;
274
- }
275
- while ((rc = mdb_cursor_get(cursor, &key, NULL, MDB_NEXT_NODUP)) == 0) {
276
- char *str;
277
- MDB_dbi db2;
278
- if (memchr(key.mv_data, '\0', key.mv_size))
279
- continue;
280
- count++;
281
- str = malloc(key.mv_size+1);
282
- memcpy(str, key.mv_data, key.mv_size);
283
- str[key.mv_size] = '\0';
284
- rc = mdb_open(txn, str, 0, &db2);
285
- if (rc == MDB_SUCCESS) {
286
- if (list) {
287
- printf("%s\n", str);
288
- list++;
289
- } else {
290
- rc = dumpit(txn, db2, str);
291
- if (rc)
292
- break;
293
- }
294
- mdb_close(env, db2);
295
- }
296
- free(str);
297
- if (rc) continue;
298
- }
299
- mdb_cursor_close(cursor);
300
- if (!count) {
301
- fprintf(stderr, "%s: %s does not contain multiple databases\n", prog, envname);
302
- rc = MDB_NOTFOUND;
303
- } else if (rc == MDB_NOTFOUND) {
304
- rc = MDB_SUCCESS;
305
- }
306
- } else {
307
- rc = dumpit(txn, dbi, subname);
308
- }
309
- if (rc && rc != MDB_NOTFOUND)
310
- fprintf(stderr, "%s: %s: %s\n", prog, envname, mdb_strerror(rc));
311
-
312
- mdb_close(env, dbi);
313
- txn_abort:
314
- mdb_txn_abort(txn);
315
- env_close:
316
- mdb_env_close(env);
317
-
318
- return rc ? EXIT_FAILURE : EXIT_SUCCESS;
319
- }
@@ -1,84 +0,0 @@
1
- .TH MDB_LOAD 1 "2015/09/30" "LMDB 0.9.17"
2
- .\" Copyright 2014-2021 Howard Chu, Symas Corp. All Rights Reserved.
3
- .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
4
- .SH NAME
5
- mdb_load \- LMDB environment import tool
6
- .SH SYNOPSIS
7
- .B mdb_load
8
- [\c
9
- .BR \-V ]
10
- [\c
11
- .BI \-f \ file\fR]
12
- [\c
13
- .BR \-n ]
14
- [\c
15
- .BI \-s \ subdb\fR]
16
- [\c
17
- .BR \-N ]
18
- [\c
19
- .BR \-T ]
20
- .BR \ envpath
21
- .SH DESCRIPTION
22
- The
23
- .B mdb_load
24
- utility reads from the standard input and loads it into the
25
- LMDB environment
26
- .BR envpath .
27
-
28
- The input to
29
- .B mdb_load
30
- must be in the output format specified by the
31
- .BR mdb_dump (1)
32
- utility or as specified by the
33
- .B -T
34
- option below.
35
- .SH OPTIONS
36
- .TP
37
- .BR \-V
38
- Write the library version number to the standard output, and exit.
39
- .TP
40
- .BR \-a
41
- Append all records in the order they appear in the input. The input is assumed to already be
42
- in correctly sorted order and no sorting or checking for redundant values will be performed.
43
- This option must be used to reload data that was produced by running
44
- .B mdb_dump
45
- on a database that uses custom compare functions.
46
- .TP
47
- .BR \-f \ file
48
- Read from the specified file instead of from the standard input.
49
- .TP
50
- .BR \-n
51
- Load an LMDB database which does not use subdirectories.
52
- .TP
53
- .BR \-s \ subdb
54
- Load a specific subdatabase. If no database is specified, data is loaded into the main database.
55
- .TP
56
- .BR \-N
57
- Don't overwrite existing records when loading into an already existing database; just skip them.
58
- .TP
59
- .BR \-T
60
- Load data from simple text files. The input must be paired lines of text, where the first
61
- line of the pair is the key item, and the second line of the pair is its corresponding
62
- data item.
63
-
64
- A simple escape mechanism, where newline and backslash (\\) characters are special, is
65
- applied to the text input. Newline characters are interpreted as record separators.
66
- Backslash characters in the text will be interpreted in one of two ways: If the backslash
67
- character precedes another backslash character, the pair will be interpreted as a literal
68
- backslash. If the backslash character precedes any other character, the two characters
69
- following the backslash will be interpreted as a hexadecimal specification of a single
70
- character; for example, \\0a is a newline character in the ASCII character set.
71
-
72
- For this reason, any backslash or newline characters that naturally occur in the text
73
- input must be escaped to avoid misinterpretation by
74
- .BR mdb_load .
75
-
76
- .SH DIAGNOSTICS
77
- Exit status is zero if no errors occur.
78
- Errors result in a non-zero exit status and
79
- a diagnostic message being written to standard error.
80
-
81
- .SH "SEE ALSO"
82
- .BR mdb_dump (1)
83
- .SH AUTHOR
84
- Howard Chu of Symas Corporation <http://www.symas.com>