Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hm3yQ-0003LX-Cm for pgsql-general@arkaria.postgresql.org; Fri, 12 Jul 2019 22:25:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hm3xQ-0006Md-1S for pgsql-general@arkaria.postgresql.org; Fri, 12 Jul 2019 22:24:00 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hm3xP-0006J7-Js for pgsql-general@lists.postgresql.org; Fri, 12 Jul 2019 22:23:59 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hm3xH-0001rE-Pw for pgsql-general@postgresql.org; Fri, 12 Jul 2019 22:23:58 +0000 Received: by mail-wr1-x444.google.com with SMTP id r1so11354759wrl.7 for ; Fri, 12 Jul 2019 15:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=WCoxilRHSF95c53CV9OhI8LfAtmL6rdljHeLSrMKUJw=; b=n312X/7L+t4X1qeloMWehzFpscizQpFPuYe8r1izDuGwRRLuP72qXYdAKZdOpPR6f7 BAc2OIhV1GOdkUy3WBkwmzuHVZ9xueJbXGNDiRAopjB6KcxKCYL6eopX71JFpzeGaUn2 JFeH5W7OIcz4o2znhUNhu07O96lvP6kC2rHKrzT1e0BrBtju/w6QPkbbcpuwgzZAWyz6 gcL1vfvPK5kU+w/JXxlwQ7sMM5qWbmiOoe09DLmpFQEdBozLKlg5s+sgzTy8aHBUL1dX 0mGvj+CLyHP/6Bk+kQiNIfSl5SbP662giTUKuBvFaNwEwccakf3wi2dAEslP+JrU9Yss MNiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=WCoxilRHSF95c53CV9OhI8LfAtmL6rdljHeLSrMKUJw=; b=chrQYczrGcd7gCaV3TxATI1u1aqXa5YRldNxoMrJKWjERMUwG/s3Lq+C42JHCEvsaS uS4vUBjEkU4LtYQjZZuxQfyH2nt9DFjOPH04b8lY6NQZw2Jny8BSRdA9TU0VsNamIGA8 Gs98gTfgiGD+9qfYUwPK3YlTJpIIS2l4XO4BAxG9GxLdEtNVwVAJ1Rwr371Hp/X8nP4z zFVXFSwCFNbW/vcVXBg0cwc2dSq/A6BDP/GMov+Y8E55EF+XoGLQYPrzfLaFKsDEMPbp CzYmFp2nwNv2GKcfF7V/3gQwwB6qhAwAOAKo7TnVrHoNTrBXQoVClW8CbZhr94NmVX3W rpEA== X-Gm-Message-State: APjAAAURM6qDn2fQWU6rNKQIH1I6F1rjKrK/PAfU7yx9+ERlceXDu/94 XfUs3TG/P5fDUYj/cELn+YSYcQ== X-Google-Smtp-Source: APXvYqx7r+Nw6mAAyENmYDPybQErBmolRex07UjWZ2LwGORMtihyERXnrRGtGcbjkYdmMuf3V0lRBg== X-Received: by 2002:adf:ee87:: with SMTP id b7mr14440943wro.61.1562970229896; Fri, 12 Jul 2019 15:23:49 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([77.243.191.21]) by smtp.gmail.com with ESMTPSA id s10sm8548077wrt.49.2019.07.12.15.23.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 12 Jul 2019 15:23:49 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id BD6771249EF; Fri, 12 Jul 2019 18:23:43 -0400 (-04) Date: Fri, 12 Jul 2019 18:23:43 -0400 From: Alvaro Herrera To: Thomas Kellerer Cc: pgsql-general@postgresql.org Subject: Re: How to extract information from pg_ddl_command type Message-ID: <20190712222343.GA26924@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jul-11, Thomas Kellerer wrote: > The function pg_event_trigger_ddl_commands() returns several columns, one of them being "command" that is of the type "pg_ddl_command". > > The manual[1] describes this column as: > > > A complete representation of the command, in internal format. > > This cannot be output directly, but it can be passed to other > > functions to obtain different pieces of information about the > > command. > > However, I can not find any of those "other functions" to extract information from that column. > > My goal is to get the complete SQL text that fired the event trigger - is that even possible through pg_event_trigger_ddl_commands()? You need a C function. See the test module in src/test/modules/test_ddl_deparse -- it contains a very simple implementation that doesn't really do a lot, but maybe it helps. The real meat of the thing is in an outdated module I wrote for 9.5. I think the latest version of that was posted by Alexander Shulgin in 2015 here https://postgr.es/m/CACACo5Q_UXYwF117LBhjZ3xaMPyrgqnqE=mXvRhEfjJ51aCfwQ@mail.gmail.com or maybe it's here https://postgr.es/m/CACACo5QQuAV+n4Gi+YA1JF_a+QenR6SJuP8CYdPSrXKa+FHS3A@mail.gmail.com -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services