diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-12-23 12:53:13 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-12-23 12:53:13 -0500 |
commit | 281dd22ac0150603ab82c052a9b5995cc2c5fb8f (patch) | |
tree | d020e70c2a5632ca60dceb38e4dc84343f717652 /src/backend/commands/tablecmds.c | |
parent | 31dfa40a834177b8e989a59252ee3ce1a3309075 (diff) | |
download | postgresql-281dd22ac0150603ab82c052a9b5995cc2c5fb8f.tar.gz postgresql-281dd22ac0150603ab82c052a9b5995cc2c5fb8f.zip |
Disallow partition key expressions that return pseudo-types.
This wasn't checked originally, but it should have been, because
in general pseudo-types can't be stored to and retrieved from disk.
Notably, partition bound values of type "record" would not be
interpretable by another session.
In v12 and HEAD, add another flag to CheckAttributeType's repertoire
so that it can produce a specific error message for this case. That's
infeasible in older branches without an ABI break, so fall back to
a slightly-less-nicely-worded error message in v10 and v11.
Problem noted by Amit Langote, though this patch is not his initial
solution. Back-patch to v10 where partitioning was introduced.
Discussion: https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.com
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 9a1ef78a1fb..d207bc299f9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -14403,6 +14403,16 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs, attcollation = exprCollation(expr); /* + * The expression must be of a storable type (e.g., not RECORD). + * The test is the same as for whether a table column is of a safe + * type (which is why we needn't check for the non-expression + * case). + */ + CheckAttributeType("partition key", + atttype, attcollation, + NIL, false); + + /* * Strip any top-level COLLATE clause. This ensures that we treat * "x COLLATE y" and "(x COLLATE y)" alike. */ |