Re: dblink patches for comment

Lists: pgsql-hackers
From: Joe Conway <mail(at)joeconway(dot)com>
To: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: dblink patches for comment
Date: 2009-05-27 01:51:08
Message-ID: 4A1C9C8C.6030405@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The attached addresses items#2 and 3 as listed by Bruce here:
http://momjian.us/cgi-bin/pgsql/joe

I think it is consistent with the discussions we had a PGCon last week.
Any objections to me committing this for 8.4?

On a side note, should I try to address items #1 & #4 for 8.4 as well?
Perhaps #4 yes since it is arguably a bug fix, but no to #1?

Joe

Attachment Content-Type Size
dblink.2009.05.26.01.diff text/x-patch 19.0 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dblink patches for comment
Date: 2009-05-27 23:24:04
Message-ID: 20613.1243466644@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Joe Conway <mail(at)joeconway(dot)com> writes:
> The attached addresses items#2 and 3 as listed by Bruce here:
> http://momjian.us/cgi-bin/pgsql/joe

> I think it is consistent with the discussions we had a PGCon last week.
> Any objections to me committing this for 8.4?

It's hard to review it without any docs that say what it's supposed to do.
(And you'd need to patch the docs anyway, eh?)

> On a side note, should I try to address items #1 & #4 for 8.4 as well?
> Perhaps #4 yes since it is arguably a bug fix, but no to #1?

Yeah, my feeling too. #1 is a new feature that was submitted too late
for 8.4. I wouldn't have argued if you'd committed it anyway during
the commitfest, but it's definitely too late now. But #4 seems like
a bugfix.

regards, tom lane


From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dblink patches for comment
Date: 2009-05-31 19:38:52
Message-ID: 4A22DCCC.8030807@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> It's hard to review it without any docs that say what it's supposed to do.
> (And you'd need to patch the docs anyway, eh?)

Fair enough :-)

Probably better if I break this up in logical chunks too. This patch
only addresses the refactoring you requested here:
http://archives.postgresql.org/message-id/28719.1230996378@sss.pgh.pa.us

I'll follow up later today with a SQL/MED only patch which includes docs.

Joe

Attachment Content-Type Size
dblink.2009.05.31.01-async_refactor.diff text/x-patch 9.5 KB

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dblink patches for comment
Date: 2009-06-01 00:27:32
Message-ID: 4A232074.5020506@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> It's hard to review it without any docs that say what it's supposed to do.
> (And you'd need to patch the docs anyway, eh?)

Here's a much simpler SQL/MED support patch for dblink.

This enforces security in the same manner for FOREIGN SERVER connections
as that worked out over time for other dblink connections. Essentially,
the FOREIGN SERVER and associated user MAPPING provides the needed info
for the libpq connection, but otherwise behavior is the same.

I've also attached a doc patch.

Comments?

Joe

Attachment Content-Type Size
dblink.2009.05.31.02-sqlmed.diff text/x-patch 7.7 KB
dblink.2009.05.31.02-sqlmed_doc.diff text/x-patch 2.7 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dblink patches for comment
Date: 2009-06-02 01:09:54
Message-ID: 29955.1243904994@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Joe Conway <mail(at)joeconway(dot)com> writes:
> Probably better if I break this up in logical chunks too. This patch
> only addresses the refactoring you requested here:
> http://archives.postgresql.org/message-id/28719.1230996378@sss.pgh.pa.us

This looks sane to me in a quick once-over, though I've not tested it.

A small suggestion for future patches: don't bother to reindent code
chunks that aren't changing --- it just complicates the diff with a
lot of uninteresting whitespace changes. You can either do that after
review, or leave it to be done by pgindent. (Speaking of which, we
need to schedule that soon...)

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: dblink patches for comment
Date: 2009-06-02 01:18:23
Message-ID: 193.1243905503@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Joe Conway <mail(at)joeconway(dot)com> writes:
> Here's a much simpler SQL/MED support patch for dblink.

> This enforces security in the same manner for FOREIGN SERVER connections
> as that worked out over time for other dblink connections. Essentially,
> the FOREIGN SERVER and associated user MAPPING provides the needed info
> for the libpq connection, but otherwise behavior is the same.

> I've also attached a doc patch.

The docs patch looks okay, except this comment is a bit hazy:

> + -- Note: local connection must require authentication for this to work properly

I think what it means is

> + -- Note: local connection must require password authentication for this to work properly

If not, please clarify some other way. It might also be good to be a
bit more clear about what "fail to work properly" might entail.

As far as the code goes, hopefully Peter will take a look since he's
spent more time on the SQL/MED code than I have. The only thing I can
see that looks bogus is that get_connect_string() is failing to handle
any quoting/escaping that might be needed for the values to be inserted
into the connection string. I don't recall offhand what rules libpq
has for that, but I hope it at least implements doubled single quotes...

regards, tom lane


From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dblink patches for comment
Date: 2009-06-02 03:25:06
Message-ID: 4A249B92.5080006@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Joe Conway <mail(at)joeconway(dot)com> writes:
>> Probably better if I break this up in logical chunks too. This patch
>> only addresses the refactoring you requested here:
>> http://archives.postgresql.org/message-id/28719.1230996378@sss.pgh.pa.us
>
> This looks sane to me in a quick once-over, though I've not tested it.

Thanks -- committed.

> A small suggestion for future patches: don't bother to reindent code
> chunks that aren't changing --- it just complicates the diff with a
> lot of uninteresting whitespace changes. You can either do that after
> review, or leave it to be done by pgindent. (Speaking of which, we
> need to schedule that soon...)

Sorry. "cvs diff -cb" seems to help (see attached). It is half the size
and much more readable.

Joe

Attachment Content-Type Size
dblink.2009.06.01.01-async_refactor.diff text/x-patch 4.1 KB

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: dblink patches for comment
Date: 2009-06-02 23:08:18
Message-ID: 4A25B0E2.3090302@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> The docs patch looks okay, except this comment is a bit hazy:
>
>> + -- Note: local connection must require authentication for this to work properly
>
> I think what it means is
>
>> + -- Note: local connection must require password authentication for this to work properly
>
> If not, please clarify some other way. It might also be good to be a
> bit more clear about what "fail to work properly" might entail.

OK, hopefully the attached is more clear.

> As far as the code goes, hopefully Peter will take a look since he's
> spent more time on the SQL/MED code than I have. The only thing I can
> see that looks bogus is that get_connect_string() is failing to handle
> any quoting/escaping that might be needed for the values to be inserted
> into the connection string. I don't recall offhand what rules libpq
> has for that, but I hope it at least implements doubled single quotes...

Added quote_literal_cstr() around the connection string params. Also
found I needed to restrict the servername string length to NAMEDATALEN
in order to avoid an assert if a full connection string is passed to
dblink_connect().

Other comments?

Thanks,

Joe

Attachment Content-Type Size
dblink.2009.06.02.02-sqlmed.diff text/x-patch 7.8 KB
dblink.2009.06.02.02-sqlmed_doc.diff text/x-patch 3.1 KB