[PATCH] Add schema and table names to partition error

Chris Bandy <bandy.chris@gmail.com>

From: Chris Bandy <bandy.chris@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2020-02-29T19:33:48Z
Lists: pgsql-hackers

Attachments

Hello,

I'm writing telemetry data into a table partitioned by time. When there 
is no partition for a particular date, my app notices the constraint 
violation, creates the partition, and retries the insert.

I'm used to handling constraint violations by observing the constraint 
name in the error fields. However, this error had none. I set out to add 
the name to the error field, but after a bit of reading my impression is 
that partition constraints are more like a property of a table.

I've attached a patch that adds the schema and table name fields to 
errors for my use case:

- Insert data into a partitioned table for which there is no partition.
- Insert data directly into an incorrect partition.

Thanks,
Chris

Commits

  1. Add object names to partition integrity violations.