On 19/11/2018 19:54, Alvaro Herrera wrote:
> It's unclear why you made generated columns on partitions unsupported.
> I'd fix the limitation if possible, but if not, at least document it.
This is explained here:
+ /*
+ * Generated columns in partition key expressions:
+ *
+ * - Stored generated columns cannot work: They are computed
+ * after BEFORE triggers, but partition routing is done
+ * before all triggers.
+ *
+ * - Virtual generated columns could work. But there is a
+ * problem when dropping such a table: Dropping a table
+ * calls relation_open(), which causes partition keys to be
+ * constructed for the partcache, but at that point the
+ * generation expression is already deleted (through
+ * dependencies), so this will fail. So if you remove the
+ * restriction below, things will appear to work, but you
+ * can't drop the table. :-(
+ */
> (I particularly notice that partition key is marked as unsupported in
> the regression test. Consider partitioning on a SERIAL column, this is
> clearly something that users will expect to work.)
A serial column is not a generated column.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services