Creating a read/write virtual table? - Mailing list pgsql-general

From Ben Martin
Subject Creating a read/write virtual table?
Date
Msg-id 1271043246.23273.101.camel@sam.localdomain
Whole thread Raw
Responses Re: Creating a read/write virtual table?
List pgsql-general
Hi,
  I'm the author of the libferris virtual filesystem. Last year I
created the ability to expose a ferris filesystem as a virtual table in
SQLite [1] and would like to do much the same for PostgreSQL if
possible.

  I was digging into where to get the whole libferris-as-vtable thing to
happen with pg:
http://www.postgresql.org/docs/8.4/static/xfunc-c.html
it strikes me that in the returning sets part:
http://www.postgresql.org/docs/8.4/static/xfunc-c.html#XFUNC-C-RETURN-SET
I might be able to prod the tupledesc that is generated by
get_call_result_type() to work out what should be returned.

There are two major drawbacks to this approach:
1) This is run as the postgres user on the server
2) This is read only.

  In my SQLite vtable both of the above restrictions don't apply. To
mitigate (1) I was hopeful that there was a way to get the connection to
PG on the server to fork/setuid ala how one can setup apache to run web
responses as linux uids. Given the difference between \copy and COPY
(client/server fs access) I don't know if such a restriction is easy to
lift.

  I think using a function restricts the results to being read only.
Perhaps having a second function that allows updates to be processed
separately.

  Any pointers / suggestions on how to do this sort of thing with
postgresql would be wonderful. Please CC any such replies as I'm not
currently on list.

[1]
http://ldn.linuxfoundation.org/article/libferris-and-sqlite-a-powerful-combination-part-1
https://ldn.linuxfoundation.org/node/26821


Attachment

pgsql-general by date:

Previous
From: ckarthic
Date:
Subject: Displaying the output of a query over a web interface.
Next
From: Craig Ringer
Date:
Subject: Re: Creating a read/write virtual table?