Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1emqkL-0006bX-WC for pgsql-general@arkaria.postgresql.org; Sat, 17 Feb 2018 00:52:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1emqkK-0000mG-6z for pgsql-general@arkaria.postgresql.org; Sat, 17 Feb 2018 00:52:56 +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 1emqkJ-0000m6-Vb for pgsql-general@lists.postgresql.org; Sat, 17 Feb 2018 00:52:56 +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.89) (envelope-from ) id 1emqkF-00073q-IZ for pgsql-general@postgresql.org; Sat, 17 Feb 2018 00:52:54 +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 w1H0qmoN003386; Fri, 16 Feb 2018 19:52:48 -0500 From: Tom Lane To: Ken Tanzer cc: PG-General Mailing List Subject: Re: Trigger (or something similar) on table rename? In-reply-to: References: <28694.1518721313@sss.pgh.pa.us> Comments: In-reply-to Ken Tanzer message dated "Fri, 16 Feb 2018 16:22:18 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3384.1518828768.1@sss.pgh.pa.us> Date: Fri, 16 Feb 2018 19:52:48 -0500 Message-ID: <3385.1518828768@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ken Tanzer writes: > Presumably the complete command would let you figure out it's a rename, and > the old and new tables. But I found this message ( > https://postgrespro.com/list/thread-id/1561932) stating that a > pg_ddl_command could only be processed in C, not in a procedural language. > I'm wondering if that just hasn't been implemented yet and is likely to > change at some point, or if there is some kind of inherent limitation > involved. That's basically the missing infrastructure I referred to. The parse tree data structures are reasonably well-documented internally (look under src/include/nodes/), but there's not a lot of mechanism in place for displaying them to high-level code. We do have decent support for reverse-compiling DML statements (select/insert/update/delete), but not for utility commands which is what you're interested in. There's no inherent reason we couldn't get there, it's just that it'd be a lot of work to get to reasonable coverage, and probably a lot of code to maintain going forward. It looks like src/test/modules/test_ddl_deparse/ contains the beginnings of a facility of this sort ... but it's only test code and doesn't necessarily have anybody's blessing as to being a good basis for moving forward. regards, tom lane