pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #8291: postgres_fdw does not re-read USER MAPING after change.
3+ messages / 3 participants
[nested] [flat]

* BUG #8291: postgres_fdw does not re-read USER MAPING after change.
@ 2013-07-09 22:05  lalbin@fhcrc.org
  0 siblings, 1 reply; 3+ messages in thread

From: lalbin@fhcrc.org @ 2013-07-09 22:05 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      8291
Logged by:          Lloyd Albin
Email address:      lalbin@fhcrc.org
PostgreSQL version: Unsupported/Unknown
Operating system:   Windows 7 (64-bit)
Description:        

Tested on
Windows 7 (64-bit) Postgres 9.3.0 Beta 2  -> Windows 7 (64-bit) Postgres
9.3.0 Beta 2
Windows 7 (64-bit) Postgres 9.3.0 Beta 1 -> SUSE Linux (64-bit) Postgres
9.0


I have found that if you change the password in the USER MAPPING, that
postgres_fdw will not use it unless the current password fails or you close
and re-open your postgres connection. I found this while testing to see if
the USER MAPPING's supports MD5 passwords and they appeared to until the
next day when I found that they no longer worked because I had closed and
re-opened my connection.


The second error that I found is in the documentation of ALTER USER MAPPING.
It incorrectly says how to update a users password.


CREATE DATABASE db1
  WITH ENCODING='UTF8'
       OWNER=postgres
       CONNECTION LIMIT=-1;


CREATE DATABASE db2
  WITH ENCODING='UTF8'
       OWNER=postgres
       CONNECTION LIMIT=-1;


-- LOG INTO db1


CREATE TABLE public.tbl_test
(
   field character varying, 
   CONSTRAINT tbl_test_field_pkey PRIMARY KEY (field)
) 
WITH (
  OIDS = FALSE
)
;
ALTER TABLE public.tbl_test
  OWNER TO postgres;


INSERT INTO public.tbl_test VALUES('Test Value');


-- LOG INTO db2


CREATE EXTENSION postgres_fdw;


CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host
'localhost', dbname 'db1', port '5432');


CREATE USER MAPPING FOR postgres SERVER myserver OPTIONS (user 'postgres',
password 'password');


CREATE FOREIGN TABLE tbl_test (
    field character varying
)
SERVER myserver;


SELECT * FROM tbl_test;
-- This works, we should see the 'Test Value' returned.


ALTER USER MAPPING FOR postgres SERVER myserver OPTIONS (user 'postgres',
password 'badpass');


ERROR:  option "user" provided more than once
********** Error **********


ERROR: option "user" provided more than once
SQL state: 42710


-- http://www.postgresql.org/docs/9.3/static/sql-alterusermapping.html


-- Documentation is not correct, needs to be updated to show updating user
password as:


ALTER USER MAPPING FOR postgres SERVER myserver OPTIONS (SET password
'badpass');


SELECT * FROM pg_catalog.pg_user_mapping;


-- Verified that password was properly changed.


SELECT * FROM tbl_test;


Total query runtime: 1970 ms.
1 row retrieved.


-- This should have failed due to the bad password.
-- If you log out of the database and then reconnect, the query will then
fail.




Lloyd Albin
Statistical Center for HIV/AIDS Research and Prevention (SCHARP)
Vaccine and Infectious Disease Division (VIDD)
Fred Hutchinson Cancer Research Center (FHCRC)



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #8291: postgres_fdw does not re-read USER MAPING after change.
@ 2013-07-10 22:33  Bernd Helmle <mailings@oopsware.de>
  parent: lalbin@fhcrc.org
  0 siblings, 1 reply; 3+ messages in thread

From: Bernd Helmle @ 2013-07-10 22:33 UTC (permalink / raw)
  To: lalbin@fhcrc.org; pgsql-bugs



--On 9. Juli 2013 22:05:20 +0000 lalbin@fhcrc.org wrote:

> I have found that if you change the password in the USER MAPPING, that
> postgres_fdw will not use it unless the current password fails or you
> close and re-open your postgres connection. I found this while testing to
> see if the USER MAPPING's supports MD5 passwords and they appeared to
> until the next day when I found that they no longer worked because I had
> closed and re-opened my connection.
>

Hmm i don't think that's a bug. It's because the postgres_fdw caches the 
connection within your local session, reusing it for any subsequent foreign 
table access.

>
> The second error that I found is in the documentation of ALTER USER
> MAPPING. It incorrectly says how to update a users password.
>
>

It could be misread, i agree. Attached is a small doc patch to address this 
against HEAD.

-- 
Thanks

	Bernd

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

user_mapping_doc.patch (application/octet-stream, 1.0K) download diff --git a/doc/src/sgml/ref/alter_user_mapping.sgml b/doc/src/sgml/ref/alter_user_mapping.sgml new file mode 100644 index 3245f83..dce5ba4 *** a/doc/src/sgml/ref/alter_user_mapping.sgml --- b/doc/src/sgml/ref/alter_user_mapping.sgml *************** ALTER USER MAPPING FOR { <replaceable cl *** 89,97 **** <title>Examples</title> <para> Change the password for user mapping <literal>bob</>, server<literal> foo</>: <programlisting> ! ALTER USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'public'); </programlisting></para> </refsect1> --- 89,103 ---- <title>Examples</title> <para> + Add a password for user mapping <literal>bob</>, server<literal> foo</>: + <programlisting> + ALTER USER MAPPING FOR bob SERVER foo OPTIONS (ADD password 'public'); + </programlisting></para> + + <para> Change the password for user mapping <literal>bob</>, server<literal> foo</>: <programlisting> ! ALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password 'public'); </programlisting></para> </refsect1>
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: BUG #8291: postgres_fdw does not re-read USER MAPING after change.
@ 2013-07-10 22:39  Albin, Lloyd P <lalbin@scharp.org>
  parent: Bernd Helmle <mailings@oopsware.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Albin, Lloyd P @ 2013-07-10 22:39 UTC (permalink / raw)
  To: Bernd Helmle <mailings@oopsware.de>; pgsql-bugs

I realized that postgres_fdw is caching the connection, but when you have existing items that use the same USER MAPPING and do not cache it such as dblink you get inconsistency in implementation and this should be avoided.

Lloyd

-----Original Message-----
From: Bernd Helmle [mailto:mailings@oopsware.de] 
Sent: Wednesday, July 10, 2013 3:34 PM
To: Albin, Lloyd P; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #8291: postgres_fdw does not re-read USER MAPING after change.



--On 9. Juli 2013 22:05:20 +0000 lalbin@fhcrc.org wrote:

> I have found that if you change the password in the USER MAPPING, that 
> postgres_fdw will not use it unless the current password fails or you 
> close and re-open your postgres connection. I found this while testing 
> to see if the USER MAPPING's supports MD5 passwords and they appeared 
> to until the next day when I found that they no longer worked because 
> I had closed and re-opened my connection.
>

Hmm i don't think that's a bug. It's because the postgres_fdw caches the connection within your local session, reusing it for any subsequent foreign table access.

>
> The second error that I found is in the documentation of ALTER USER
> MAPPING. It incorrectly says how to update a users password.
>
>

It could be misread, i agree. Attached is a small doc patch to address this 
against HEAD.

-- 
Thanks

	Bernd


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-07-10 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09 22:05 BUG #8291: postgres_fdw does not re-read USER MAPING after change. lalbin@fhcrc.org
2013-07-10 22:33 ` Bernd Helmle <mailings@oopsware.de>
2013-07-10 22:39   ` Albin, Lloyd P <lalbin@scharp.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox