Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc35b472

Browse files
committed
Fix errors in contrib/bloom index build.
Count the number of tuples in the index honestly, instead of assumingthat it's the same as the number of tuples in the heap. (It might bedifferent if the index is partial.)Fix counting of tuples in current index page, too. This error wouldhave led to failing to write out the final page of the index if itcontained exactly one tuple, so that the last tuple of the relationwould not get indexed.Back-patch to 9.6 where contrib/bloom was added.Tomas Vondra and Tom LaneDiscussion:https://postgr.es/m/3b3d8eac-c709-0d25-088e-b98339a1b28a@2ndquadrant.com
1 parente2f1eb0 commitc35b472

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

‎contrib/bloom/blinsert.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ PG_MODULE_MAGIC;
3333
typedefstruct
3434
{
3535
BloomStateblstate;/* bloom index state */
36+
int64indtuples;/* total number of tuples indexed */
3637
MemoryContexttmpCtx;/* temporary memory context reset after each
3738
* tuple */
3839
chardata[BLCKSZ];/* cached page */
39-
int64count;/* number of tuples in cached page */
40+
intcount;/* number of tuples in cached page */
4041
}BloomBuildState;
4142

4243
/*
@@ -102,8 +103,14 @@ bloomBuildCallback(Relation index, HeapTuple htup, Datum *values,
102103
/* We shouldn't be here since we're inserting to the empty page */
103104
elog(ERROR,"could not add new bloom tuple to empty page");
104105
}
106+
107+
/* Next item was added successfully */
108+
buildstate->count++;
105109
}
106110

111+
/* Update total tuple count */
112+
buildstate->indtuples+=1;
113+
107114
MemoryContextSwitchTo(oldCtx);
108115
MemoryContextReset(buildstate->tmpCtx);
109116
}
@@ -138,17 +145,15 @@ blbuild(Relation heap, Relation index, IndexInfo *indexInfo)
138145
bloomBuildCallback, (void*)&buildstate,
139146
NULL);
140147

141-
/*
142-
* There are could be some items in cached page. Flush this page if
143-
* needed.
144-
*/
148+
/* Flush last page if needed (it will be, unless heap was empty) */
145149
if (buildstate.count>0)
146150
flushCachedPage(index,&buildstate);
147151

148152
MemoryContextDelete(buildstate.tmpCtx);
149153

150154
result= (IndexBuildResult*)palloc(sizeof(IndexBuildResult));
151-
result->heap_tuples=result->index_tuples=reltuples;
155+
result->heap_tuples=reltuples;
156+
result->index_tuples=buildstate.indtuples;
152157

153158
returnresult;
154159
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp