elog() error, trying CURENT OF with foreign table - Mailing list pgsql-hackers

From Rushabh Lathia
Subject elog() error, trying CURENT OF with foreign table
Date
Msg-id CAGPqQf0L8dtNtb3_ea4jBvV3JrnuQzcqYuSHtFJbTaiCgNo_yA@mail.gmail.com
Whole thread Raw
Responses Re: elog() error, trying CURENT OF with foreign table
List pgsql-hackers
While trying out CURRENT OF with foreign table, ending up with error.

postgres=# select version();
                                                     version                                                     
-----------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.3devel on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3), 64-bit
(1 row)

-- Create exptension & database
postgres=# CREATE EXTENSION postgres_fdw;
CREATE EXTENSION
postgres=# create database regression;
CREATE DATABASE

-- Create foreign server
postgres=# CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw
postgres-#   OPTIONS (dbname 'regression');
CREATE SERVER
postgres=# CREATE USER MAPPING FOR CURRENT_USER SERVER loopback;
CREATE USER MAPPING

-- Create table into remote server
postgres=# \c regression
You are now connected to database "regression" as user "rushabh".
regression=# create table test ( a int );
CREATE TABLE
regression=# insert into test values ( 1 );
INSERT 0 1

-- Connect to local server and create test function
regression=# \c postgres
-- Create foreign table
postgres=# create foreign table test ( a int ) server loopback;
CREATE FOREIGN TABLE
postgres=# CREATE OR REPLACE FUNCTION taest_func_dblink2()
postgres-# RETURNS numeric
postgres-# AS $$
postgres$# DECLARE c CURSOR FOR SELECT a FROM test FOR UPDATE;
postgres$# v_i numeric;
postgres$# BEGIN
postgres$# OPEN c;
postgres$# FETCH c INTO v_i;
postgres$# UPDATE test SET a=50 WHERE CURRENT OF c;
postgres$# RETURN 0;
postgres$# END; $$ LANGUAGE plpgsql;
CREATE FUNCTION

postgres=# select taest_func_dblink2();
ERROR:  CURRENT OF cannot be executed
CONTEXT:  SQL statement "UPDATE test SET a=50 WHERE CURRENT OF c" 
PL/pgSQL function taest_func_dblink2() line 7 at SQL statement

Here test ending up with following:

elog(ERROR, "CURRENT OF cannot be executed");

should we change this to ereport() or is there some other fix that we should make?

Regards, 
Rushabh Lathia

pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Enabling Checksums
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Inconsistent DB data in Streaming Replication