Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9KYA-0001ao-4I for pgsql-hackers@arkaria.postgresql.org; Sat, 13 May 2017 00:04:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d9KY9-0006RL-LQ for pgsql-hackers@arkaria.postgresql.org; Sat, 13 May 2017 00:04:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d9KWc-0003Sy-Ss for pgsql-hackers@postgresql.org; Sat, 13 May 2017 00:03:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d9KWZ-0003WK-FS for pgsql-hackers@postgresql.org; Sat, 13 May 2017 00:03:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v4D034rP020076; Fri, 12 May 2017 20:03:04 -0400 From: Tom Lane To: Alvaro Herrera cc: Simon Riggs , Andrew Dunstan , Tomas Vondra , PostgreSQL-development , Dean Rasheed Subject: Re: WITH clause in CREATE STATISTICS In-reply-to: <20170512221010.nglatgt5azzdxjlj@alvherre.pgsql> References: <20170512221010.nglatgt5azzdxjlj@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 12 May 2017 19:10:10 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20074.1494633784.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 12 May 2017 20:03:04 -0400 Message-ID: <20075.1494633784@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Alvaro Herrera writes: > Tom Lane wrote: >> Hm. That would behave less than desirably if getObjectClass() could >> return a value that wasn't a member of the enum, but it's hard to >> credit that happening. I guess I'd vote for removing the default: >> case from all of the places that have "switch (getObjectClass(object))", >> as forgetting to add an entry seems like a much larger hazard. > Ignoring the one in alter.c's AlterObjectNamespace_oid, which only > handles a small subset of the enum values, that gives the following > warnings: > /pgsql/source/master/src/backend/catalog/dependency.c: In function 'doDel= etion': > /pgsql/source/master/src/backend/catalog/dependency.c:1106:2: warning: en= umeration value 'OCLASS_ROLE' not handled in switch [-Wswitch] > switch (getObjectClass(object)) > ^ > /pgsql/source/master/src/backend/catalog/dependency.c:1106:2: warning: en= umeration value 'OCLASS_DATABASE' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/catalog/dependency.c:1106:2: warning: en= umeration value 'OCLASS_TBLSPACE' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/catalog/dependency.c:1106:2: warning: en= umeration value 'OCLASS_SUBSCRIPTION' not handled in switch [-Wswitch] Hm. I think it's intentional that shared objects are not handled there, but I wonder whether the lack of SUBSCRIPTION represents a bug. Anyway I think it would be fine to add those to the switch as explicit error cases. > /pgsql/source/master/src/backend/commands/tablecmds.c: In function 'ATExe= cAlterColumnType': > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_AM' not handled in switch [-Wswitch] > switch (getObjectClass(&foundObject)) > ^ > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_STATISTIC_EXT' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_EVENT_TRIGGER' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_PUBLICATION' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_PUBLICATION_REL' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_SUBSCRIPTION' not handled in switch [-Wswitch] > /pgsql/source/master/src/backend/commands/tablecmds.c:9112:3: warning: en= umeration value 'OCLASS_TRANSFORM' not handled in switch [-Wswitch] All of those ought to go into the category that prints "unexpected object depending on column", I think; certainly "unrecognized object class" is not a better report, and the fact that we've evidently not touched this switch in the last few additions of object types provides fodder for the idea that the default: is unhelpful. (Not to mention that not having OCLASS_STATISTIC_EXT here is an outright bug as of today...) So losing the default: case here seems good to me. Alternatively, we could drop the explicit listing of oclasses we're not expecting to see, and let the default: case be "unexpected object depending on column". Treating the default separately is only of value if we'd expect getObjectDescription to fail, but there's no good reason for this code to be passing judgment on whether that might happen. What do we want this to do about statistics objects? We could either throw a feature-not-implemented error or try to update the stats object for the new column type. regards, tom lane --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers