pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alex Kliukin <alexk@hintbits.com>
To: pgsql-general@postgresql.org
Subject: regex match and special characters
Date: Thu, 16 Aug 2018 12:59:38 +0200
Message-ID: <1534417178.2357012.1476047168.78425024@webmail.messagingengine.com> (raw)

Hi,

Here is a simple SQL statement that gives different results on PostgreSQL 9.6 and PostgreSQL 10+. The space character at the end of the string is actually U+2006 SIX-PER-EM SPACE (http://www.fileformat.info/info/unicode/char/2006/index.htm)

test=# select 'abcd ' ~ 'abcd\s';
 ?column?
----------
 t
(1 row)

test=# select version();
                                             version
-------------------------------------------------------------------------------------------------
 PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (Gentoo 6.4.0-r1 p1.3) 6.4.0, 64-bit
(1 row)


On another server (running on the same system on a different port)

postgres=# select version();
                                            version
-----------------------------------------------------------------------------------------------
 PostgreSQL 9.6.9 on x86_64-pc-linux-gnu, compiled by gcc (Gentoo 6.4.0-r1 p1.3) 6.4.0, 64-bit
(1 row)

postgres=# select 'abcd ' ~ 'abcd\s';
 ?column?
----------
 f
(1 row)

For both clusters, the client encoding is UTF8, the database encoding and collation is UTF8 and en_US.utf8 respectively, and the lc_ctype is en_US.utf8. I am accessing the databases running locally by ssh-ing first to the host. 

I observed similar issues with other Linux-based servers running Ubuntu, in all cases the regex resulted in true on PostgreSQL 10+ and false on earlier versions (down to 9.3). The query comes from a table check that suddenly stopped accepting rows valid in the older version during the migration. Making it  select 'abcd ' ~ E'abcd\\s' doesn't  modify the outcome, unsurprisingly.

Is it reproducible for others here as well? Given that it is, Is there a way to make both versions behave the same?

Cheers,
Alex




view thread (6+ messages)  latest in thread

Message-ID: <1534417178.2357012.1476047168.78425024@webmail.messagingengine.com>
Permalink:  ../1534417178.2357012.1476047168.78425024@webmail.messagingengine.com/
Also on:    postgresql.org/message-id/1534417178.2357012.1476047168.78425024@webmail.messagingengine.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alexk@hintbits.com
  Subject: Re: regex match and special characters
  In-Reply-To: <1534417178.2357012.1476047168.78425024@webmail.messagingengine.com>
  References: <1534417178.2357012.1476047168.78425024@webmail.messagingengine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox