Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: Scripting f...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 7 Topic 15503 of 16987
Post > Topic >>

Re: Scripting function definitions as SQL?

by singh.gurjeet@[EMAIL PROTECTED] ("Gurjeet Singh") May 12, 2008 at 12:38 PM

------=_Part_2259_28836120.1210576118463
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Mon, May 12, 2008 at 10:57 AM, Reece Hart <reece@[EMAIL PROTECTED]
> wrote:

> On Sun, 2008-05-11 at 06:12 -0700, Postgres User wrote:
> > Has anyone written a function that scripts out all the functions in a
> > database as full SQL statements (Create Function.....)
>
> You could pg_dump the schema in the "custom" format (-Fc), then call
> pg_restore with -l to get the TOC, grep the TOC for functions, and feed
> that back into pg_restore with -L. It sounds like a lot, but it's pretty
> easy in practice, like so:
>
> $ sudo -u postgres pg_dump -Fc -s mydb >mydb.pgdfc
> $ pg_restore -l mydb.pgdfc >mydb.toc
> $ grep -E '^[0-9]+; [0-9]+ [0-9]+ FUNCTION' mydb.toc >mydb-fx.toc
> $ pg_restore -L mydb-fx.toc mydb.pgdfc
>
> The output of pg_restore is sql.
>
> This technique is extremely useful for other kinds of schema elements as
> well.
>
>
It's a bit too much for the task at hand. Recently I was also faced with a
situation where I wanted to dump a few functions (only), but pg_dump does
not have any option to do so!!

Can we have an option to dump function?

Best regards,

-- 
gurjeet[.singh]@[EMAIL PROTECTED]
 gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

------=_Part_2259_28836120.1210576118463
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Mon, May 12, 2008 at 10:57 AM, Reece Hart &lt;<a
href="mailto:reece@[EMAIL PROTECTED]
">reece@[EMAIL PROTECTED]
>&gt; wrote:<br><div
class="gmail_quote"><blockquote class="gmail_quote" style="border-left:
1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;">
<div class="Ih2E3d">On Sun, 2008-05-11 at 06:12 -0700, Postgres User
wrote:<br>
&gt; Has anyone written a function that scripts out all the functions in
a<br>
&gt; database as full SQL statements (Create Function.....)<br>
<br>
</div>You could pg_dump the schema in the &quot;custom&quot; format (-Fc),
then call<br>
pg_restore with -l to get the TOC, grep the TOC for functions, and
feed<br>
that back into pg_restore with -L. It sounds like a lot, but it&#39;s
pretty<br>
easy in practice, like so:<br>
<br>
$ sudo -u postgres pg_dump -Fc -s mydb &gt;mydb.pgdfc<br>
$ pg_restore -l mydb.pgdfc &gt;mydb.toc<br>
$ grep -E &#39;^[0-9]+; [0-9]+ [0-9]+ FUNCTION&#39; mydb.toc
&gt;mydb-fx.toc<br>
$ pg_restore -L mydb-fx.toc mydb.pgdfc<br>
<br>
The output of pg_restore is sql.<br>
<br>
This technique is extremely useful for other kinds of schema elements
as<br>
well.<br>
<br></blockquote></div><br>It&#39;s a bit too much for the task at hand.
Recently I was also faced with a situation where I wanted to dump a few
functions (only), but pg_dump does not have any option to do
so!!<br><br>Can we have an option to dump function?<br>
<br>Best regards,<br><br>--
<br>gurjeet[.singh]@[EMAIL PROTECTED]
>singh.gurjeet@[EMAIL PROTECTED]
 gmail | hotmail |
indiatimes | yahoo }.com<br><br>EnterpriseDB <a
href="http://www.enterprisedb.com">http://www.enterprisedb.com</a><br><br>
Mail sent from my BlackLaptop device

------=_Part_2259_28836120.1210576118463--
 




 7 Posts in Topic:
Scripting function definitions as SQL?
postgres.developer@[EMAIL  2008-05-11 06:12:40 
Re: Scripting function definitions as SQL?
kleptog@[EMAIL PROTECTED]  2008-05-11 15:49:37 
Re: Scripting function definitions as SQL?
postgres.developer@[EMAIL  2008-05-11 11:28:37 
Re: Scripting function definitions as SQL?
depesz@[EMAIL PROTECTED]   2008-05-11 20:43:25 
Re: Scripting function definitions as SQL?
postgres.developer@[EMAIL  2008-05-11 12:08:36 
Re: Scripting function definitions as SQL?
reece@[EMAIL PROTECTED]   2008-05-11 22:27:51 
Re: Scripting function definitions as SQL?
singh.gurjeet@[EMAIL PROT  2008-05-12 12:38:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 10:13:46 CDT 2008.