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 1h6AQL-0001HP-4J for pgsql-gui-dev@arkaria.postgresql.org; Tue, 19 Mar 2019 08:48:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h6AQJ-0005u7-AP for pgsql-gui-dev@arkaria.postgresql.org; Tue, 19 Mar 2019 08:48:39 +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 1h6AQJ-0005u0-5C for pgsql-gui-dev@lists.postgresql.org; Tue, 19 Mar 2019 08:48:39 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h6AQG-0005HQ-Li for pgsql-gui-dev@lists.postgresql.org; Tue, 19 Mar 2019 08:48:38 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id BA9505F79F; Tue, 19 Mar 2019 04:48:34 -0400 (EDT) Date: Tue, 19 Mar 2019 04:48:34 -0400 From: Stephen Frost To: Brice Maron Cc: Damien Clochard , Christoph Berg , pgsql-gui-dev@lists.postgresql.org Subject: Re: Export the CREATE TABLE command in pure SQL Message-ID: <20190319084834.GR6197@tamriel.snowman.net> References: <2bc470194b4837c1f733a4e05f569bc6@dalibo.info> <20190318151017.GE3087@msg.df7cb.de> <303d6ac0fd3feef40b41da944909ef12@dalibo.info> <20190319030038.GN6197@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="acCIYfrzR/XZtXk6" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --acCIYfrzR/XZtXk6 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, One issue that might be useful to discuss on this list... Is there really just one API that makes sense here and would be sufficient? It seems to me that tools like pgAdmin actually need to pull out the structure of the table itself in individual pieces and such- a backend command that just returned the full CREATE TABLE wouldn't actually help that tool much. I do think that psql users might like such an option, but for most of them, running pg_dump isn't likely to be an issue, and it would also be that we could implement this client-side instead of having to have it in both the client and server.. Thoughts? Thanks! Stephen * Brice Maron (bmaron@gmail.com) wrote: > Hi, > i've tried a few time to implement this feature and look how other clients > do but it often (always?) ends up beeing completely buggy or incomplete > which of course > defeat the purpose ... > if we can come up with something as easy as show create table , if would = be > very nice ( can even be usefull for psql users , in combination with other > \... commands) >=20 >=20 >=20 > On Tue, Mar 19, 2019 at 4:00 AM Stephen Frost wrote: >=20 > > Greetings, > > > > * Damien Clochard (damien@dalibo.info) wrote: > > > Le 18.03.2019 16:10, Christoph Berg a =E9crit : > > > >Re: Damien Clochard 2019-03-17 > > > ><2bc470194b4837c1f733a4e05f569bc6@dalibo.info> > > > >>How do you guys deal with this ? It seems that a lot of GUI tools a= re > > > >>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. > > > > > > 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 wo= uld > > > include the dumputils.h header file. But pg_dump is a client-side too= l, > > 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. > > > > > > 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 > > --acCIYfrzR/XZtXk6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJckKziAAoJEO1sijiDR2RV4Y0QAK8hb1yQ+3VNM5/e44Q/1vLO /Md00XwFrOSbfjkBhLIQdcHHGqZmWNm0OIgNKZPr5cJWASaLwPuDQD6R9qYJWWgs Qa8/EXWK+jYI5VeLJIVRMVyPy6dyOxMu0BNZ3eZ7dcqEbS566y5AnvwUlySz/FI4 6z3Cl9mkleXsPIkZhJa1V78Bighd1XYE5C5RhpKyWlfcqvqXiqredHwIWy125ZU1 Q+czgFk3VlZLmZ1//PCeROqfG4a6RpJMMuNGJF9UfDn354U2J4psOpjjZfvg5RMH utXly0BSXE6OkHkUd/JpOfoQ6rjhbTr/Qm3V0Ebk9YdhcvQ4s/xLDaE1L4WGOCJo 3u3jFeySIJXFBC2UTyJdEpbbt2zWcBtOSEQXr6vFMmR4I7UH+DpcaILB0EYt1197 Fwzs9iZWZlqtqpu5DK7qRMN0yTDoZLHFCnC54NGCgtOJgkH/WvbiiWrNMOaO61Pk YGMxo6NISYLYlKk6SZwRSmEnSPoDYMkKRLXktuuVt4vDf3Wj7OfmoyOFL+m8xvKo 3m8+uiPueC3uVARJZ1U44JwDjt62vYoS0Js3FsgeqTT9FP+sthziCqPiNtyz7QZb aHSsXMWg0PWnsStVlnJn9I2KJefzrjcMhgOYNWgL2YkghmjwaaLR4ZQeF5daT8uP 4rv0E9BXjgN6MmIxDsIz =EBpR -----END PGP SIGNATURE----- --acCIYfrzR/XZtXk6--