reinit-opaque.patch
text/x-diff
Filename: reinit-opaque.patch
Type: text/x-diff
Part: 0
Message:
Re: BRIN indexes - TRAP: BadArgument
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/brin/brin.c | 9 | 0 |
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index bd35cf6..441127f 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -519,6 +519,7 @@ brinrescan(PG_FUNCTION_ARGS)
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(1);
+ BrinOpaque *opaque;
/* other arguments ignored */
@@ -526,6 +527,14 @@ brinrescan(PG_FUNCTION_ARGS)
memmove(scan->keyData, scankey,
scan->numberOfKeys * sizeof(ScanKeyData));
+ /*
+ * Reinitialize the opaque struct; some opclasses might choose to
+ * cache per-scan info in there.
+ */
+ opaque = (BrinOpaque *) scan->opaque;
+ brin_free_desc(opaque->bo_bdesc);
+ opaque->bo_bdesc = brin_build_desc(scan->indexRelation);
+
PG_RETURN_VOID();
}