summaryrefslogtreecommitdiff
path: root/src/heap/heap_open.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-02-17 17:25:57 +0000
committer <>2015-03-17 16:26:24 +0000
commit780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch)
tree598f8b9fa431b228d29897e798de4ac0c1d3d970 /src/heap/heap_open.c
parent7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff)
downloadberkeleydb-master.tar.gz
Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz.HEADdb-6.1.23master
Diffstat (limited to 'src/heap/heap_open.c')
-rw-r--r--src/heap/heap_open.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/heap/heap_open.c b/src/heap/heap_open.c
index 6827450d..f5bb72ae 100644
--- a/src/heap/heap_open.c
+++ b/src/heap/heap_open.c
@@ -1,19 +1,19 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*/
#include "db_config.h"
#include "db_int.h"
+#include "dbinc/blob.h"
#include "dbinc/crypto.h"
#include "dbinc/db_page.h"
#include "dbinc/db_swap.h"
#include "dbinc/fop.h"
#include "dbinc/heap.h"
#include "dbinc/lock.h"
-#include "dbinc/log.h"
#include "dbinc/mp.h"
static void __heap_init_meta __P((DB *, HEAPMETA *, db_pgno_t, DB_LSN*));
@@ -82,6 +82,7 @@ __heap_metachk(dbp, name, hm)
env = dbp->env;
h = (HEAP *)dbp->heap_internal;
+ ret = 0;
/*
* At this point, all we know is that the magic number is for a Heap.
@@ -92,6 +93,7 @@ __heap_metachk(dbp, name, hm)
M_32_SWAP(vers);
switch (vers) {
case 1:
+ case 2:
break;
default:
__db_errx(env,
@@ -116,6 +118,26 @@ __heap_metachk(dbp, name, hm)
/* Set the page size. */
dbp->pgsize = hm->dbmeta.pagesize;
+ dbp->blob_threshold = hm->blob_threshold;
+ GET_BLOB_FILE_ID(env, hm, dbp->blob_file_id, ret);
+ if (ret != 0)
+ return (ret);
+ /* Blob databases must be upgraded. */
+ if (vers == 1 && dbp->blob_file_id != 0) {
+ __db_errx(env, DB_STR_A("1209",
+"%s: databases that support blobs must be upgraded.", "%s"),
+ name);
+ return (EINVAL);
+ }
+#ifndef HAVE_64BIT_TYPES
+ if (dbp->blob_file_id != 0) {
+ __db_errx(env, DB_STR_A("1205",
+ "%s: blobs require 64 integer compiler support.", "%s"),
+ name);
+ return (EINVAL);
+ }
+#endif
+
/* Copy the file's ID. */
memcpy(dbp->fileid, hm->dbmeta.uid, DB_FILE_ID_LEN);
@@ -179,7 +201,8 @@ __heap_read_meta(dbp, ip, txn, meta_pgno, flags)
h->region_size = meta->region_size;
if (PGNO(meta) == PGNO_BASE_MD && !F_ISSET(dbp, DB_AM_RECOVER))
- __memp_set_last_pgno(mpf, meta->dbmeta.last_pgno);
+ (void)__memp_set_last_pgno(
+ mpf, meta->dbmeta.last_pgno);
} else {
DB_ASSERT(dbp->env,
IS_RECOVERING(dbp->env) || F_ISSET(dbp, DB_AM_RECOVER));
@@ -285,6 +308,12 @@ __heap_new_file(dbp, ip, txn, fhp, name)
pginfo.type = dbp->type;
pdbt.data = &pginfo;
pdbt.size = sizeof(pginfo);
+ if (dbp->blob_threshold) {
+ if ((ret = __blob_generate_dir_ids(
+ dbp, txn, &dbp->blob_file_id)) != 0)
+ return (ret);
+
+ }
if ((ret = __os_calloc(env, 1, dbp->pgsize, &buf)) != 0)
return (ret);
meta = (HEAPMETA *)buf;
@@ -394,7 +423,9 @@ done: if (region != NULL && (t_ret = __memp_fput(mpf,
dbc->thread_info, region, dbc->priority)) != 0 && ret == 0)
ret = t_ret;
- ret = __memp_fput(mpf, dbc->thread_info, meta, dbc->priority);
+ if ((t_ret = __memp_fput(mpf,
+ dbc->thread_info, meta, dbc->priority)) != 0 && ret == 0)
+ ret = t_ret;
if ((t_ret = __TLPUT(dbc, meta_lock)) != 0 && ret == 0)
ret = t_ret;
@@ -436,4 +467,6 @@ __heap_init_meta(dbp, meta, pgno, lsnp)
meta->region_size = h->region_size;
meta->nregions = 1;
meta->curregion = 1;
+ meta->blob_threshold = dbp->blob_threshold;
+ SET_BLOB_META_FILE_ID(meta, dbp->blob_file_id, HEAPMETA);
}