Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XOXmV-000884-7N for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Sep 2014 20:00:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XOXmU-0003vY-G7 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Sep 2014 20:00:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XOXmT-0003vP-AI for pgsql-hackers@postgresql.org; Mon, 01 Sep 2014 20:00:49 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XOXmP-0003Ne-97 for pgsql-hackers@postgresql.org; Mon, 01 Sep 2014 20:00:48 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1XOXmL-0005RB-0M; Mon, 01 Sep 2014 16:00:41 -0400 Date: Mon, 1 Sep 2014 16:00:41 -0400 From: Bruce Momjian To: Tom Lane Cc: David G Johnston , pgsql-hackers@postgresql.org Subject: Re: Re: [BUGS] Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns Message-ID: <20140901200040.GC19338@momjian.us> References: <20140827144053.GL14956@momjian.us> <31422.1409153093@sss.pgh.pa.us> <20140828014030.GA777962@tornado.leadboat.com> <20140830233226.GC15078@momjian.us> <4268.1409503835@sss.pgh.pa.us> <1409507164344-5817073.post@n5.nabble.com> <14363.1409508633@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pf9I7BMVVzbSWLtt" Content-Disposition: inline In-Reply-To: <14363.1409508633@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -3.6 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Aug 31, 2014 at 02:10:33PM -0400, Tom Lane wrote: > David G Johnston writes: > > Would it be proper to issue an additional top-level warning with the column > > moved notification? Thus there would be NOTICE, NOTICE, WARNING in the > > above example? Or, more generically, "columns reordered to match inherited > > column order" to avoid multiple warnings if more than one column is moved. > > That's a good point: if this message fires at all, it will probably fire > more than once; do we want that? If we do it as you suggest here, we'll > lose the information as to exactly which columns got relocated, which > perhaps is bad, or maybe it doesn't matter. Also, I don't remember the > exact code structure in that area, but it might be a bit painful to > arrange that we get only one such warning even when inheriting from > multiple parents. > > If we do want the specific moved columns to be identified, I'd still go > with errdetail on the NOTICE rather than two separate messages. I think > calling it a WARNING is a bit extreme anyway. OK, here is the updated output based on the comments: CREATE TABLE B(a int, c int); CREATE TABLE a5 ( a integer, b integer, c integer ) INHERITS (b); NOTICE: merging column "a" with inherited definition NOTICE: moving and merging column "c" with inherited definition DETAIL: user-specified column moved to the location of the inherited column I think we have to mention "move" in the error message because mentioning "move" only in the detail means that the detail actually has new information, not more detailed information. Patch attached. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --pf9I7BMVVzbSWLtt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="inh-warning.diff" diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c new file mode 100644 index 3720a0f..b88b664 *** a/src/backend/commands/tablecmds.c --- b/src/backend/commands/tablecmds.c *************** MergeAttributes(List *schema, List *supe *** 1756,1767 **** --- 1756,1771 ---- */ if (inhSchema != NIL) { + int schema_attno = 0; + foreach(entry, schema) { ColumnDef *newdef = lfirst(entry); char *attributeName = newdef->colname; int exist_attno; + schema_attno++; + /* * Does it conflict with some previously inherited column? */ *************** MergeAttributes(List *schema, List *supe *** 1780,1788 **** * Yes, try to merge the two column definitions. They must * have the same type, typmod, and collation. */ ! ereport(NOTICE, ! (errmsg("merging column \"%s\" with inherited definition", ! attributeName))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod); typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod); --- 1784,1797 ---- * Yes, try to merge the two column definitions. They must * have the same type, typmod, and collation. */ ! if (exist_attno == schema_attno) ! ereport(NOTICE, ! (errmsg("merging column \"%s\" with inherited definition", ! attributeName))); ! else ! ereport(NOTICE, ! (errmsg("moving and merging column \"%s\" with inherited definition", attributeName), ! errdetail("user-specified column moved to the location of the inherited column"))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod); typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod); --pf9I7BMVVzbSWLtt Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --pf9I7BMVVzbSWLtt--