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 1h69Is-0004JU-C6 for pgsql-gui-dev@arkaria.postgresql.org; Tue, 19 Mar 2019 07:36:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h69Ir-0001uM-0d for pgsql-gui-dev@arkaria.postgresql.org; Tue, 19 Mar 2019 07:36:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h69Hf-0007Eu-Pt for pgsql-gui-dev@lists.postgresql.org; Tue, 19 Mar 2019 07:35:39 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h69Hd-0005Tq-6t for pgsql-gui-dev@lists.postgresql.org; Tue, 19 Mar 2019 07:35:38 +0000 Received: by mail-ed1-x541.google.com with SMTP id q14so83875edr.5 for ; Tue, 19 Mar 2019 00:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C97amyi+HpxOCFOu3X+G7xfYthWbfgFWE3TbRrL6uF4=; b=YotConXUcLe7tfsooUuEcyHGidzGigwHuxUeA/8LQRQ7o/BvTB5Eub7IYB57a/pjf9 1mn6R+SjuTDt0OAaFS1mFwRgGUIsrHl14lPFLSNQUkIMOH51P6gZ+jJZs+ucD0wRq+3T ldjy2Azh2boGPx7og5Fc7l3JSAYUg370tz08CWfsrEopBkefu6/1s4kx+HeI5GwQYR1E OtgkLrSxzBhLaoamk9Ab7jI4ElqapoMdDz2p8VpqkaEPmfOWB3jnqLVO2QgzX3SaiIwQ S+vcgukGDVpYQXxoautkPRrZopSlUi+05PowY4n0j8clyz6jSUne3HBOAr9bHIv2YnkX PwVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C97amyi+HpxOCFOu3X+G7xfYthWbfgFWE3TbRrL6uF4=; b=k8b0izHEKpsHNc9xFF9eLjYQdh55A6kcWEVJAOB0griRXJt0jI2sSZ3ISN6TDWNSjR chhjgPIlLLnc8zV+1vv0TlSsCEWZk73Fo7heP53tb7eZZacQrL+qcBln+mA4tftOjxzN z4jfI/jDhGnZa7RH/OktzV9ukmRShQ/E/IX2cgss70YoBmPRs1AXYfbsWlbahqy71Tr2 tjiPWyEg7L5MlBerjULSvo5/LX3uDdkDexe5DqV6irFX4soPZQzpbPdCBq9ebV5RPMYu 0bOBAG/qBD0bmyymMxYlZy6xcroVF5Kw1nJfBl+3m6c6K2qSD4YiPk1BP0ZtfUF/QyAr yuOg== X-Gm-Message-State: APjAAAVf89p4ATsW35uQDn5n6LAOT/p/7iEYKl2JR9AOuTocIqEVYUl0 VzhQzEFeHozgGHk+rfQ8u8NpuwFGMXc2Jq6jVU0= X-Google-Smtp-Source: APXvYqz9EVcJ+xrEjqoSziVhQg9CxHGdFyHCNe/QPtGIakhzqhOBHx3YfzYzf1qB/dtD4wNDP/9EtI5YzK3W2Ne99YE= X-Received: by 2002:a50:b3bc:: with SMTP id s57mr15478913edd.206.1552980935499; Tue, 19 Mar 2019 00:35:35 -0700 (PDT) MIME-Version: 1.0 References: <2bc470194b4837c1f733a4e05f569bc6@dalibo.info> <20190318151017.GE3087@msg.df7cb.de> <303d6ac0fd3feef40b41da944909ef12@dalibo.info> <20190319030038.GN6197@tamriel.snowman.net> In-Reply-To: <20190319030038.GN6197@tamriel.snowman.net> From: Brice Maron Date: Tue, 19 Mar 2019 08:35:24 +0100 Message-ID: Subject: Re: Export the CREATE TABLE command in pure SQL To: Stephen Frost Cc: Damien Clochard , Christoph Berg , pgsql-gui-dev@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000000e44705846d8d7b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000000e44705846d8d7b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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) On Tue, Mar 19, 2019 at 4:00 AM Stephen Frost wrote: > Greetings, > > * Damien Clochard (damien@dalibo.info) wrote: > > Le 18.03.2019 16:10, Christoph Berg a =C3=A9crit : > > >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 t= o > > >>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 al= so > > 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 woul= d > > 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. > > > > 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 > --00000000000000e44705846d8d7b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,=C2=A0
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=C2=A0
defeat the = purpose ...=C2=A0
if we can come up with something as easy as sho= w create table , if would be very nice ( can even be usefull for psql users= , in combination with other \... commands)



On Tue, Mar 19, 2019 at 4:00 AM Stephen Frost <sfrost@snowman.net> wrote:
Greetings,

* Damien Clochard (= damien@dalibo.info) wrote:
> Le 18.03.2019 16:10, Christoph Berg a =C3=A9crit=C2=A0:
> >Re: Damien Clochard 2019-03-17
> ><2bc470194b4837c1f733a4e05f569bc6@dalibo.info> > >>How do you guys deal with this ? It seems that a lot of GUI to= ols are
> >>able
> >>to "export the table structure".... Is there an exte= nsion somewhere to
> >>do
> >>that ? Is it possible to write i in pure SQL ? If yes, there a= nybody
> >>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 ca= n
> >(could?) use. But of course that won't fix the problem for exi= sting PG
> >versions.
>
> This was also my first thought. MySQL has a nice "SHOW CREATE TAB= LE" command
> and it seems to me that putting this code on the server would be a ben= efit
> for any GUI tools that tries to export tables structure and probably a= lso
> 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 wou= ld
> 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= 9;t have
> the time and knowledge to propose a patch like that by myself. But if<= br> > 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..<= br>
> >For a medium-term solution, a plpgsql extension (or the client-sid= e
> >equivalent) seems like the best way.
>
> Agreed.

I'm a bit concerned that we'd end up with differences between pg_du= mp
and this extension eventually...=C2=A0 I guess my thought would be to try a= nd
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
--00000000000000e44705846d8d7b--