Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5697522

Browse files
committed
In plpgsql, don't try to convert int2vector or oidvector to expanded array.
These types are storage-compatible with real arrays, but they don't support toasting, so of course they can't support expansion either. Per bug #14289 from Michael Overmeyer. Back-patch to 9.5 where expanded arrays were introduced. Report: <20160818174414.1529.37913@wrigleys.postgresql.org>
1 parent e830674 commit 5697522

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/include/utils/array.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* The OIDVECTOR and INT2VECTOR datatypes are storage-compatible with
3838
* generic arrays, but they support only one-dimensional arrays with no
39-
* nulls (and no null bitmap).
39+
* nulls (and no null bitmap). They don't support being toasted, either.
4040
*
4141
* There are also some "fixed-length array" datatypes, such as NAME and
4242
* POINT. These are simply a sequence of a fixed number of items each

src/pl/plpgsql/src/pl_comp.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -2192,14 +2192,19 @@ build_datatype(HeapTuple typeTup, int32 typmod, Oid collation)
21922192
/* NB: this is only used to decide whether to apply expand_array */
21932193
if (typeStruct->typtype == TYPTYPE_BASE)
21942194
{
2195-
/* this test should match what get_element_type() checks */
2195+
/*
2196+
* This test should include what get_element_type() checks. We also
2197+
* disallow non-toastable array types (i.e. oidvector and int2vector).
2198+
*/
21962199
typ->typisarray = (typeStruct->typlen == -1 &&
2197-
OidIsValid(typeStruct->typelem));
2200+
OidIsValid(typeStruct->typelem) &&
2201+
typeStruct->typstorage != 'p');
21982202
}
21992203
else if (typeStruct->typtype == TYPTYPE_DOMAIN)
22002204
{
22012205
/* we can short-circuit looking up base types if it's not varlena */
22022206
typ->typisarray = (typeStruct->typlen == -1 &&
2207+
typeStruct->typstorage != 'p' &&
22032208
OidIsValid(get_base_element_type(typeStruct->typbasetype)));
22042209
}
22052210
else

0 commit comments

Comments
 (0)