summaryrefslogtreecommitdiff
path: root/src/backend/access/spgist/spgtextproc.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-12-19 14:58:41 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-12-19 14:58:41 -0500
commit92203624934095163f8b57b5b3d7bbd2645da2c8 (patch)
tree8570ad85adefe211f46f295b86aaf05d461f3e8a /src/backend/access/spgist/spgtextproc.c
parent3695a555136a6d179cac8ae48d5f90171d5b30e9 (diff)
Teach SP-GiST to do index-only scans.
Operator classes can specify whether or not they support this; this preserves the flexibility to use lossy representations within an index. In passing, move constant data about a given index into the rd_amcache cache area, instead of doing fresh lookups each time we start an index operation. This is mainly to try to make sure that spgcanreturn() has insignificant cost; I still don't have any proof that it matters for actual index accesses. Also, get rid of useless copying of FmgrInfo pointers; we can perfectly well use the relcache's versions in-place.
Diffstat (limited to 'src/backend/access/spgist/spgtextproc.c')
-rw-r--r--src/backend/access/spgist/spgtextproc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/backend/access/spgist/spgtextproc.c b/src/backend/access/spgist/spgtextproc.c
index b6037978425..ab37d482636 100644
--- a/src/backend/access/spgist/spgtextproc.c
+++ b/src/backend/access/spgist/spgtextproc.c
@@ -51,6 +51,7 @@ spg_text_config(PG_FUNCTION_ARGS)
cfg->prefixType = TEXTOID;
cfg->labelType = CHAROID;
+ cfg->canReturnData = true;
cfg->longValuesOK = true; /* suffixing will shorten long values */
PG_RETURN_VOID();
}
@@ -521,7 +522,10 @@ spg_text_leaf_consistent(PG_FUNCTION_ARGS)
queryLen = VARSIZE_ANY_EXHDR(query);
- /* For equality, we needn't reconstruct fullValue if not same length */
+ /*
+ * For an equality check, we needn't reconstruct fullValue if not same
+ * length; it can't match
+ */
if (strategy == BTEqualStrategyNumber && queryLen != fullLen)
PG_RETURN_BOOL(false);
@@ -529,15 +533,20 @@ spg_text_leaf_consistent(PG_FUNCTION_ARGS)
if (VARSIZE_ANY_EXHDR(leafValue) == 0 && level > 0)
{
fullValue = VARDATA(reconstrValue);
+ out->leafValue = PointerGetDatum(reconstrValue);
}
else
{
- fullValue = palloc(fullLen);
+ text *fullText = palloc(VARHDRSZ + fullLen);
+
+ SET_VARSIZE(fullText, VARHDRSZ + fullLen);
+ fullValue = VARDATA(fullText);
if (level)
memcpy(fullValue, VARDATA(reconstrValue), level);
if (VARSIZE_ANY_EXHDR(leafValue) > 0)
memcpy(fullValue + level, VARDATA_ANY(leafValue),
VARSIZE_ANY_EXHDR(leafValue));
+ out->leafValue = PointerGetDatum(fullText);
}
/* Run the appropriate type of comparison */