MDB_VL32: Switch to mdb_size_t formats PRIu64 & co

Drop macro Y=MDB_FMT_Y, add Yu/Yd=MDB_PRIy(). Replace
Y"d..." -> Yd"...", Y"u..." -> Yu"..." / MDB_SCNy(u)"...".
ntdll
Hallvard Furuseth 8 years ago
parent 65d9791ada
commit 4d47e89f4d
  1. 28
      libraries/liblmdb/lmdb.h
  2. 141
      libraries/liblmdb/mdb.c
  3. 4
      libraries/liblmdb/mdb_dump.c
  4. 31
      libraries/liblmdb/mdb_load.c
  5. 24
      libraries/liblmdb/mdb_stat.c

@ -186,31 +186,21 @@ typedef mode_t mdb_mode_t;
# define MDB_FMT_Z "z" /**< printf/scanf format modifier for size_t */
#endif
#if !defined(MDB_VL32) || SIZE_MAX > 0xffffffffU
#ifndef MDB_VL32
typedef size_t mdb_size_t;
# define MDB_SIZE_MAX SIZE_MAX /**< max #mdb_size_t */
# define MDB_FMT_Y MDB_FMT_Z /**< Obsolescent, see #MDB_PRIz()/#MDB_SCNz() */
/* TODO: For VL32, use uint64_t (trivial) and therefore PRI<c>64 (big patch) */
#elif defined(_WIN32)
typedef unsigned __int64 mdb_size_t;
# define MDB_SIZE_MAX _UI64_MAX
# define MDB_FMT_Y "I64"
#elif defined(ULLONG_MAX)
typedef unsigned long long mdb_size_t;
# define MDB_SIZE_MAX ULLONG_MAX
# define MDB_FMT_Y "ll"
/** #mdb_size_t printf formats, \b t = one of [diouxX] without quotes */
# define MDB_PRIy(t) MDB_FMT_Z #t
/** #mdb_size_t scanf formats, \b t = one of [dioux] without quotes */
# define MDB_SCNy(t) MDB_FMT_Z #t
#else
# error "Found no acceptable integer type for mdb_size_t"
#endif
#ifdef MDB_VL32
typedef uint64_t mdb_size_t;
# define MDB_SIZE_MAX UINT64_MAX
# define MDB_PRIy(t) PRI##t##64
# define MDB_SCNy(t) SCN##t##64
# define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */
#endif
/** #mdb_size_t printf formats, \b t = one of [diouxX] without quotes */
#define MDB_PRIz(t) MDB_FMT_Y #t
/** #mdb_size_t scanf formats, \b t = one of [dioux] without quotes */
#define MDB_SCNz(t) MDB_FMT_Y #t
/** An abstraction for a file handle.
* On POSIX systems file handles are small integers. On Windows
* they're opaque pointers.

@ -457,7 +457,8 @@ typedef pthread_mutex_t mdb_mutex_t[1], *mdb_mutexref_t;
#endif
#define Z MDB_FMT_Z /**< printf/scanf format modifier for size_t */
#define Y MDB_FMT_Y /**< printf/scanf format modifier for #mdb_size_t */
#define Yu MDB_PRIy(u) /**< printf format for #mdb_size_t */
#define Yd MDB_PRIy(d) /**< printf format for "signed #mdb_size_t" */
#if defined(_WIN32) || defined(MDB_USE_POSIX_SEM)
#define MNAME_LEN 32
@ -1711,20 +1712,20 @@ mdb_page_list(MDB_page *mp)
case P_LEAF|P_LEAF2: type = "LEAF2 page"; break;
case P_LEAF|P_LEAF2|P_SUBP: type = "LEAF2 sub-page"; break;
case P_OVERFLOW:
fprintf(stderr, "Overflow page %"Y"u pages %u%s\n",
fprintf(stderr, "Overflow page %"Yu" pages %u%s\n",
pgno, mp->mp_pages, state);
return;
case P_META:
fprintf(stderr, "Meta-page %"Y"u txnid %"Y"u\n",
fprintf(stderr, "Meta-page %"Yu" txnid %"Yu"\n",
pgno, ((MDB_meta *)METADATA(mp))->mm_txnid);
return;
default:
fprintf(stderr, "Bad page %"Y"u flags 0x%u\n", pgno, mp->mp_flags);
fprintf(stderr, "Bad page %"Yu" flags 0x%u\n", pgno, mp->mp_flags);
return;
}
nkeys = NUMKEYS(mp);
fprintf(stderr, "%s %"Y"u numkeys %d%s\n", type, pgno, nkeys, state);
fprintf(stderr, "%s %"Yu" numkeys %d%s\n", type, pgno, nkeys, state);
for (i=0; i<nkeys; i++) {
if (IS_LEAF2(mp)) { /* LEAF2 pages have no mp_ptrs[] or node headers */
@ -1739,7 +1740,7 @@ mdb_page_list(MDB_page *mp)
key.mv_data = node->mn_data;
nsize = NODESIZE + key.mv_size;
if (IS_BRANCH(mp)) {
fprintf(stderr, "key %d: page %"Y"u, %s\n", i, NODEPGNO(node),
fprintf(stderr, "key %d: page %"Yu", %s\n", i, NODEPGNO(node),
DKEY(&key));
total += nsize;
} else {
@ -1835,7 +1836,7 @@ static void mdb_audit(MDB_txn *txn)
}
}
if (freecount + count + NUM_METAS != txn->mt_next_pgno) {
fprintf(stderr, "audit: %"Y"u freecount: %"Y"u count: %"Y"u total: %"Y"u next_pgno: %"Y"u\n",
fprintf(stderr, "audit: %"Yu" freecount: %"Yu" count: %"Yu" total: %"Yu" next_pgno: %"Yu"\n",
txn->mt_txnid, freecount, count+NUM_METAS,
freecount+count+NUM_METAS, txn->mt_next_pgno);
}
@ -2019,8 +2020,7 @@ mdb_page_loose(MDB_cursor *mc, MDB_page *mp)
}
}
if (loose) {
DPRINTF(("loosen db %d page %"Y"u", DDBI(mc),
mp->mp_pgno));
DPRINTF(("loosen db %d page %"Yu, DDBI(mc), mp->mp_pgno));
NEXT_LOOSE_PAGE(mp) = txn->mt_loose_pgs;
txn->mt_loose_pgs = mp;
txn->mt_loose_count++;
@ -2317,8 +2317,7 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp)
np = txn->mt_loose_pgs;
txn->mt_loose_pgs = NEXT_LOOSE_PAGE(np);
txn->mt_loose_count--;
DPRINTF(("db %d use loose page %"Y"u", DDBI(mc),
np->mp_pgno));
DPRINTF(("db %d use loose page %"Yu, DDBI(mc), np->mp_pgno));
*mp = np;
return MDB_SUCCESS;
}
@ -2420,10 +2419,10 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp)
}
env->me_pglast = last;
#if (MDB_DEBUG) > 1
DPRINTF(("IDL read txn %"Y"u root %"Y"u num %u",
DPRINTF(("IDL read txn %"Yu" root %"Yu" num %u",
last, txn->mt_dbs[FREE_DBI].md_root, i));
for (j = i; j; j--)
DPRINTF(("IDL %"Y"u", idl[j]));
DPRINTF(("IDL %"Yu, idl[j]));
#endif
/* Merge in descending sorted order */
mdb_midl_xmerge(mop, idl);
@ -2593,7 +2592,7 @@ mdb_page_touch(MDB_cursor *mc)
(rc = mdb_page_alloc(mc, 1, &np)))
goto fail;
pgno = np->mp_pgno;
DPRINTF(("touched db %d page %"Y"u -> %"Y"u", DDBI(mc),
DPRINTF(("touched db %d page %"Yu" -> %"Yu, DDBI(mc),
mp->mp_pgno, pgno));
mdb_cassert(mc, mp->mp_pgno != pgno);
mdb_midl_xappend(txn->mt_free_pgs, mp->mp_pgno);
@ -2994,7 +2993,7 @@ mdb_txn_renew(MDB_txn *txn)
rc = mdb_txn_renew0(txn);
if (rc == MDB_SUCCESS) {
DPRINTF(("renew txn %"Y"u%c %p on mdbenv %p, root page %"Y"u",
DPRINTF(("renew txn %"Yu"%c %p on mdbenv %p, root page %"Yu,
txn->mt_txnid, (txn->mt_flags & MDB_TXN_RDONLY) ? 'r' : 'w',
(void *)txn, (void *)txn->mt_env, txn->mt_dbs[MAIN_DBI].md_root));
}
@ -3112,7 +3111,7 @@ renew:
} else {
txn->mt_flags |= flags; /* could not change txn=me_txn0 earlier */
*ret = txn;
DPRINTF(("begin txn %"Y"u%c %p on mdbenv %p, root page %"Y"u",
DPRINTF(("begin txn %"Yu"%c %p on mdbenv %p, root page %"Yu,
txn->mt_txnid, (flags & MDB_RDONLY) ? 'r' : 'w',
(void *) txn, (void *) env, txn->mt_dbs[MAIN_DBI].md_root));
}
@ -3179,7 +3178,7 @@ mdb_txn_end(MDB_txn *txn, unsigned mode)
/* Export or close DBI handles opened in this txn */
mdb_dbis_update(txn, mode & MDB_END_UPDATE);
DPRINTF(("%s txn %"Y"u%c %p on mdbenv %p, root page %"Y"u",
DPRINTF(("%s txn %"Yu"%c %p on mdbenv %p, root page %"Yu,
names[mode & MDB_END_OPMASK],
txn->mt_txnid, (txn->mt_flags & MDB_TXN_RDONLY) ? 'r' : 'w',
(void *) txn, (void *)env, txn->mt_dbs[MAIN_DBI].md_root));
@ -3380,10 +3379,10 @@ mdb_freelist_save(MDB_txn *txn)
#if (MDB_DEBUG) > 1
{
unsigned int i = free_pgs[0];
DPRINTF(("IDL write txn %"Y"u root %"Y"u num %u",
DPRINTF(("IDL write txn %"Yu" root %"Yu" num %u",
txn->mt_txnid, txn->mt_dbs[FREE_DBI].md_root, i));
for (; i; i--)
DPRINTF(("IDL %"Y"u", free_pgs[i]));
DPRINTF(("IDL %"Yu, free_pgs[i]));
}
#endif
continue;
@ -3551,7 +3550,7 @@ mdb_page_flush(MDB_txn *txn, int keep)
* the write offset, to at least save the overhead of a Seek
* system call.
*/
DPRINTF(("committing page %"Y"u", pgno));
DPRINTF(("committing page %"Yu, pgno));
memset(&ov, 0, sizeof(ov));
ov.Offset = pos & 0xffffffff;
ov.OffsetHigh = pos >> 16 >> 16;
@ -3602,7 +3601,7 @@ retry_seek:
wpos = pos;
wsize = 0;
}
DPRINTF(("committing page %"Y"u", pgno));
DPRINTF(("committing page %"Yu, pgno));
next_pos = pos + size;
iov[n].iov_len = size;
iov[n].iov_base = (char *)dp;
@ -3815,7 +3814,7 @@ mdb_txn_commit(MDB_txn *txn)
!(txn->mt_flags & (MDB_TXN_DIRTY|MDB_TXN_SPILLS)))
goto done;
DPRINTF(("committing txn %"Y"u %p on mdbenv %p, root page %"Y"u",
DPRINTF(("committing txn %"Yu" %p on mdbenv %p, root page %"Yu,
txn->mt_txnid, (void*)txn, (void*)env, txn->mt_dbs[MAIN_DBI].md_root));
/* Update DB root pointers */
@ -3913,7 +3912,7 @@ mdb_env_read_header(MDB_env *env, MDB_meta *meta)
p = (MDB_page *)&pbuf;
if (!F_ISSET(p->mp_flags, P_META)) {
DPRINTF(("page %"Y"u not a meta page", p->mp_pgno));
DPRINTF(("page %"Yu" not a meta page", p->mp_pgno));
return MDB_INVALID;
}
@ -4025,7 +4024,7 @@ mdb_env_write_meta(MDB_txn *txn)
#endif
toggle = txn->mt_txnid & 1;
DPRINTF(("writing meta page %d for root page %"Y"u",
DPRINTF(("writing meta page %d for root page %"Yu,
toggle, txn->mt_dbs[MAIN_DBI].md_root));
env = txn->mt_env;
@ -4519,13 +4518,13 @@ mdb_env_open2(MDB_env *env)
DPRINTF(("opened database version %u, pagesize %u",
meta->mm_version, env->me_psize));
DPRINTF(("using meta page %d", (int) (meta->mm_txnid & 1)));
DPRINTF(("depth: %u", db->md_depth));
DPRINTF(("entries: %"Y"u", db->md_entries));
DPRINTF(("branch pages: %"Y"u", db->md_branch_pages));
DPRINTF(("leaf pages: %"Y"u", db->md_leaf_pages));
DPRINTF(("overflow pages: %"Y"u", db->md_overflow_pages));
DPRINTF(("root: %"Y"u", db->md_root));
DPRINTF(("using meta page %d", (int) (meta->mm_txnid & 1)));
DPRINTF(("depth: %u", db->md_depth));
DPRINTF(("entries: %"Yu, db->md_entries));
DPRINTF(("branch pages: %"Yu, db->md_branch_pages));
DPRINTF(("leaf pages: %"Yu, db->md_leaf_pages));
DPRINTF(("overflow pages: %"Yu, db->md_overflow_pages));
DPRINTF(("root: %"Yu, db->md_root));
}
#endif
@ -5531,7 +5530,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int *exactp)
nkeys = NUMKEYS(mp);
DPRINTF(("searching %u keys in %s %spage %"Y"u",
DPRINTF(("searching %u keys in %s %spage %"Yu,
nkeys, IS_LEAF(mp) ? "leaf" : "branch", IS_SUBP(mp) ? "sub-" : "",
mdb_dbg_pgno(mp)));
@ -5579,7 +5578,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int *exactp)
DPRINTF(("found leaf index %u [%s], rc = %i",
i, DKEY(&nodekey), rc));
else
DPRINTF(("found branch index %u [%s -> %"Y"u], rc = %i",
DPRINTF(("found branch index %u [%s -> %"Yu"], rc = %i",
i, DKEY(&nodekey), NODEPGNO(node), rc));
#endif
if (rc == 0)
@ -5627,7 +5626,7 @@ static void
mdb_cursor_pop(MDB_cursor *mc)
{
if (mc->mc_snum) {
DPRINTF(("popping page %"Y"u off db %d cursor %p",
DPRINTF(("popping page %"Yu" off db %d cursor %p",
mc->mc_pg[mc->mc_top]->mp_pgno, DDBI(mc), (void *) mc));
mc->mc_snum--;
@ -5643,7 +5642,7 @@ mdb_cursor_pop(MDB_cursor *mc)
static int
mdb_cursor_push(MDB_cursor *mc, MDB_page *mp)
{
DPRINTF(("pushing page %"Y"u on db %d cursor %p", mp->mp_pgno,
DPRINTF(("pushing page %"Yu" on db %d cursor %p", mp->mp_pgno,
DDBI(mc), (void *) mc));
if (mc->mc_snum >= CURSOR_STACK) {
@ -5990,7 +5989,7 @@ mdb_page_get(MDB_cursor *mc, pgno_t pgno, MDB_page **ret, int *lvl)
}
if (pgno >= txn->mt_next_pgno) {
DPRINTF(("page %"Y"u not found", pgno));
DPRINTF(("page %"Yu" not found", pgno));
txn->mt_flags |= MDB_TXN_ERROR;
return MDB_PAGE_NOTFOUND;
}
@ -6030,13 +6029,13 @@ mdb_page_search_root(MDB_cursor *mc, MDB_val *key, int flags)
MDB_node *node;
indx_t i;
DPRINTF(("branch page %"Y"u has %u keys", mp->mp_pgno, NUMKEYS(mp)));
DPRINTF(("branch page %"Yu" has %u keys", mp->mp_pgno, NUMKEYS(mp)));
/* Don't assert on branch pages in the FreeDB. We can get here
* while in the process of rebalancing a FreeDB branch page; we must
* let that proceed. ITS#8336
*/
mdb_cassert(mc, !mc->mc_dbi || NUMKEYS(mp) > 1);
DPRINTF(("found index 0 to page %"Y"u", NODEPGNO(NODEPTR(mp, 0))));
DPRINTF(("found index 0 to page %"Yu, NODEPGNO(NODEPTR(mp, 0))));
if (flags & (MDB_PS_FIRST|MDB_PS_LAST)) {
i = 0;
@ -6081,7 +6080,7 @@ mdb_page_search_root(MDB_cursor *mc, MDB_val *key, int flags)
return MDB_CORRUPTED;
}
DPRINTF(("found leaf page %"Y"u for key [%s]", mp->mp_pgno,
DPRINTF(("found leaf page %"Yu" for key [%s]", mp->mp_pgno,
key ? DKEY(key) : "null"));
mc->mc_flags |= C_INITIALIZED;
mc->mc_flags &= ~C_EOF;
@ -6196,7 +6195,7 @@ mdb_page_search(MDB_cursor *mc, MDB_val *key, int flags)
mc->mc_snum = 1;
mc->mc_top = 0;
DPRINTF(("db %d root page %"Y"u has flags 0x%X",
DPRINTF(("db %d root page %"Yu" has flags 0x%X",
DDBI(mc), root, mc->mc_pg[0]->mp_flags));
if (flags & MDB_PS_MODIFY) {
@ -6221,7 +6220,7 @@ mdb_ovpage_free(MDB_cursor *mc, MDB_page *mp)
MDB_ID pn = pg << 1;
int rc;
DPRINTF(("free ov page %"Y"u (%d)", pg, ovpages));
DPRINTF(("free ov page %"Yu" (%d)", pg, ovpages));
/* If the page is dirty or on the spill list we just acquired it,
* so we should give it back to our current free list, if any.
* Otherwise put it onto the list of pages we freed in this txn.
@ -6314,7 +6313,7 @@ mdb_node_read(MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
data->mv_size = NODEDSZ(leaf);
memcpy(&pgno, NODEDATA(leaf), sizeof(pgno));
if ((rc = mdb_page_get(mc, pgno, &omp, NULL)) != 0) {
DPRINTF(("read overflow page %"Y"u failed", pgno));
DPRINTF(("read overflow page %"Yu" failed", pgno));
return rc;
}
data->mv_data = METADATA(omp);
@ -6375,7 +6374,7 @@ mdb_cursor_sibling(MDB_cursor *mc, int move_right)
op = mc->mc_pg[mc->mc_top];
#endif
mdb_cursor_pop(mc);
DPRINTF(("parent page is page %"Y"u, index %u",
DPRINTF(("parent page is page %"Yu", index %u",
mc->mc_pg[mc->mc_top]->mp_pgno, mc->mc_ki[mc->mc_top]));
if (move_right ? (mc->mc_ki[mc->mc_top] + 1u >= NUMKEYS(mc->mc_pg[mc->mc_top]))
@ -6452,7 +6451,7 @@ mdb_cursor_next(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
}
}
DPRINTF(("cursor_next: top page is %"Y"u in cursor %p",
DPRINTF(("cursor_next: top page is %"Yu" in cursor %p",
mdb_dbg_pgno(mp), (void *) mc));
if (mc->mc_flags & C_DEL) {
mc->mc_flags ^= C_DEL;
@ -6466,12 +6465,12 @@ mdb_cursor_next(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
return rc;
}
mp = mc->mc_pg[mc->mc_top];
DPRINTF(("next page is %"Y"u, key index %u", mp->mp_pgno, mc->mc_ki[mc->mc_top]));
DPRINTF(("next page is %"Yu", key index %u", mp->mp_pgno, mc->mc_ki[mc->mc_top]));
} else
mc->mc_ki[mc->mc_top]++;
skip:
DPRINTF(("==> cursor points to page %"Y"u with %u keys, key index %u",
DPRINTF(("==> cursor points to page %"Yu" with %u keys, key index %u",
mdb_dbg_pgno(mp), NUMKEYS(mp), mc->mc_ki[mc->mc_top]));
if (IS_LEAF2(mp)) {
@ -6541,7 +6540,7 @@ mdb_cursor_prev(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
}
}
DPRINTF(("cursor_prev: top page is %"Y"u in cursor %p",
DPRINTF(("cursor_prev: top page is %"Yu" in cursor %p",
mdb_dbg_pgno(mp), (void *) mc));
mc->mc_flags &= ~(C_EOF|C_DEL);
@ -6553,13 +6552,13 @@ mdb_cursor_prev(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
}
mp = mc->mc_pg[mc->mc_top];
mc->mc_ki[mc->mc_top] = NUMKEYS(mp) - 1;
DPRINTF(("prev page is %"Y"u, key index %u", mp->mp_pgno, mc->mc_ki[mc->mc_top]));
DPRINTF(("prev page is %"Yu", key index %u", mp->mp_pgno, mc->mc_ki[mc->mc_top]));
} else
mc->mc_ki[mc->mc_top]--;
mc->mc_flags &= ~C_EOF;
DPRINTF(("==> cursor points to page %"Y"u with %u keys, key index %u",
DPRINTF(("==> cursor points to page %"Yu" with %u keys, key index %u",
mdb_dbg_pgno(mp), NUMKEYS(mp), mc->mc_ki[mc->mc_top]));
if (IS_LEAF2(mp)) {
@ -7753,7 +7752,7 @@ mdb_page_new(MDB_cursor *mc, uint32_t flags, int num, MDB_page **mp)
if ((rc = mdb_page_alloc(mc, num, &np)))
return rc;
DPRINTF(("allocated new mpage %"Y"u, page size %u",
DPRINTF(("allocated new mpage %"Yu", page size %u",
np->mp_pgno, mc->mc_txn->mt_env->me_psize));
np->mp_flags = flags | P_DIRTY;
np->mp_lower = (PAGEHDRSZ-PAGEBASE);
@ -7853,7 +7852,7 @@ mdb_node_add(MDB_cursor *mc, indx_t indx,
mdb_cassert(mc, mp->mp_upper >= mp->mp_lower);
DPRINTF(("add to %s %spage %"Y"u index %i, data size %"Z"u key size %"Z"u [%s]",
DPRINTF(("add to %s %spage %"Yu" index %i, data size %"Z"u key size %"Z"u [%s]",
IS_LEAF(mp) ? "leaf" : "branch",
IS_SUBP(mp) ? "sub-" : "",
mdb_dbg_pgno(mp), indx, data ? data->mv_size : 0,
@ -7894,7 +7893,7 @@ mdb_node_add(MDB_cursor *mc, indx_t indx,
goto full;
if ((rc = mdb_page_new(mc, P_OVERFLOW, ovpages, &ofp)))
return rc;
DPRINTF(("allocated overflow page %"Y"u", ofp->mp_pgno));
DPRINTF(("allocated overflow page %"Yu, ofp->mp_pgno));
flags |= F_BIGDATA;
goto update;
} else {
@ -7951,7 +7950,7 @@ update:
return MDB_SUCCESS;
full:
DPRINTF(("not enough room in page %"Y"u, got %u ptrs",
DPRINTF(("not enough room in page %"Yu", got %u ptrs",
mdb_dbg_pgno(mp), NUMKEYS(mp)));
DPRINTF(("upper-lower = %u - %u = %"Z"d", mp->mp_upper,mp->mp_lower,room));
DPRINTF(("node size = %"Z"u", node_size));
@ -7974,7 +7973,7 @@ mdb_node_del(MDB_cursor *mc, int ksize)
MDB_node *node;
char *base;
DPRINTF(("delete node %u on %s page %"Y"u", indx,
DPRINTF(("delete node %u on %s page %"Yu, indx,
IS_LEAF(mp) ? "leaf" : "branch", mdb_dbg_pgno(mp)));
numkeys = NUMKEYS(mp);
mdb_cassert(mc, indx < numkeys);
@ -8131,7 +8130,7 @@ mdb_xcursor_init1(MDB_cursor *mc, MDB_node *node)
mx->mx_db.md_flags |= MDB_INTEGERKEY;
}
}
DPRINTF(("Sub-db -%u root page %"Y"u", mx->mx_cursor.mc_dbi,
DPRINTF(("Sub-db -%u root page %"Yu, mx->mx_cursor.mc_dbi,
mx->mx_db.md_root));
mx->mx_dbflag = DB_VALID|DB_USRVALID|DB_DIRTY; /* DB_DIRTY guides mdb_cursor_touch */
if (NEED_CMP_CLONG(mx->mx_dbx.md_cmp, mx->mx_db.md_pad))
@ -8166,7 +8165,7 @@ mdb_xcursor_init2(MDB_cursor *mc, MDB_xcursor *src_mx, int new_dupdata)
}
mx->mx_db = src_mx->mx_db;
mx->mx_cursor.mc_pg[0] = src_mx->mx_cursor.mc_pg[0];
DPRINTF(("Sub-db -%u root page %"Y"u", mx->mx_cursor.mc_dbi,
DPRINTF(("Sub-db -%u root page %"Yu, mx->mx_cursor.mc_dbi,
mx->mx_db.md_root));
}
@ -8336,7 +8335,7 @@ mdb_update_key(MDB_cursor *mc, MDB_val *key)
char kbuf2[DKBUF_MAXKEYSIZE*2+1];
k2.mv_data = NODEKEY(node);
k2.mv_size = node->mn_ksize;
DPRINTF(("update key %u (ofs %u) [%s] to [%s] on page %"Y"u",
DPRINTF(("update key %u (ofs %u) [%s] to [%s] on page %"Yu,
indx, ptr,
mdb_dkey(&k2, kbuf2),
DKEY(key),
@ -8484,7 +8483,7 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
return rc;
}
DPRINTF(("moving %s node %u [%s] on page %"Y"u to node %u on page %"Y"u",
DPRINTF(("moving %s node %u [%s] on page %"Yu" to node %u on page %"Yu,
IS_LEAF(csrc->mc_pg[csrc->mc_top]) ? "leaf" : "branch",
csrc->mc_ki[csrc->mc_top],
DKEY(&key),
@ -8578,7 +8577,7 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
key.mv_size = NODEKSZ(srcnode);
key.mv_data = NODEKEY(srcnode);
}
DPRINTF(("update separator for source page %"Y"u to [%s]",
DPRINTF(("update separator for source page %"Yu" to [%s]",
csrc->mc_pg[csrc->mc_top]->mp_pgno, DKEY(&key)));
mdb_cursor_copy(csrc, &mn);
mn.mc_snum--;
@ -8609,7 +8608,7 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
key.mv_size = NODEKSZ(srcnode);
key.mv_data = NODEKEY(srcnode);
}
DPRINTF(("update separator for destination page %"Y"u to [%s]",
DPRINTF(("update separator for destination page %"Yu" to [%s]",
cdst->mc_pg[cdst->mc_top]->mp_pgno, DKEY(&key)));
mdb_cursor_copy(cdst, &mn);
mn.mc_snum--;
@ -8655,7 +8654,7 @@ mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst)
psrc = csrc->mc_pg[csrc->mc_top];
pdst = cdst->mc_pg[cdst->mc_top];
DPRINTF(("merging page %"Y"u into %"Y"u", psrc->mp_pgno, pdst->mp_pgno));
DPRINTF(("merging page %"Yu" into %"Yu, psrc->mp_pgno, pdst->mp_pgno));
mdb_cassert(csrc, csrc->mc_snum > 1); /* can't merge root page */
mdb_cassert(csrc, cdst->mc_snum > 1);
@ -8712,7 +8711,7 @@ mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst)
}
}
DPRINTF(("dst page %"Y"u now has %u keys (%.1f%% filled)",
DPRINTF(("dst page %"Yu" now has %u keys (%.1f%% filled)",
pdst->mp_pgno, NUMKEYS(pdst),
(float)PAGEFILL(cdst->mc_txn->mt_env, pdst) / 10));
@ -8829,14 +8828,14 @@ mdb_rebalance(MDB_cursor *mc)
minkeys = 1;
thresh = FILL_THRESHOLD;
}
DPRINTF(("rebalancing %s page %"Y"u (has %u keys, %.1f%% full)",
DPRINTF(("rebalancing %s page %"Yu" (has %u keys, %.1f%% full)",
IS_LEAF(mc->mc_pg[mc->mc_top]) ? "leaf" : "branch",
mdb_dbg_pgno(mc->mc_pg[mc->mc_top]), NUMKEYS(mc->mc_pg[mc->mc_top]),
(float)PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) / 10));
if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= thresh &&
NUMKEYS(mc->mc_pg[mc->mc_top]) >= minkeys) {
DPRINTF(("no need to rebalance page %"Y"u, above fill threshold",
DPRINTF(("no need to rebalance page %"Yu", above fill threshold",
mdb_dbg_pgno(mc->mc_pg[mc->mc_top])));
return MDB_SUCCESS;
}
@ -8965,7 +8964,7 @@ mdb_rebalance(MDB_cursor *mc)
fromleft = 1;
}
DPRINTF(("found neighbor page %"Y"u (%u keys, %.1f%% full)",
DPRINTF(("found neighbor page %"Yu" (%u keys, %.1f%% full)",
mn.mc_pg[mn.mc_top]->mp_pgno, NUMKEYS(mn.mc_pg[mn.mc_top]),
(float)PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) / 10));
@ -9175,7 +9174,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
newindx = mc->mc_ki[mc->mc_top];
nkeys = NUMKEYS(mp);
DPRINTF(("-----> splitting %s page %"Y"u and adding [%s] at index %i/%i",
DPRINTF(("-----> splitting %s page %"Yu" and adding [%s] at index %i/%i",
IS_LEAF(mp) ? "leaf" : "branch", mp->mp_pgno,
DKEY(newkey), mc->mc_ki[mc->mc_top], nkeys));
@ -9183,7 +9182,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
if ((rc = mdb_page_new(mc, mp->mp_flags, 1, &rp)))
return rc;
rp->mp_pad = mp->mp_pad;
DPRINTF(("new right sibling: page %"Y"u", rp->mp_pgno));
DPRINTF(("new right sibling: page %"Yu, rp->mp_pgno));
/* Usually when splitting the root page, the cursor
* height is 1. But when called from mdb_update_key,
@ -9201,7 +9200,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
mc->mc_pg[0] = pp;
mc->mc_ki[0] = 0;
mc->mc_db->md_root = pp->mp_pgno;
DPRINTF(("root split! new root = %"Y"u", pp->mp_pgno));
DPRINTF(("root split! new root = %"Yu, pp->mp_pgno));
new_root = mc->mc_db->md_depth++;
/* Add left (implicit) pointer. */
@ -9218,7 +9217,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
ptop = 0;
} else {
ptop = mc->mc_top-1;
DPRINTF(("parent branch page is %"Y"u", mc->mc_pg[ptop]->mp_pgno));
DPRINTF(("parent branch page is %"Yu, mc->mc_pg[ptop]->mp_pgno));
}
mdb_cursor_copy(mc, &mn);
@ -10694,7 +10693,7 @@ mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
if (mr[i].mr_pid) {
txnid_t txnid = mr[i].mr_txnid;
sprintf(buf, txnid == (txnid_t)-1 ?
"%10d %"Z"x -\n" : "%10d %"Z"x %"Y"u\n",
"%10d %"Z"x -\n" : "%10d %"Z"x %"Yu"\n",
(int)mr[i].mr_pid, (size_t)mr[i].mr_tid, txnid);
if (first) {
first = 0;
@ -10799,7 +10798,7 @@ mdb_reader_check0(MDB_env *env, int rlocked, int *dead)
}
for (; j<rdrs; j++)
if (mr[j].mr_pid == pid) {
DPRINTF(("clear stale reader pid %u txn %"Y"d",
DPRINTF(("clear stale reader pid %u txn %"Yd,
(unsigned) pid, mr[j].mr_txnid));
mr[j].mr_pid = 0;
count++;

@ -20,7 +20,7 @@
#include <signal.h>
#include "lmdb.h"
#define Y MDB_FMT_Y
#define Yu MDB_PRIy(u)
#define PRINT 1
static int mode;
@ -111,7 +111,7 @@ static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
if (name)
printf("database=%s\n", name);
printf("type=btree\n");
printf("mapsize=%" Y "u\n", info.me_mapsize);
printf("mapsize=%"Yu"\n", info.me_mapsize);
if (info.me_mapaddr)
printf("mapaddr=%p\n", info.me_mapaddr);
printf("maxreaders=%u\n", info.me_maxreaders);

@ -38,7 +38,7 @@ static MDB_envinfo info;
static MDB_val kbuf, dbuf;
#define Y MDB_FMT_Y
#define Yu MDB_PRIy(u)
#define STRLENOF(s) (sizeof(s)-1)
@ -69,7 +69,7 @@ static void readhdr(void)
if (!strncmp(dbuf.mv_data, "VERSION=", STRLENOF("VERSION="))) {
version=atoi((char *)dbuf.mv_data+STRLENOF("VERSION="));
if (version > 3) {
fprintf(stderr, "%s: line %" Y "u: unsupported VERSION %d\n",
fprintf(stderr, "%s: line %"Yu": unsupported VERSION %d\n",
prog, lineno, version);
exit(EXIT_FAILURE);
}
@ -79,7 +79,7 @@ static void readhdr(void)
if (!strncmp((char *)dbuf.mv_data+STRLENOF("FORMAT="), "print", STRLENOF("print")))
mode |= PRINT;
else if (strncmp((char *)dbuf.mv_data+STRLENOF("FORMAT="), "bytevalue", STRLENOF("bytevalue"))) {
fprintf(stderr, "%s: line %" Y "u: unsupported FORMAT %s\n",
fprintf(stderr, "%s: line %"Yu": unsupported FORMAT %s\n",
prog, lineno, (char *)dbuf.mv_data+STRLENOF("FORMAT="));
exit(EXIT_FAILURE);
}
@ -90,7 +90,7 @@ static void readhdr(void)
subname = strdup((char *)dbuf.mv_data+STRLENOF("database="));
} else if (!strncmp(dbuf.mv_data, "type=", STRLENOF("type="))) {
if (strncmp((char *)dbuf.mv_data+STRLENOF("type="), "btree", STRLENOF("btree"))) {
fprintf(stderr, "%s: line %" Y "u: unsupported type %s\n",
fprintf(stderr, "%s: line %"Yu": unsupported type %s\n",
prog, lineno, (char *)dbuf.mv_data+STRLENOF("type="));
exit(EXIT_FAILURE);
}
@ -100,7 +100,7 @@ static void readhdr(void)
if (ptr) *ptr = '\0';
i = sscanf((char *)dbuf.mv_data+STRLENOF("mapaddr="), "%p", &info.me_mapaddr);
if (i != 1) {
fprintf(stderr, "%s: line %" Y "u: invalid mapaddr %s\n",
fprintf(stderr, "%s: line %"Yu": invalid mapaddr %s\n",
prog, lineno, (char *)dbuf.mv_data+STRLENOF("mapaddr="));
exit(EXIT_FAILURE);
}
@ -108,9 +108,10 @@ static void readhdr(void)
int i;
ptr = memchr(dbuf.mv_data, '\n', dbuf.mv_size);
if (ptr) *ptr = '\0';
i = sscanf((char *)dbuf.mv_data+STRLENOF("mapsize="), "%" Y "u", &info.me_mapsize);
i = sscanf((char *)dbuf.mv_data+STRLENOF("mapsize="),
"%" MDB_SCNy(u), &info.me_mapsize);
if (i != 1) {
fprintf(stderr, "%s: line %" Y "u: invalid mapsize %s\n",
fprintf(stderr, "%s: line %"Yu": invalid mapsize %s\n",
prog, lineno, (char *)dbuf.mv_data+STRLENOF("mapsize="));
exit(EXIT_FAILURE);
}
@ -120,7 +121,7 @@ static void readhdr(void)
if (ptr) *ptr = '\0';
i = sscanf((char *)dbuf.mv_data+STRLENOF("maxreaders="), "%u", &info.me_maxreaders);
if (i != 1) {
fprintf(stderr, "%s: line %" Y "u: invalid maxreaders %s\n",
fprintf(stderr, "%s: line %"Yu": invalid maxreaders %s\n",
prog, lineno, (char *)dbuf.mv_data+STRLENOF("maxreaders="));
exit(EXIT_FAILURE);
}
@ -136,12 +137,12 @@ static void readhdr(void)
if (!dbflags[i].bit) {
ptr = memchr(dbuf.mv_data, '=', dbuf.mv_size);
if (!ptr) {
fprintf(stderr, "%s: line %" Y "u: unexpected format\n",
fprintf(stderr, "%s: line %"Yu": unexpected format\n",
prog, lineno);
exit(EXIT_FAILURE);
} else {
*ptr = '\0';
fprintf(stderr, "%s: line %" Y "u: unrecognized keyword ignored: %s\n",
fprintf(stderr, "%s: line %"Yu": unrecognized keyword ignored: %s\n",
prog, lineno, (char *)dbuf.mv_data);
}
}
@ -151,7 +152,7 @@ static void readhdr(void)
static void badend(void)
{
fprintf(stderr, "%s: line %" Y "u: unexpected end of input\n",
fprintf(stderr, "%s: line %"Yu": unexpected end of input\n",
prog, lineno);
}
@ -209,7 +210,7 @@ badend:
buf->mv_data = realloc(buf->mv_data, buf->mv_size*2);
if (!buf->mv_data) {
Eof = 1;
fprintf(stderr, "%s: line %" Y "u: out of memory, line too long\n",
fprintf(stderr, "%s: line %"Yu": out of memory, line too long\n",
prog, lineno);
return EOF;
}
@ -401,7 +402,7 @@ int main(int argc, char *argv[])
rc = readline(&data, &dbuf);
if (rc) {
fprintf(stderr, "%s: line %" Y "u: failed to read key value\n", prog, lineno);
fprintf(stderr, "%s: line %"Yu": failed to read key value\n", prog, lineno);
goto txn_abort;
}
@ -416,7 +417,7 @@ int main(int argc, char *argv[])
if (batch == 100) {
rc = mdb_txn_commit(txn);
if (rc) {
fprintf(stderr, "%s: line %" Y "u: txn_commit: %s\n",
fprintf(stderr, "%s: line %"Yu": txn_commit: %s\n",
prog, lineno, mdb_strerror(rc));
goto env_close;
}
@ -436,7 +437,7 @@ int main(int argc, char *argv[])
rc = mdb_txn_commit(txn);
txn = NULL;
if (rc) {
fprintf(stderr, "%s: line %" Y "u: txn_commit: %s\n",
fprintf(stderr, "%s: line %"Yu": txn_commit: %s\n",
prog, lineno, mdb_strerror(rc));
goto env_close;
}

@ -18,7 +18,7 @@
#include "lmdb.h"
#define Z MDB_FMT_Z
#define Y MDB_FMT_Y
#define Yu MDB_PRIy(u)
static void prstat(MDB_stat *ms)
{
@ -26,10 +26,10 @@ static void prstat(MDB_stat *ms)
printf(" Page size: %u\n", ms->ms_psize);
#endif
printf(" Tree depth: %u\n", ms->ms_depth);
printf(" Branch pages: %"Y"u\n", ms->ms_branch_pages);
printf(" Leaf pages: %"Y"u\n", ms->ms_leaf_pages);
printf(" Overflow pages: %"Y"u\n", ms->ms_overflow_pages);
printf(" Entries: %"Y"u\n", ms->ms_entries);
printf(" Branch pages: %"Yu"\n", ms->ms_branch_pages);
printf(" Leaf pages: %"Yu"\n", ms->ms_leaf_pages);
printf(" Overflow pages: %"Yu"\n", ms->ms_overflow_pages);
printf(" Entries: %"Yu"\n", ms->ms_entries);
}
static void usage(char *prog)
@ -122,11 +122,11 @@ int main(int argc, char *argv[])
(void)mdb_env_info(env, &mei);
printf("Environment Info\n");
printf(" Map address: %p\n", mei.me_mapaddr);
printf(" Map size: %"Y"u\n", mei.me_mapsize);
printf(" Map size: %"Yu"\n", mei.me_mapsize);
printf(" Page size: %u\n", mst.ms_psize);
printf(" Max pages: %"Y"u\n", mei.me_mapsize / mst.ms_psize);
printf(" Number of pages used: %"Y"u\n", mei.me_last_pgno+1);
printf(" Last transaction ID: %"Y"u\n", mei.me_last_txnid);
printf(" Max pages: %"Yu"\n", mei.me_mapsize / mst.ms_psize);
printf(" Number of pages used: %"Yu"\n", mei.me_last_pgno+1);
printf(" Last transaction ID: %"Yu"\n", mei.me_last_txnid);
printf(" Max readers: %u\n", mei.me_maxreaders);
printf(" Number of readers used: %u\n", mei.me_numreaders);
}
@ -184,20 +184,20 @@ int main(int argc, char *argv[])
pg += span;
for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
}
printf(" Transaction %"Y"u, %"Z"d pages, maxspan %"Z"d%s\n",
printf(" Transaction %"Yu", %"Z"d pages, maxspan %"Z"d%s\n",
*(mdb_size_t *)key.mv_data, j, span, bad);
if (freinfo > 2) {
for (--j; j >= 0; ) {
pg = iptr[j];
for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
printf(span>1 ? " %9"Y"u[%"Z"d]\n" : " %9"Y"u\n",
printf(span>1 ? " %9"Yu"[%"Z"d]\n" : " %9"Yu"\n",
pg, span);
}
}
}
}
mdb_cursor_close(cursor);
printf(" Free pages: %"Y"u\n", pages);
printf(" Free pages: %"Yu"\n", pages);
}
rc = mdb_open(txn, subname, 0, &dbi);

Loading…
Cancel
Save