Re: in-catalog Extension Scripts and Control parameters (templates?)

From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: in-catalog Extension Scripts and Control parameters (templates?)
Date: 2013-07-04 07:42:50
Message-ID: CAJKUy5iE_tp+3-66P74tLXZrfA=G9v2Y+JKGBp+T2o7CrexEWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 24, 2013 at 6:20 AM, Dimitri Fontaine
<dimitri(at)2ndquadrant(dot)fr> wrote:
> Jaime Casanova <jaime(at)2ndquadrant(dot)com> writes:
>> just tried to build this one, but it doesn't apply cleanly anymore...
>> specially the ColId_or_Sconst contruct in gram.y
>
> Please find attached a new version of the patch, v7, rebased to current
> master tree and with some more cleanup. I've been using the new grammar
> entry NonReservedWord_or_Sconst, I'm not sure about that.
>

Hi,

code review (haven't read all the code)
============================

- The error message in aclchk.c:5175 isn't very clear, i mean the user
should see something better than "uptmpl"
"""
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("extension uptmpl with OID %u does not exist",
ext_uptmpl_oid)));
"""

- In alter.c you made AlterObjectRename_internal non static and
replaced a SearchSysCache1 call with a get_catalog_object_by_oid one.
Now, in its comment that function says that is for simple cases. And
because of the things you're doing it seems to me this isn't a simple
case. Maybe instead of modifying it you should create other function
RenameExtensionTemplateInternal, just like tablecmd.c does?

btw, get_catalog_object_by_oid will execute a SearchSysCacheCopy1 so
should be calling heap_freetuple(oldtuple)

- This is a typo i guess: AtlerExtensionTemplateRename

- In event_triggers.c, it seems the intention was to keep the
event_trigger_support array in order, any reason to for not doing it?

- extension.c: In function ‘get_ext_ver_list_from_catalog’:
extension.c:1150:25: warning: variable ‘evi’ set but not used
[-Wunused-but-set-variable]

Functionality
===========

i tried this:

create template for extension test version 'abc' with (nosuperuser) as $$
create function f1(i int) returns int as $_$ select 1; $_$
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

create template for extension test from 'abc' to 'xyz' with (nosuperuser) as $$
create function f2(i int) returns int as $_$ select 1; $_$
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

create template for extension test from 'xyz' to '123' with (nosuperuser) as $$
create function f3(i int) returns int as $_$ select 1; $_$
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

create extension test version '123';
CREATE EXTENSION

postgres=# \df
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+------+------------------+---------------------+------
(0 rows)

Actually, what this did was to create an 123 schema and it puts the
functions there.

But that schema is inaccesible and undroppable:

select * from "123".f1(1);
ERROR: schema "123" does not exist

drop schema "123";
ERROR: schema "123" does not exist

----------------------------------------------------------

postgres=# create template for extension test2 version '1.0' with
(nosuperuser) as $$
create function f1(i int) returns int as $_$ select 1; $_$
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

postgres=# create template for extension test2 from '1.0' to '1.1'
with (nosuperuser) as $$
create function f2(i int) returns int as $_$ select 1; $_$
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

postgres=# create template for extension test2 from '1.0' to '2.1'
with (nosuperuser) as $$
create function f3(i int) returns int as $_$ select 1; $_$
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

postgres=# create extension test2 version '2.1';
CREATE EXTENSION

In this case only f1() and f3() exists, because the extension is going
from 1.0 to 2.1. is this expected?
and, yes... the functions are in the schema "2.1"

--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación
Phone: +593 4 5107566 Cell: +593 987171157

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jaime Casanova 2013-07-04 07:46:22 Re: in-catalog Extension Scripts and Control parameters (templates?)
Previous Message Michael Paquier 2013-07-04 06:38:23 Re: Support for REINDEX CONCURRENTLY