Re: ASCII Null control character validation

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Alexey Chernyshov <a(dot)chernyshov(at)postgrespro(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ASCII Null control character validation
Date: 2017-11-30 20:39:50
Message-ID: c4633f8d-2e3a-c38f-71c0-db49c65a8d2f@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/30/17 03:13, Alexey Chernyshov wrote:
> I found in src/backend/utils/mb/wchar.c: pg_verify_mbstr_len() that it
> reports ASCII Null character (\000) as invalid. As for me, it should
> pass validation. However, ASCII Null character breaks a line and the
> end of the line is missed, try:
>
> INSERT INTO mytable VALUES (E'a\001b\000c and rest of line MIA');
>
> Find patch attached. Am I wrong?

The main reason why you can't usefully have null characters in a string
literal is that the type input functions take a cstring as input, so no
string with a null character can possibly be input to a type.

So removing that check would just cause failure or confusion later.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Arthur Zakirov 2017-11-30 20:47:56 Re: [HACKERS] Bug in to_timestamp().
Previous Message Robert Haas 2017-11-30 20:39:09 Re: [HACKERS] postgres_fdw bug in 9.6