pg_get_tabledef

From: "Usama Munir" <usama(dot)munir(at)enterprisedb(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_get_tabledef
Date: 2007-05-21 13:20:48
Message-ID: 46519CB0.2080609@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, <br>
<br>
i was following a thread some time ago where adding a function <b>pg_get_tabledef</b>
was one of the TODOs for 8.2, but it somehow didn't make it to the
release perhaps because the functionality was not clearly defined? not
sure.<br>
<br>
Anyway&nbsp; i happen to come up with a function for pg_get_tabledef which
works something like following<br>
<br>
<i>postgres=# select pg_get_tabledef(16388) ;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pg_get_tabledef&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
--------------------------------<br>
&nbsp;CREATE TABLE&nbsp; public.dept<br>
&nbsp;(<br>
&nbsp; deptno numeric(2,0) NOT NULL,<br>
&nbsp; dname&nbsp; character varying(14),<br>
&nbsp; loc&nbsp;&nbsp;&nbsp; character varying(13)<br>
&nbsp;)<br>
&nbsp;WITHOUT OIDS;<br>
</i>(1 row)<br>
<br>
<br>
<br>
i wanted to submit a patch for this, IFF the community wants this
function. The rationale is obviously to help Application developers
writing applications like pgAdmin. Currently this part of SQL needs to
be constructed manually for postgres by the tools.<br>
<br>
it is arguable that a table defintion will have constraints , triggers
etc as well, and they can be added without much problem, but i think if
a tool needs to construct an SQL for all table related objects then
functions are already available for them like pg_get_constraintdef,
pg_get_ruledef, pg_get_indexdef, pg_get_triggerdef etc<br>
<br>
i understand that you guys don't like someone to develop a patch in
isolation and just come up with it one day, but it really came out as a
by-product of some other work , and i thought you guys might be
interested in it.<br>
<br>
if it is desired,&nbsp; i will submit&nbsp; a patch for it, within a day or so.<br>
<br>
Regards,<br>
Usama Munir<br>
EnterpriseDB (<a class="moz-txt-link-abbreviated" href="http://www.enterprisedb.com">www.enterprisedb.com</a>)<br>
<br>
<br>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-05-21 13:21:50 Re: Concurrent psql patch
Previous Message Magnus Hagander 2007-05-21 11:18:27 Re: mb and ecpg regression tests