blob: 56537d61402074ced39c5b550505c76399e2ddc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
local n = 1
local function test(res, ermsg)
if not res then error(ermsg)
else
print("ok",n)
n = n + 1
end
end
local lmdb=require'lmdb'
local env=lmdb.open("data")
test(env,"no env")
local txn = env:txn_begin(true)
test(txn, "no txn")
local db = txn:open()
test(db, "no db")
db["foo"]="bar"
db["the"]="of the"
test(db["foo"] == "bar","no eq 1")
test(txn:commit())
local txn2 = env:txn_begin()
test(txn2,"no txn2")
local db2 = txn2:open()
test(db2, "no db2")
test(db2["the"] == "of the", "no eq 2")
test(txn2:commit())
local ok,v = pcall(function() return db2["foo"] end)
test(not ok,"shouldn't be able to access db from closed txn")
print("ok, got msg",v)
print()
print("everything good!!!")
|