tsvector work with citext

Started by David E. Wheelerover 10 years ago9 messages
#1David E. Wheeler
david@kineticode.com
1 attachment(s)

Hey Hackers,

Is there a way to get tsvector_update_trigger() to work with citext columns? The attached case throws an error:

ERROR: column "title" is not of a character type

Is the fact that citext is a (non-preferred) member of the string category not sufficient for this to work? If not, are there any workarounds?

Thanks,

David

Attachments:

try.sqlapplication/sql; name=try.sqlDownload
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: David E. Wheeler (#1)
Re: tsvector work with citext

"David E. Wheeler" <david@kineticode.com> writes:

Is there a way to get tsvector_update_trigger() to work with citext
columns?

Hmm ... tsvector_op.c has

/* Check if datatype is TEXT or binary-equivalent to it */
static bool
is_text_type(Oid typid)
{
/* varchar(n) and char(n) are binary-compatible with text */
if (typid == TEXTOID || typid == VARCHAROID || typid == BPCHAROID)
return true;
/* Allow domains over these types, too */
typid = getBaseType(typid);
if (typid == TEXTOID || typid == VARCHAROID || typid == BPCHAROID)
return true;
return false;
}

and a look at the caller says that "binary-equivalent to TEXT" is indeed
the requirement, because we want to apply DatumGetTextP() to the argument.

However, it does seem like this function is not implementing its
specification. Why isn't it just "IsBinaryCoercible(typid, TEXTOID)"?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Teodor Sigaev
teodor@sigaev.ru
In reply to: Tom Lane (#2)
Re: tsvector work with citext

However, it does seem like this function is not implementing its
specification. Why isn't it just "IsBinaryCoercible(typid, TEXTOID)"?

Oversight, I suppose. is_text_type() was introduced by

commit 635aaab278afc1af972a4b6a55ff632ab763505d
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue Apr 8 18:20:29 2008 +0000

Fix tsvector_update_trigger() to be domain-friendly: it needs to allow all
the columns it works with to be domains over the expected type, not just
exactly the expected type. In passing, fix ts_stat() the same way.
Per report from Markus Wollny.

Will fix. Suppose, is_expected_type() could be replaced to IsBinaryCoercible too.

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Teodor Sigaev
teodor@sigaev.ru
In reply to: Teodor Sigaev (#3)
Re: tsvector work with citext

Oversight, I suppose. is_text_type() was introduced by

commit 635aaab278afc1af972a4b6a55ff632ab763505d
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue Apr 8 18:20:29 2008 +0000

Fix tsvector_update_trigger() to be domain-friendly: it needs to allow all
the columns it works with to be domains over the expected type, not just
exactly the expected type. In passing, fix ts_stat() the same way.
Per report from Markus Wollny.

I'm wrong, in this commit it was just renamed. It was originally coded by me.
But it's still oversight.

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5David E. Wheeler
david@kineticode.com
In reply to: Teodor Sigaev (#4)
Re: tsvector work with citext

On Sep 17, 2015, at 6:17 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:

I'm wrong, in this commit it was just renamed. It was originally coded by me. But it's still oversight.

Fixable?

Thanks,

David

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Teodor Sigaev
teodor@sigaev.ru
In reply to: David E. Wheeler (#5)
Re: tsvector work with citext

Fixable?

Fixed (9acb9007de30b3daaa9efc16763c3bc6e3e0a92d), but didn't backpatch because
it isn't a critical bug.

Thank you for the report!

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7David E. Wheeler
david@kineticode.com
In reply to: Teodor Sigaev (#6)
Re: tsvector work with citext

On Sep 18, 2015, at 7:29 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:

Fixable?

Fixed (9acb9007de30b3daaa9efc16763c3bc6e3e0a92d), but didn't backpatch because it isn't a critical bug.

Great, thank you!

For those on older versions, what’s the simplest workaround?

Best,

David

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: David E. Wheeler (#7)
Re: tsvector work with citext

"David E. Wheeler" <david@kineticode.com> writes:

On Sep 18, 2015, at 7:29 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:

Fixed (9acb9007de30b3daaa9efc16763c3bc6e3e0a92d), but didn't backpatch because it isn't a critical bug.

Great, thank you!
For those on older versions, what’s the simplest workaround?

FWIW, I thought this would be a reasonable thing to back-patch.
It's not as though contrib/citext hasn't been around for awhile.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#9Teodor Sigaev
teodor@sigaev.ru
In reply to: Tom Lane (#8)
Re: tsvector work with citext

Fixed (9acb9007de30b3daaa9efc16763c3bc6e3e0a92d), but didn't backpatch because it isn't a critical bug.

For those on older versions, whatО©╫О©╫О©╫s the simplest workaround?

FWIW, I thought this would be a reasonable thing to back-patch.
It's not as though contrib/citext hasn't been around for awhile.

I'd like this idea, but does it look like a new feature in previous releses?

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers