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 1h64zd-0005vU-0u for pgsql-gui-dev@arkaria.postgresql.org; Tue, 19 Mar 2019 03:00:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h64zb-0002Rw-PA for pgsql-gui-dev@arkaria.postgresql.org; Tue, 19 Mar 2019 03:00:43 +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 1h64zb-0002Rb-Jk for pgsql-gui-dev@lists.postgresql.org; Tue, 19 Mar 2019 03:00:43 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h64zY-0005pc-98 for pgsql-gui-dev@lists.postgresql.org; Tue, 19 Mar 2019 03:00:43 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 10D245F79F; Mon, 18 Mar 2019 23:00:39 -0400 (EDT) Date: Mon, 18 Mar 2019 23:00:38 -0400 From: Stephen Frost To: Damien Clochard Cc: Christoph Berg , pgsql-gui-dev@lists.postgresql.org Subject: Re: Export the CREATE TABLE command in pure SQL Message-ID: <20190319030038.GN6197@tamriel.snowman.net> References: <2bc470194b4837c1f733a4e05f569bc6@dalibo.info> <20190318151017.GE3087@msg.df7cb.de> <303d6ac0fd3feef40b41da944909ef12@dalibo.info> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7mGQMtC7ORh9TbWy" Content-Disposition: inline In-Reply-To: <303d6ac0fd3feef40b41da944909ef12@dalibo.info> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --7mGQMtC7ORh9TbWy Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Damien Clochard (damien@dalibo.info) wrote: > Le 18.03.2019 16:10, Christoph Berg a =E9crit=A0: > >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. >=20 > This was also my first thought. MySQL has a nice "SHOW CREATE TABLE" comm= and > 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. >=20 > https://dev.mysql.com/doc/refman/8.0/en/show-create-table.html >=20 > 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... I think the right answer here would be to try and move the code for this into the libpgcommon library but I'm not sure how easy that would be.. > >For a medium-term solution, a plpgsql extension (or the client-side > >equivalent) seems like the best way. >=20 > Agreed. I'm a bit concerned that we'd end up with differences between pg_dump and this extension eventually... I guess my thought would be to try and build something into the server for this and use that for future PG versions, and then back-port things into another library for older versions or something. Thanks! Stephen --7mGQMtC7ORh9TbWy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJckFtWAAoJEO1sijiDR2RVG1QP/iBNmWQvwO+T3qmblV1aLWrA o4B+2mT/HMhz4tUg8HicIoYyWvG1MYQq44+h/5vDZvFh8I7Gv7NPnJy65vxIoMwO 0Cm2TC6mPIPSjX9z5FBxCOhVyXdTXDVZ//WDaSySWd8CTmlwph7njZrrnzt9oRwd nHvlR3u34ExMm+z9Hhd3iJDfhwnU4bzmyqhGrlXLK0THxVFWEEWaa6dsR8W1QiMP cFgrcDxUUH3YvH7zHFXHMGYZ0FhbO6yjN3Nwg/ugs4VhNFaZevqsP2+CKHVGFkfn Ylv/SdJNNZsV+hNhK6Kcvdc40VJUuRxzeiex3Ob3tbUklBItOyxOcxHDwVR/rCay Y7R5jZ0s7CpDoitwthjHPlP4Edms6MvhDwgHxpFIJI5ttoqN7vYAxaWequAKFGTK 27AzDAau5hFzmtFSV2JiuhvlcYTm/d+7DJR3WGU4XdsZrjlbrx7PPeOlLRZLzy3D iBAYhYpSXr+lyXfNLVFKmQBKTvYm9bOuTWVoQm6seK3JFvlLo/xAt1LmPT/+B6qf E3xzNAX8/1i+hw1FPfm2QyE8k2RJk7x5zD/YP8T5mu7Ot3+WC2vzY5TAgZ9rxWgA VpL7va8TqeCiOl8JFvhUem/UaGZrGoNrcOL5ReyGVpBhIPq73YhbU586feD2cwdh KYkmSwzjIITSAc90i/hy =ttku -----END PGP SIGNATURE----- --7mGQMtC7ORh9TbWy--