1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Fix contrib/hstore to throw an error for keys or values that don't fit in its

data structure, rather than silently truncating them.  Andrew Gierth
This commit is contained in:
Tom Lane
2009-03-15 22:05:17 +00:00
parent 7a52a8f829
commit f3a72bd40b
4 changed files with 46 additions and 15 deletions

View File

@ -295,7 +295,7 @@ tconvert(PG_FUNCTION_ARGS)
SET_VARSIZE(out, len);
out->size = 1;
ARRPTR(out)->keylen = VARSIZE(key) - VARHDRSZ;
ARRPTR(out)->keylen = hstoreCheckKeyLen(VARSIZE(key) - VARHDRSZ);
if (PG_ARGISNULL(1))
{
ARRPTR(out)->vallen = 0;
@ -303,7 +303,7 @@ tconvert(PG_FUNCTION_ARGS)
}
else
{
ARRPTR(out)->vallen = VARSIZE(val) - VARHDRSZ;
ARRPTR(out)->vallen = hstoreCheckValLen(VARSIZE(val) - VARHDRSZ);
ARRPTR(out)->valisnull = false;
}
ARRPTR(out)->pos = 0;
@ -540,11 +540,9 @@ hs_contains(PG_FUNCTION_ARGS)
res = false;
}
else if (te->vallen != entry->vallen ||
strncmp(
vv + entry->pos + entry->keylen,
strncmp(vv + entry->pos + entry->keylen,
tv + te->pos + te->keylen,
te->vallen)
)
te->vallen))
res = false;
}
else