Re: pgsql: Support frontend-backend protocol communication using a shm_mq.

Lists: pgsql-committerspgsql-hackers
From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Support frontend-backend protocol communication using a shm_mq.
Date: 2014-10-31 16:47:41
Message-ID: E1XkFMT-0000Ze-Db@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Support frontend-backend protocol communication using a shm_mq.

A background worker can use pq_redirect_to_shm_mq() to direct protocol
that would normally be sent to the frontend to a shm_mq so that another
process may read them.

The receiving process may use pq_parse_errornotice() to parse an
ErrorResponse or NoticeResponse from the background worker and, if
it wishes, ThrowErrorData() to propagate the error (with or without
further modification).

Patch by me. Review by Andres Freund.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2bd9e412f92bc6a68f3e8bcb18e04955cc35001d

Modified Files
--------------
src/backend/libpq/Makefile | 2 +-
src/backend/libpq/pqcomm.c | 98 ++++++++------
src/backend/libpq/pqmq.c | 261 ++++++++++++++++++++++++++++++++++++++
src/backend/utils/adt/numutils.c | 2 +-
src/backend/utils/error/elog.c | 51 ++++++++
src/include/libpq/libpq.h | 36 ++++--
src/include/libpq/pqmq.h | 22 ++++
src/include/utils/builtins.h | 2 +-
src/include/utils/elog.h | 1 +
9 files changed, 428 insertions(+), 47 deletions(-)


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Robert Haas <rhaas(at)postgresql(dot)org>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Support frontend-backend protocol communication using a shm_mq.
Date: 2014-11-01 13:30:38
Message-ID: 5454E07E.3050804@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On 10/31/14 12:47 PM, Robert Haas wrote:
> Support frontend-backend protocol communication using a shm_mq.

This fails cpluspluscheck.

src/include/libpq/pqmq.h needs to include something that defines StringInfo.


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Support frontend-backend protocol communication using a shm_mq.
Date: 2014-11-03 17:36:58
Message-ID: CA+Tgmoa=NBuuiuq3hHVqOuxT-xL2v0xFLe5gqs7qoO1XNQkq4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Sat, Nov 1, 2014 at 9:30 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On 10/31/14 12:47 PM, Robert Haas wrote:
>> Support frontend-backend protocol communication using a shm_mq.
>
> This fails cpluspluscheck.
>
> src/include/libpq/pqmq.h needs to include something that defines StringInfo.

OK, fixed.

On my MacBook Pro, cpluspluscheck is all but useless, because it gives
a zillion warnings like this:

In file included from src/include/postgres.h:47,
from /tmp/cpluspluscheck.ZkYfcq/test.cpp:2:
src/include/c.h:110:21: error: libintl.h: No such file or directory

I bet that's because I configure --with-libraries=/opt/local/lib
--with-includes=/opt/local/include

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Robert Haas <rhaas(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Support frontend-backend protocol communication using a shm_mq.
Date: 2014-12-04 21:15:07
Message-ID: 20141204211507.GA1768@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Robert Haas wrote:
> Support frontend-backend protocol communication using a shm_mq.

I just noticed that this patch broke the case where a standalone backend
is sent a query that throws an error -- instead, we get a segmentation
fault. Example:

echo "foobar" | postgres --single
PostgreSQL stand-alone backend 9.5devel
backend> Segmentation fault

I guess we could have a src/test/modules subdir that tests simple stuff
on standalone backends ...

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Support frontend-backend protocol communication using a shm_mq.
Date: 2014-12-05 00:53:23
Message-ID: CA+TgmoZx45P8wc4ZJshKNM9eJvv-haa6ycqeNaj8gUMg-K0Yjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Thu, Dec 4, 2014 at 4:15 PM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> Robert Haas wrote:
>> Support frontend-backend protocol communication using a shm_mq.
>
> I just noticed that this patch broke the case where a standalone backend
> is sent a query that throws an error -- instead, we get a segmentation
> fault.

Ugh, sorry. Fixed.

> Example:
>
> echo "foobar" | postgres --single
> PostgreSQL stand-alone backend 9.5devel
> backend> Segmentation fault
>
> I guess we could have a src/test/modules subdir that tests simple stuff
> on standalone backends ...

Wouldn't hurt. Although it's not something that's likely to get
broken very often.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company