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 1h5wCk-0003Hk-5T for pgsql-gui-dev@arkaria.postgresql.org; Mon, 18 Mar 2019 17:37:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5wCi-0003qW-Hw for pgsql-gui-dev@arkaria.postgresql.org; Mon, 18 Mar 2019 17:37:40 +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 1h5wCi-0003qO-BT for pgsql-gui-dev@lists.postgresql.org; Mon, 18 Mar 2019 17:37:40 +0000 Received: from mimolette.dalibo.net ([212.85.157.144] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5wCf-00030d-9j for pgsql-gui-dev@lists.postgresql.org; Mon, 18 Mar 2019 17:37:39 +0000 Received: from webmail2.dalibo.info (mimolette.dalibo.net [212.85.157.144]) by mail.dalibo.com (Postfix) with ESMTPSA id CB66D2C05D9; Mon, 18 Mar 2019 18:37:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.info; s=a; t=1552930655; bh=tms+GcaVxu7RbbDfWTG1aHioj8y3FdIe3NueBiBa1Xg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=C5qE0zJSgiJr63QBg1XfMYgeGI5LqD5KMklf16LFBBBhnXS7SF1xk0YGk64sDGwDa eGe0OW7J2y5lZqyBVpka74I/6fYDVkgOIeR1S940uFFu1VdUsOIUKPvvgFWzRhopuU AFJ235isrUr4MicryI0FEPerl1B0ha/yDHWScMNY= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 18 Mar 2019 18:37:34 +0100 From: Damien Clochard To: Christoph Berg Cc: pgsql-gui-dev@lists.postgresql.org Subject: Re: Export the CREATE TABLE command in pure SQL In-Reply-To: <20190318151017.GE3087@msg.df7cb.de> References: <2bc470194b4837c1f733a4e05f569bc6@dalibo.info> <20190318151017.GE3087@msg.df7cb.de> Message-ID: <303d6ac0fd3feef40b41da944909ef12@dalibo.info> X-Sender: damien@dalibo.info User-Agent: Roundcube Webmail/1.3.8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Le 18.03.2019 16:10, Christoph Berg a écrit : > Re: Damien Clochard 2019-03-17 > <2bc470194b4837c1f733a4e05f569bc6@dalibo.info> >> How do you guys deal with this ? It seems that a lot of GUI tools are >> able >> to "export the table structure".... Is there an extension somewhere to >> do >> that ? Is it possible to write i in pure SQL ? If yes, there anybody >> here >> interested in joining forces to build a shared export function ? > > IMHO the cleanest way would be to move all of that into the server. > There are already functions like pg_getindexdef() which pg_dump can > (could?) use. But of course that won't fix the problem for existing PG > versions. > Hi Christoph ! This was also my first thought. MySQL has a nice "SHOW CREATE TABLE" command and it seems to me that putting this code on the server would be a benefit for any GUI tools that tries to export tables structure and probably also for schema versionning tools. https://dev.mysql.com/doc/refman/8.0/en/show-create-table.html I looked at the pg_dump code and tried to build a C extension that would include the dumputils.h header file. But pg_dump is a client-side tool, so parts of this code would have to be moved to the server-side. I don't have the time and knowledge to propose a patch like that by myself. But if someone is interested, I can help... > For a medium-term solution, a plpgsql extension (or the client-side > equivalent) seems like the best way. > Agreed. Thanks for your answer -- Damien Clochard