aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index e4697f68aeb..96bed96e753 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -3552,8 +3552,6 @@ CheckConstraintFetch(Relation relation)
SysScanDesc conscan;
ScanKeyData skey[1];
HeapTuple htup;
- Datum val;
- bool isnull;
int found = 0;
ScanKeyInit(&skey[0],
@@ -3568,6 +3566,9 @@ CheckConstraintFetch(Relation relation)
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
+ Datum val;
+ bool isnull;
+ char *s;
/* We want check constraints only */
if (conform->contype != CONSTRAINT_CHECK)
@@ -3590,8 +3591,11 @@ CheckConstraintFetch(Relation relation)
elog(ERROR, "null conbin for rel %s",
RelationGetRelationName(relation));
- check[found].ccbin = MemoryContextStrdup(CacheMemoryContext,
- TextDatumGetCString(val));
+ /* detoast and convert to cstring in caller's context */
+ s = TextDatumGetCString(val);
+ check[found].ccbin = MemoryContextStrdup(CacheMemoryContext, s);
+ pfree(s);
+
found++;
}