From: | Marti Raudsepp <marti(at)juffo(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net> |
Subject: | Re: Text-any concatenation volatility acting as optimization barrier |
Date: | 2012-02-08 09:53:01 |
Message-ID: | CABRT9RAF+9EnC0qcZrBd=4g8GQGXcPQxvN2=LWJAtG3H06gkTA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Feb 8, 2012 at 06:21, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Marti Raudsepp <marti(at)juffo(dot)org> writes:
>> Case #1 uses the normal textcat(text, text) operator by automatically
>> coercing 'x' as text.
>> However, case #2 uses the anytextcat(anynonarray, text), which is
>> marked as volatile thus acts as an optimization barrier.
>
> Hmm ... since those operators were invented (in 8.3), we have adopted a
> policy that I/O functions are presumed to be no worse than stable:
> http://archives.postgresql.org/pgsql-committers/2010-07/msg00307.php
> ISTM that would justify relabeling anytextcat/textanycat as stable,
> which should fix this.
Yes, we should definitely take advantage of that.
I scanned through all of pg_proc, there are 4 functions like this that
can be changed: textanycat, anytextcat, quote_literal and
quote_nullable. All of these have SQL wrappers to cast their argument
to ::text.
quote_literal | select pg_catalog.quote_literal($1::pg_catalog.text)
quote_nullable | select pg_catalog.quote_nullable($1::pg_catalog.text)
textanycat | select $1 || $2::pg_catalog.text
anytextcat | select $1::pg_catalog.text || $2
Patch attached (in git am format). Passes all regression tests (except
'json' which fails on my machine even on git master).
No documentation changes necessary AFAICT.
Regards,
Marti
Attachment | Content-Type | Size |
---|---|---|
0001-Mark-textanycat-quote_literal-quote_nullable-functio.patch | text/x-patch | 4.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Duncan Rance | 2012-02-08 10:01:55 | Re: BUG #6425: Bus error in slot_deform_tuple |
Previous Message | Dave Page | 2012-02-08 09:35:03 | Re: [HACKERS] pgindent README correction |