Re: Parser - Query Analyser

From: Craig Ringer <craig(at)2ndQuadrant(dot)com>
To: Michael Giannakopoulos <miccagiann(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Parser - Query Analyser
Date: 2012-11-18 12:34:46
Message-ID: 50A8D5E6.2030101@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2012-11-18 14:10:23 Re: [GENERAL] Prepared Statement Name Truncation
Previous Message Chris Angelico 2012-11-18 11:48:51 Re: PG_TERMINATE_BACKEND not working.

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2012-11-18 13:52:10 Re: Do we need so many hint bits?
Previous Message Simon Riggs 2012-11-18 11:37:58 Re: Materialized views WIP patch