Re: Extensibility of the PostgreSQL wire protocol

From: Jan Wieck <jan(at)wi3ck(dot)info>
To: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
Cc: Dave Cramer <davecramer(at)postgres(dot)rocks>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Extensibility of the PostgreSQL wire protocol
Date: 2021-02-19 13:46:10
Message-ID: CAGBW59empGcTqdf38DCmLxSB5vfSD6vbLxNGTfVeHGeCZyJfXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thank you Kuntal,

On Fri, Feb 19, 2021 at 4:36 AM Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
wrote:

> On Thu, Feb 18, 2021 at 9:32 PM Jan Wieck <jan(at)wi3ck(dot)info> wrote:
>
>
> Few comments in the extension code (although experimental):
>
> 1. In telnet_srv.c,
> + static int pe_port;
> ..
> + DefineCustomIntVariable("telnet_srv.port",
> + "Telnet server
> port.",
> + NULL,
> + &pe_port,
> + pe_port,
> + 1024,
> + 65536,
> + PGC_POSTMASTER,
> + 0,
> + NULL,
> + NULL,
> + NULL);
>
> The variable pe_port should be initialized to a value which is > 1024
> and < 65536. Otherwise, the following assert will fail,
> TRAP: FailedAssertion("newval >= conf->min", File: "guc.c", Line:
> 5541, PID: 12100)
>
>
Right, forgot to turn on Asserts.

> 2. The function pq_putbytes shouldn't be used by anyone other than
> old-style COPY out.
> + pq_putbytes(msg, strlen(msg));
> Otherwise, the following assert will fail in the same function:
> /* Should only be called by old-style COPY OUT */
> Assert(DoingCopyOut);
>

I would argue that the Assert needs to be changed. It is obvious that the
Assert in place is meant to guard against direct usage of pg_putbytes() in
an attempt to force all code to use pq_putmessage() instead. This is good
when speaking libpq wire protocol since all messages there are prefixed
with a one byte message type. It does not apply to other protocols.

I propose to create another global boolean IsNonLibpqFrontend which the
protocol extension will set to true when accepting the connection and the
above then will change to

Assert(DoingCopyOut || IsNonLibpqFrontend);

Regards, Jan

>
> --
> Thanks & Regards,
> Kuntal Ghosh
> Amazon Web Services
>

--
Jan Wieck

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2021-02-19 13:48:35 Re: Extensibility of the PostgreSQL wire protocol
Previous Message Joel Jacobson 2021-02-19 12:45:34 Re: Some regular-expression performance hacking