
It seems some code disappeared from pg_dump.c between 7.0.2 and current, I
think in the following revisions:

revision 1.148
date: 2000/05/28 20:34:52;  author: tgl;  state: Exp;  lines: +21 -42
Miscellaneous cleanups of places that needed to account for new
pg_language entries.
----------------------------
revision 1.147
date: 2000/04/14 01:34:24;  author: tgl;  state: Exp;  lines: +2 -2
Another static-vs-not-static error.

The code is:

...in dumpOneFunc....

    if (finfo[i].dumped)
        return;
    else
        finfo[i].dumped = 1;

    /* becomeUser(fout, finfo[i].usename); */

    if (finfo[i].lang == INTERNALlanguageId)
    {
        func_def = finfo[i].prosrc;
        strcpy(func_lang, "INTERNAL");
    }
    else if (finfo[i].lang == ClanguageId)
    {
        func_def = finfo[i].probin;
        strcpy(func_lang, "C");
    }
    else if (finfo[i].lang == SQLlanguageId)
    {
        func_def = finfo[i].prosrc;
        strcpy(func_lang, "SQL");
    }
    else
    {

and without this code, the dumps for plpgsql call handlers do not work (at
least for me). It may be that I have messed something up in the code, but I
don't think so.

Any light you can shed on this would be great.

P.S. The specific problem is that it now uses plsrc as the definition for
all functions, whereas the (C language) plpgsql call handler requires plbin
to be used.


----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/

Sun, 09 Jul 2000 20:50:07 +1000
Philip Warner <pjw@rhyme.com.au>
C language function dump problem
Philip Warner <pjw@rhyme.com.au> writes:
> It seems some code disappeared from pg_dump.c between 7.0.2 and current,
> ...
> P.S. The specific problem is that it now uses plsrc as the definition for
> all functions, whereas the (C language) plpgsql call handler requires plbin
> to be used.

Looks like I broke it :-(.  Didn't read the code carefully enough,
I guess, and thought that the selection of language name was the only
useful thing it was accomplishing.  So I figured the default path would
handle all cases just as easily.

Now that I think about it, the code was actually broken before that,
because for a C-language function it needs to produce two AS items
specifying the link symbol and the library path.  Looks like we
neglected to update pg_dump when that feature was added.

Basically you need to make pg_dump do the inverse of
interpret_AS_clause() in src/backend/commands/define.c.  Note that
there are now two OIDs that need to be handled this way, ClanguageId
and NEWClanguageId.

			regards, tom lane

Sun, 09 Jul 2000 13:25:43 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: C language function dump problem 
At 13:25 9/07/00 -0400, Tom Lane wrote:
>Philip Warner <pjw@rhyme.com.au> writes:
>> It seems some code disappeared from pg_dump.c between 7.0.2 and current,
>> ...
>> P.S. The specific problem is that it now uses plsrc as the definition for
>> all functions, whereas the (C language) plpgsql call handler requires plbin
>> to be used.
>
>Now that I think about it, the code was actually broken before that,
>because for a C-language function it needs to produce two AS items
>specifying the link symbol and the library path.  Looks like we
>neglected to update pg_dump when that feature was added.
>

Looking at the code, it *seems* that I should be able to (in pseudo-code):

if ( finfo[i].probin != "-")
    defn = defn || "AS " || finfo[i].probin;

if ( finfo[i].prosrc != "-")
    defn = defn || "AS " || finfo[i].prosrc;

ie. Use probin is it is not "-", and use prosrc if it is not "-".

This gets around hard coding for C & newC, so reduces the chance of
problems in the future...I think. 

Does that sound reasonable to everyone?



----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/

Mon, 10 Jul 2000 10:38:30 +1000
Philip Warner <pjw@rhyme.com.au>
Re: Re: C language function dump problem 
Philip Warner <pjw@rhyme.com.au> writes:
> Looking at the code, it *seems* that I should be able to (in pseudo-code):

> if ( finfo[i].probin != "-")
>     defn = defn || "AS " || finfo[i].probin;

> if ( finfo[i].prosrc != "-")
>     defn = defn || "AS " || finfo[i].prosrc;

Not quite; I think the correct syntax for C functions is

	AS 'probin', 'prosrc'

Also I'm not real sure that the unused field will be "-" for all the
other languages --- but if that's true you could make it work.  Not
hardwiring the language OIDs would definitely be a Good Thing.

			regards, tom lane

Sun, 09 Jul 2000 21:13:19 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Re: C language function dump problem 
At 21:13 9/07/00 -0400, Tom Lane wrote:
>
>Also I'm not real sure that the unused field will be "-" for all the
>other languages --- but if that's true you could make it work.  Not
>hardwiring the language OIDs would definitely be a Good Thing.
>

Done. In backend/commands/define.c unused field is set to '-' for the moment.

A patch for CVS is attached, and I have amended my BLOB dumping version
appropriately.




----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/
Mon, 10 Jul 2000 12:05:23 +1000
Philip Warner <pjw@rhyme.com.au>
Re: Re: C language function dump problem 
I take it back.  I did have this.  I was looking for pg_dump in the
subject.  Searching for Warner, I found it.  Sorry for the confusion. 
Applied.

> At 21:13 9/07/00 -0400, Tom Lane wrote:
> >
> >Also I'm not real sure that the unused field will be "-" for all the
> >other languages --- but if that's true you could make it work.  Not
> >hardwiring the language OIDs would definitely be a Good Thing.
> >
> 
> Done. In backend/commands/define.c unused field is set to '-' for the moment.
> 
> A patch for CVS is attached, and I have amended my BLOB dumping version
> appropriately.
> 

[ Attachment, skipping... ]

> 
> ----------------------------------------------------------------
> Philip Warner                    |     __---_____
> Albatross Consulting Pty. Ltd.   |----/       -  \
> (A.C.N. 008 659 498)             |          /(@)   ______---_
> Tel: (+61) 0500 83 82 81         |                 _________  \
> Fax: (+61) 0500 83 82 82         |                 ___________ |
> Http://www.rhyme.com.au          |                /           \|
>                                  |    --________--
> PGP key available upon request,  |  /
> and from pgp5.ai.mit.edu:11371   |/


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 11 Jul 2000 10:45:14 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Re: C language function dump problem