Re: in-catalog Extension Scripts and Control parameters (templates?) - Mailing list pgsql-hackers

From Jaime Casanova
Subject Re: in-catalog Extension Scripts and Control parameters (templates?)
Date
Msg-id CAJKUy5iE_tp+3-66P74tLXZrfA=G9v2Y+JKGBp+T2o7CrexEWg@mail.gmail.com
Whole thread Raw
In response to Re: in-catalog Extension Scripts and Control parameters (templates?)  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
Responses Re: in-catalog Extension Scripts and Control parameters (templates?)
List pgsql-hackers
On Mon, Jun 24, 2013 at 6:20 AM, Dimitri Fontaine
<dimitri@2ndquadrant.fr> wrote:
> Jaime Casanova <jaime@2ndquadrant.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
withOID %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)
returnsint 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)
returnsint as $_$ select 1; $_$ 
language sql;
$$;
CREATE TEMPLATE FOR EXTENSION

create extension test version '123';
CREATE EXTENSION

postgres=# \df                      List of functionsSchema | 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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Support for REINDEX CONCURRENTLY
Next
From: Jaime Casanova
Date:
Subject: Re: in-catalog Extension Scripts and Control parameters (templates?)