Re: Adding XMLEXISTS to the grammar

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Adding XMLEXISTS to the grammar
Дата
Msg-id AANLkTildM3RWfIAHHQnwIAUsb16eFP1hsAVmFadTl37d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Adding XMLEXISTS to the grammar  (Mike Fowler <mike@mlfowler.com>)
Ответы [PATCH] Re: Adding XMLEXISTS to the grammar  (Mike Fowler <mike@mlfowler.com>)
Список pgsql-hackers
On Thu, Jun 24, 2010 at 2:37 PM, Mike Fowler <mike@mlfowler.com> wrote:
> Thanks Robert, I've managed to resolve this make making a type cast inside
> gram.y. However, it now seems that the function itself can not be found.
> I've made an entry in pg_proc.h, but when running psql I'm getting the
> following:
>
> xmltest=# SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers'
> PASSING BY REF data);
> ERROR:  function pg_catalog.xml_exists(text, xml) does not exist
> LINE 1: SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers' ...
>                                           ^
> HINT:  No function matches the given name and argument types. You might need
> to add explicit type casts.
>
> In gram.y I've got:
>
> FuncCall *n = makeNode(FuncCall);
> n->funcname = SystemFuncName("xml_exists");
>
> (also tried SystemFuncName("xmlexists");)
>
> In xml.h:
>
> extern bool xml_exists(text *xpath_expr_text, xmltype *data);
>
> I've also tried
>
> bool xml_exists(PG_FUNCTION_ARGS) {
>
> and finally in pg_proc.h I have:
>
> DATA(insert OID = 3037 (  xmlexists     PGNSP PGUID 12 1 0 0 f f f t f i 3 0
> 16 "25 142" _null_ _null_ _null_ _null_ xml_exists _null_ _null_ _null_ ));
> DESCR("evaluate XPath expression in a boolean context");
>
> (also tried ( xml_exists   PGNSP....))
>
> After each attempt, I've blown away the installation, made clean and
> installed, initialised a fresh database and restored my sample database.
> I've had a grep around using position and it's target function textpos as
> examples but I fail to see any other file that they live in other than their
> implementation. As far as I can tell, I'm not doing anything different from
> position. Any thoughts?

It looks like the pg_proc entry is creating an SQL function called
xmlexists referencing a C function called xml_exists, and the gram.y
changes want there to be an SQL function called xml_exists.  I think
you should rip out all the catalog and parser changes for starters,
and just try to get it working as a regular old function.  Once you
have that working, you can add the syntax support back in.  I'd
suggest making the C and SQL function names the same as each other,
but different from the keyword you're planning to use (xmlexists).

As for declaring the function, I believe you want this:

Datum
your_function_name(PG_FUNCTION_ARGS)
{

}

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: EOL for 7.4 and 8.0
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Add TCP keepalive support to libpq.