Adding type info etc for inheritance errmsg: "child table is missing column ..."

From: Ryan Murphy <ryanfmurphy(at)gmail(dot)com>
To: PostgreSQL DEV mailing list <pgsql-hackers(at)postgresql(dot)org>
Subject: Adding type info etc for inheritance errmsg: "child table is missing column ..."
Date: 2017-01-07 17:19:10
Message-ID: CAHeEsBc95C6=Sce_5nLuv66EEs2=8B7WPNofm6=3A581QxHwXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hey Postgres team!

I've been gleefully using the inheritance feature of Postgres for the last
6 months or so, and it's really great! I especially like how easily you
can ALTER TABLE foo INHERIT bar, and get helpful error messages about what
columns need to be there before the inherit can take place.

One thing that seemed helpful to me is if it not only told you that you're
missing the attribute, but also told you the type, and perhaps even the
constraints, so you can easily make the column match up with the one you're
inheriting. Otherwise you may add the wrong type of column and end up with
a "column is the wrong type" error.

The attached patch is my initial attempt at adding the type, making the
error message read e.g.:

ERROR: child table is missing column "name" text

I'm sure it needs work (in particular I borrowed a lot of the get-type-name
logic from getTypeOutputInfo() so probably needs a factor), and I'd
ultimately love for it to list NOT NULL, DEFAULTs and other constraints to
make it easier to prepare a table to inherit from another.

Thoughts / suggestions? Does this seem useful to you guys?

Best,
Ryan

Attachment Content-Type Size
0001-child-table-is-missing-attribute-show-type.patch application/octet-stream 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2017-01-07 17:20:00 Re: [WIP]Vertical Clustered Index (columnar store extension)
Previous Message Kuntal Ghosh 2017-01-07 17:07:57 Re: Incorrect XLogRegisterBuffer flag for revmapbuf in brin