Re: pgsql_fdw, FDW for PostgreSQL server

Albe Laurenz <laurenz.albe@wien.gv.at>

From: "Albe Laurenz" <laurenz.albe@wien.gv.at>
To: "Shigeru Hanada *EXTERN*" <shigeru.hanada@gmail.com>, "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Cc: "Tom Lane" <tgl@sss.pgh.pa.us>, "Robert Haas" <robertmhaas@gmail.com>, "PostgreSQL-development" <pgsql-hackers@postgresql.org>, "Kohei KaiGai" <kaigai@kaigai.gr.jp>, "Martijn van Oosterhout" <kleptog@svana.org>, "Etsuro Fujita" <fujita.etsuro@lab.ntt.co.jp>, "Hitoshi Harada" <umi.tanuki@gmail.com>
Date: 2012-03-06T10:09:08Z
Lists: pgsql-hackers
Shigeru Hanada wrote:
[pgsql_fdw_v12.patch]

I know this is not the latest version, but I played around with it and
tickled a bug.
It seems to have a problem with rolled back subtransactions.

test=> \d+ remote
                      Foreign table "laurenz.remote"
    Column |  Type   | Modifiers | FDW Options | Storage  | Description
   --------+---------+-----------+-------------+----------+-------------
    id     | integer | not null  |             | plain    |
    val    | text    | not null  |             | extended |
   Server: loopback
   FDW Options: (nspname 'laurenz', relname 'local')
   Has OIDs: no
test=> BEGIN;
test=> DECLARE x CURSOR FOR SELECT * FROM remote;
   DEBUG:  Remote SQL: SELECT id, val FROM laurenz.local
   DEBUG:  relid=16423 fetch_count=10000
   DEBUG:  starting remote transaction with "START TRANSACTION ISOLATION
LEVEL REPEATABLE READ"
test=> FETCH x;
    id | val
   ----+-----
     1 | one
   (1 row)
test=> SAVEPOINT z;
test=> ERROR OUT;
   ERROR:  syntax error at or near "ERROR"
   LINE 1: ERROR OUT;
test=> ROLLBACK TO SAVEPOINT z;
test=> FETCH x;
    id | val
   ----+-----
     2 | two
   (1 row)
test=> COMMIT;
   ERROR:  could not close cursor
   DETAIL:  no connection to the server

   HINT:  CLOSE pgsql_fdw_cursor_0

The error message reported is not consistent, at one attempt the backend
crashed.

Yours,
Laurenz Albe