psql: \edit-function - Mailing list pgsql-hackers

From Abhijit Menon-Sen
Subject psql: \edit-function
Date
Msg-id 20080616020121.GA18941@toroid.org
Whole thread Raw
Responses Re: psql: \edit-function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi.

I'm working on a patch where if you say "\ef foo" in psql, it'll start
$EDITOR with a "CREATE OR REPLACE FUNCTION" statement to recreate the
function. So you edit and save and quit, and if you made any changes,
psql will execute the statement.

The psql(/command.c) parts of this are quite simple. I've attached a
patch to demonstrate the idea.

The problem is, of course, generating the "CREATE OR REPLACE" statement.
There is some code to do this in pg_dump.c:dumpFunc(), but it's strongly
tied to pg_dump (global variables, output to Archive *, dependencies on
other functions, etc.).

I could either try to duplicate this code (and there's a lot of it), or
rip dumpFunc() and its dependencies out of pg_dump into dumpfunc.c and
make it callable both by pg_dump and psql. I've done some work towards
the latter, so I know it's possible, but it's a lot of work, which I
don't want to do if it won't be accepted anyway.

I would appreciate some advice on how to proceed.

-- ams

Attachment

pgsql-hackers by date:

Previous
From: ITAGAKI Takahiro
Date:
Subject: Re: pg_stat_statements
Next
From: ITAGAKI Takahiro
Date:
Subject: Re: pg_stat_statements