Re: when does a function name get mapped to an OID?

From: Darren Ferguson <darren(at)crystalballinc(dot)com>
To: Fran Fabrizio <ffabrizio(at)mmrd(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: when does a function name get mapped to an OID?
Date: 2002-04-23 18:24:17
Message-ID: Pine.LNX.4.10.10204231422210.7360-100000@thread.crystalballinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 23 Apr 2002, Fran Fabrizio wrote:

>
> If this is answered in the docs I apologize, I've been looking around
> without much success.
>
> I am trying to bring order to our schema loading process. We have about
> a dozen files with functions, triggers and views defined in them and
> some of them depend on functions declared on other files, etc...so in
> the past we've had situations where we unload and reload one of the
> files and that breaks something that was depending on the contents of
> the reloaded file (i.e. fmgr_info: 12343567 cache lookup failed
> messages). So, I'm making a bit more of a sane system to make sure
> things get loaded and reloaded in the right order.
>
> I was noticing that within one of the files, something like this is
> declared:
>
> drop function bar();
> drop function foo();
> create function foo() returns int4 as '
> select bar();
> ' language 'sql';
> create function bar() returns int4 as '
> select 1234;
> ' language 'sql';
>
> This loads into the db just fine. Which got me to thinking, shouldn't
> the loading of foo() throw an error since at that time bar() does not
> exist?

This will throw an error if you try and run foo() before you create bar().
But from my experience the function is compiled when it is first run a
plan created. It is not compiled at creation time.

> So my best guess is that function names don't get mapped to OIDs
> until first actual use. Is this correct? It would save me trouble if
> so since I wouldn't have to worry about the order in which they are
> loaded so much as to ensure that if anything is REloaded, that any
> dependencies are also reloaded.
>
> Thanks,
> Fran
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

HTH

Darren Ferguson

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-04-23 18:30:09 Re: when does a function name get mapped to an OID?
Previous Message Fran Fabrizio 2002-04-23 18:06:14 when does a function name get mapped to an OID?