summaryrefslogtreecommitdiff
path: root/src/heap/heap_upgrade.c
blob: 35fa78b960cfab23091bf90751b2fb8620f76a02 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1996, 2015 Oracle and/or its affiliates.  All rights reserved.
 *
 * $Id$
 */

#include "db_config.h"

#include "db_int.h"
#include "dbinc/blob.h"
#include "dbinc/db_page.h"
#include "dbinc/heap.h"
#include "dbinc/db_upgrade.h"

/*
 * __heap_60_heapmeta--
 *	Upgrade the version number.
 *
 * PUBLIC: int __heap_60_heapmeta
 * PUBLIC:      __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
 */
int
__heap_60_heapmeta(dbp, real_name, flags, fhp, h, dirtyp)
	DB *dbp;
	char *real_name;
	u_int32_t flags;
	DB_FH *fhp;
	PAGE *h;
	int *dirtyp;
{
	HEAPMETA *hmeta;

	COMPQUIET(flags, 0);
	COMPQUIET(real_name, NULL);
	COMPQUIET(fhp, NULL);
	COMPQUIET(dbp, NULL);
	hmeta = (HEAPMETA *)h;

	hmeta->dbmeta.version = 2;
	*dirtyp = 1;

	return (0);
}

/*
 * __heap_60_heap --
 *	Upgrade the blob records on the database heap pages.
 *
 * PUBLIC: int __heap_60_heap
 * PUBLIC:      __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
 */
int
__heap_60_heap(dbp, real_name, flags, fhp, h, dirtyp)
	DB *dbp;
	char *real_name;
	u_int32_t flags;
	DB_FH *fhp;
	PAGE *h;
	int *dirtyp;
{
	HEAPBLOBHDR60 hb60;
	HEAPBLOBHDR60P1 hb60p1;
	HEAPHDR *hdr;
	db_seq_t blob_id, blob_size, file_id;
	db_indx_t indx, *offtbl;
	int ret;

	COMPQUIET(flags, 0);
	COMPQUIET(real_name, NULL);
	COMPQUIET(fhp, NULL);
	offtbl = (db_indx_t *)HEAP_OFFSETTBL(dbp, h);
	ret = 0;

	DB_ASSERT(dbp->env, HEAPBLOBREC60_SIZE == HEAPBLOBREC_SIZE);
	for (indx = 0; indx <= HEAP_HIGHINDX(h); indx++) {
		if (offtbl[indx] == 0)
			continue;
		hdr = (HEAPHDR *)P_ENTRY(dbp, h, indx);
		if (F_ISSET(hdr, HEAP_RECBLOB)) {
			memcpy(&hb60, hdr, HEAPBLOBREC60_SIZE);
			memset(&hb60p1, 0, HEAPBLOBREC_SIZE);
			hb60p1.std_hdr.flags = hb60.flags;
			hb60p1.std_hdr.size = hb60.size;
			hb60p1.encoding = hb60.encoding;
			hb60p1.lsn = hb60.lsn;
			GET_BLOB60_ID(dbp->env, hb60, blob_id, ret);
			if (ret != 0)
				return (ret);
			GET_BLOB60_SIZE(dbp->env, hb60, blob_size, ret);
			if (ret != 0)
				return (ret);
			GET_BLOB60_FILE_ID(dbp->env, &hb60, file_id, ret);
			if (ret != 0)
				return (ret);
			SET_BLOB_ID(&hb60p1, blob_id, HEAPBLOBHDR60P1);
			SET_BLOB_SIZE(&hb60p1, blob_size, HEAPBLOBHDR60P1);
			SET_BLOB_FILE_ID(&hb60p1, file_id, HEAPBLOBHDR60P1);
			memcpy(hdr, &hb60p1, HEAPBLOBREC_SIZE);
			*dirtyp = 1;
		}
	}

	return (ret);
}