Re: Parser - Query Analyser - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: Parser - Query Analyser
Date
Msg-id 50A8D5E6.2030101@2ndQuadrant.com
Whole thread Raw
In response to Parser - Query Analyser  (Michael Giannakopoulos <miccagiann@gmail.com>)
List pgsql-hackers
On 11/17/2012 10:18 PM, Michael Giannakopoulos wrote:
> Hello guys,
>
> My name is Michail Giannakopoulos and I am a graduate student at
> University of Toronto. I have no previous experience in developing a
> system like postgreSQL before.
>
> What I am trying to explore is if it is possible to extend postgreSQL
> in order to accept queries of the form:
>
> Select function(att1, att2, att3) AS output(out1, out2, ..., outk)
> FROM [database_name];

I think you meant "FROM [table_name]". It certainly seems like it, as
you describe "database_name" as a "relation" a little later.

If you really meant "FROM [database_name]", you're not going to have
much luck. PostgreSQL backends are associated with a single database.
They cannot query across databases without hacks like dblink, which
internally opens a connection to another backend. So you really can't
query "FROM [database_name]", you must connect to a database then issue
queries against it.

If you meant "FROM relation_name": it sounds like you are describing a
stored procedure that returns SETOF RECORD. If so, you can already do
this, though the syntax is a little different. You have to pass the
relation *name* or regclass oid into the procedure, where it builds a
dynamic SQL statement to SELECT from the table and return the result.

Alternately: Are you trying to describe a *row filter function*? Like a
WHERE clause wrapped up in a function?

It would really help if you could show some mock examples of what you're
trying to achieve. Inputs as CREATE TABLE and INSERT statements, mock
output, explanation of how you'd get that output, what problem you're
trying to solve, etc.

-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services




pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Materialized views WIP patch
Next
From: Simon Riggs
Date:
Subject: Re: Do we need so many hint bits?