Re: interval / interval -> double operator - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: interval / interval -> double operator
Date
Msg-id 20070530002328.GK11630@alvh.no-ip.org
Whole thread Raw
In response to Re: interval / interval -> double operator  ("Andrew Hammond" <andrew.george.hammond@gmail.com>)
Responses Re: interval / interval -> double operator
List pgsql-hackers
Andrew Hammond escribió:

> Ok, I've been hunting through src/backend to try and find the code for
> EXTRACT(epoch ...). I found EXTRACT in src/backend/parser/gram.y, which
> seems like a reasonable place to start.
> 
>  | EXTRACT '(' extract_list ')'
>      {
>          FuncCall *n = makeNode(FuncCall);
>          n->funcname = SystemFuncName("date_part");
>          n->args = $3;
>          n->agg_star = FALSE;
>          n->agg_distinct = FALSE;
>          n->location = @1;
>          $$ = (Node *)n;
>     }
> 
> Which got me looking for "date_part". But that only seems to be in the
> gram.y file, include/catalog/pg_proc.h and the test suite. The pg_proc.h
> stuff looks pretty interesting, but to decipher it, I figured I need to read
> up on SystemFuncName().

That's where you got lost -- if you had looked at the pg_proc.h entries
more carefully you would have seen that they point to other functions,
like timestamptz_part and friends.  You can find them on timestamp.c,
etc.  The key is knowing that the pg_proc.h entry maps from a SQL
function name into a C function name.

-- 
Alvaro Herrera                 http://www.amazon.com/gp/registry/DXLWNGRJD34J
"La naturaleza, tan frágil, tan expuesta a la muerte... y tan viva"


pgsql-hackers by date:

Previous
From: "Jaime Casanova"
Date:
Subject: Re: Reviewing temp_tablespaces GUC patch
Next
From: Wang Haiyong
Date:
Subject: Re: Help! DLL make faild under windows mingw.