Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: "Daniel Verite" <daniel(at)manitou-mail(dot)org>, "Robert Schreiber" <bobschreiber(at)charter(dot)net>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug
Date: 2019-05-13 17:48:18
Message-ID: 4306.1557769698@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Here's a proposed patch for dealing with the non-spec greediness behavior.
It also fixes misbehavior with | in the pattern, as shown in the new
test cases (well, if you try them against HEAD, you'll see the
misbehavior).

I haven't done anything about most of the SQL-spec incompatibilities
mentioned in the other thread, but I did change the code to throw error
for more than two escape-double-quote separators, mainly because not
doing so would've required more complexity in the result string
allocation logic.

Also, rather than throw error for a single separator, I just let the
code ignore the case, because with this implementation a fairly reasonable
behavior falls out: it acts the same as if the last pattern section were
empty. I'm a little worried that that's turning an implementation
artifact into a feature, but it seems to line up well with our historical
behavior for no separators (namely, we act as though the first and last
sections were both empty).

I've included doc changes addressing these specific behaviors, but
not done anything about the other omissions in the docs.

Comments? Should we try to get more than this done for v12, or just
leave it for some other day?

regards, tom lane

Attachment Content-Type Size
fix-SQL-substring-pattern-greediness.patch text/x-diff 11.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Monica Maria Piza Merchan 2019-05-13 20:04:14 prerunscript.command.line.error
Previous Message Peter Eisentraut 2019-05-13 16:28:01 Re: identity not working with inherited table