Size limit for NOTIFY payload

Started by sulfinu@gmail.comover 1 year ago4 messagesdocs
Jump to latest
#1sulfinu@gmail.com
sulfinu@gmail.com

Hello,

according to the documentation
<https://www.postgresql.org/docs/current/sql-notify.html&gt;, the payload
given in a NOTIFY statement must not exceed a certain limit *in bytes*. But
the payload is a character string, therefore the limit remains unclear.

What's the character encoding of the NOTIFY payload, is it the default
database encoding?

Thanks.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: sulfinu@gmail.com (#1)
Re: Size limit for NOTIFY payload

sulfinu@gmail.com writes:

What's the character encoding of the NOTIFY payload, is it the default
database encoding?

It's whatever encoding your database uses; NOTIFY doesn't do any
transcoding.

(We'd have to think harder about that if NOTIFY messages could cross
database boundaries ... but they don't today.)

regards, tom lane

#3sulfinu@gmail.com
sulfinu@gmail.com
In reply to: Tom Lane (#2)
Re: Size limit for NOTIFY payload

Well, as I said, that's a *text* value with a *byte* limit. The
documentation should definitely mention something like *"with the default
database encoding"*.

În mie., 18 dec. 2024 la 18:29, Tom Lane <tgl@sss.pgh.pa.us> a scris:

Show quoted text

sulfinu@gmail.com writes:

What's the character encoding of the NOTIFY payload, is it the default
database encoding?

It's whatever encoding your database uses; NOTIFY doesn't do any
transcoding.

(We'd have to think harder about that if NOTIFY messages could cross
database boundaries ... but they don't today.)

regards, tom lane

#4Greg Sabino Mullane
greg@turnstep.com
In reply to: sulfinu@gmail.com (#3)
Re: Size limit for NOTIFY payload

On Fri, Dec 20, 2024 at 5:53 AM <sulfinu@gmail.com> wrote:

Well, as I said, that's a *text* value with a *byte* limit. The
documentation should definitely mention something like *"with the default
database encoding"*.

I'm not sure why you think adding such wordage is needed. Bytes is bytes.
Your application should be checking the number of bytes in the string sent
to NOTIFY.

On a related note, if you find yourself approaching the payload limits, you
might want to rethink the way you are using LISTEN/NOTIFY.

Cheers,
Greg