Re: How do write schema independent install files for functions.

From: Bartosz Dmytrak <bdmytrak(at)gmail(dot)com>
To: Philip Couling <phil(at)pedal(dot)me(dot)uk>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How do write schema independent install files for functions.
Date: 2012-07-16 19:45:30
Message-ID: CAD8_UcaFYbgVfEgoE-MUFvwYs7VgyGBsOjdP5OfH+VPJVp62MA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2012/7/16 Philip Couling <phil(at)pedal(dot)me(dot)uk>

>
> Is there any more flexible way to do this?
>
> Hi,
in my opinion you should use fully qualified names instead of set
search_path
Your script should look like this:

CREATE OR REPLACE FUNCTION my_schema.foo()
RETURNS INTEGER AS
$BODY$
BEGIN
RETURN 42;
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE
COST 100;

CREATE OR REPLACE FUNCTION another_schema.bar()
RETURNS INTEGER AS
$BODY$
BEGIN
RETURN my_schema.foo();
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE
COST 100;

then script is readable and uses full qualified names.
http://www.postgresql.org/docs/9.1/static/ddl-schemas.html#sql-createschema.html

Regards,
Bartek

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Philip Couling 2012-07-16 19:49:57 Re: How do write schema independent install files for functions.
Previous Message Tom Lane 2012-07-16 19:44:08 Re: How do write schema independent install files for functions.