MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / add_clump

Function add_clump

src/jrd/pag.cpp:124–220  ·  view source on GitHub ↗

CVC: Since nobody checks the result from this function (strange!), I changed bool to void as the return type but left the result returned as comment.

Source from the content-addressed store, hash-verified

122// CVC: Since nobody checks the result from this function (strange!), I changed
123// bool to void as the return type but left the result returned as comment.
124static void add_clump(thread_db* tdbb, USHORT type, USHORT len, const UCHAR* entry, ClumpOper mode)
125{
126/***********************************************
127 *
128 * a d d _ c l u m p
129 *
130 ***********************************************
131 *
132 * Functional description
133 * Adds a clump to log/header page.
134 * mode
135 * 0 - add CLUMP_ADD
136 * 1 - replace CLUMP_REPLACE
137 * 2 - replace only! CLUMP_REPLACE_ONLY
138 * returns
139 * true - modified page
140 * false - nothing done => nobody checks this function's result.
141 *
142 **************************************/
143 SET_TDBB(tdbb);
144 Database* dbb = tdbb->getDatabase();
145 CHECK_DBB(dbb);
146
147 err_post_if_database_is_readonly(dbb);
148
149 WIN window(DB_PAGE_SPACE, HEADER_PAGE);
150 pag* page = CCH_FETCH(tdbb, &window, LCK_write, pag_header);
151 header_page* header = (header_page*) page;
152 USHORT* end_addr = &header->hdr_end;
153
154 UCHAR* entry_p;
155 const UCHAR* clump_end;
156 if (mode != CLUMP_ADD)
157 {
158 const bool found = find_type(tdbb, &window, &page, LCK_write, type, &entry_p, &clump_end);
159
160 // If we did'nt find it and it is REPLACE_ONLY, return
161
162 if (!found && mode == CLUMP_REPLACE_ONLY)
163 {
164 CCH_RELEASE(tdbb, &window);
165 return; //false;
166 }
167
168 // If not found, just go and add the entry
169
170 if (found)
171 {
172
173 // if same size, overwrite it
174 const USHORT oldLen = entry_p[1] + 2u;
175
176 if (oldLen - 2u == len)
177 {
178 entry_p += 2;
179 if (len)
180 {
181 CCH_MARK_MUST_WRITE(tdbb, &window);

Callers 4

PAG_add_fileFunction · 0.85
PAG_set_db_guidFunction · 0.85
PAG_set_repl_sequenceFunction · 0.85
PAG_set_sweep_intervalFunction · 0.85

Calls 9

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
CCH_FETCHFunction · 0.85
find_typeFunction · 0.85
CCH_RELEASEFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
find_clump_spaceFunction · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected