pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedtsearch2() trigger and domain types...
5+ messages / 3 participants
[nested] [flat]
* tsearch2() trigger and domain types...
@ 2007-06-18 21:09 Michael D. Stemle, Jr. <manchicken@notsosoft.net>
0 siblings, 1 reply; 5+ messages in thread
From: Michael D. Stemle, Jr. @ 2007-06-18 21:09 UTC (permalink / raw)
To: pgsql-sql
Okay, so I have an interesting problem that I'm having a hard time figuring
out.
For standardization in my database I use a domain (login_t) for my login
column in my profile table. I'm trying to use the tsearch2() trigger to
index several columns, including the login column, into a column
called "search_index."
So I added the trigger as attached with the hope that it would do just that.
Well, here's what I get upon every update and insert to the profile table:
WARNING: TSearch: 'login' is not of character type
I've tried casting and such, but nothing seems to work. Anybody got any
ideas? Thanks in advance.
--
~ Michael D. Stemle, Jr. <><
(A)bort, (R)etry, (I)nfluence with large hammer
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Attachments:
tgr_profile_search_index-on-public_profile_DDL.sql (text/plain, 439B) download
CREATE TRIGGER "tgr_profile_search_index" AFTER INSERT OR UPDATE
ON "public"."profile" FOR EACH ROW
EXECUTE PROCEDURE "public"."tsearch2"(search_index, description, interests, login, hometown, email, url, im_names, name);
COMMENT ON TRIGGER "tgr_profile_search_index" ON "public"."profile"
IS 'This trigger will keep the search index up to date for the profile table. This index is based on the description and the interests columns.';
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tsearch2() trigger and domain types...
@ 2007-06-18 22:59 Tom Lane <tgl@sss.pgh.pa.us>
parent: Michael D. Stemle, Jr. <manchicken@notsosoft.net>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2007-06-18 22:59 UTC (permalink / raw)
To: Michael D. Stemle, Jr. <manchicken@notsosoft.net>; +Cc: pgsql-sql@postgresql.org, Oleg Bartunov <oleg@sai.msu.su>; Teodor Sigaev <teodor@sigaev.ru>
"Michael D. Stemle, Jr." <manchicken@notsosoft.net> writes:
> For standardization in my database I use a domain (login_t) for my login
> column in my profile table.
> Well, here's what I get upon every update and insert to the profile table:
> WARNING: TSearch: 'login' is not of character type
The tsearch trigger seems to insist that the column be text, varchar(n),
or char(n) ... no domains need apply :-(
I'm not real sure why it doesn't just invoke the column's output
function and be datatype-agnostic. Or at least do that when the
shortcut "I know what text looks like" path isn't applicable.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tsearch2() trigger and domain types...
@ 2007-06-19 13:55 manchicken <manchicken@notsosoft.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: manchicken @ 2007-06-19 13:55 UTC (permalink / raw)
To: pgsql-sql
On Monday 18 June 2007 17:59:50 Tom Lane wrote:
> "Michael D. Stemle, Jr." <manchicken@notsosoft.net> writes:
> > For standardization in my database I use a domain (login_t) for my login
> > column in my profile table.
> >
> > Well, here's what I get upon every update and insert to the profile
> > table: WARNING: TSearch: 'login' is not of character type
>
> The tsearch trigger seems to insist that the column be text, varchar(n),
> or char(n) ... no domains need apply :-(
>
> I'm not real sure why it doesn't just invoke the column's output
> function and be datatype-agnostic. Or at least do that when the
> shortcut "I know what text looks like" path isn't applicable.
Is there any way to cast these column datatypes in the trigger to fool it, or
is the only way to fix this to reconstruct the table without domains? I'd
really prefer not to abandon domains if at all possible.
--
~ manchicken <><
(A)bort, (R)etry, (I)nfluence with large hammer.
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tsearch2() trigger and domain types...
@ 2007-06-19 14:08 Tom Lane <tgl@sss.pgh.pa.us>
parent: manchicken <manchicken@notsosoft.net>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2007-06-19 14:08 UTC (permalink / raw)
To: manchicken <manchicken@notsosoft.net>; +Cc: pgsql-sql
manchicken <manchicken@notsosoft.net> writes:
> Is there any way to cast these column datatypes in the trigger to fool it,
No, you'd have to modify the trigger source code. It'd be a pretty
trivial change to allow domains over textual types:
continue;
}
oidtype = SPI_gettypeid(rel->rd_att, numattr);
+ oidtype = getBaseType(oidtype);
/* We assume char() and varchar() are binary-equivalent to text */
if (!(oidtype == TEXTOID ||
oidtype == VARCHAROID ||
oidtype == BPCHAROID))
{
elog(WARNING, "TSearch: '%s' is not of character type",
trigger->tgargs[i]);
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tsearch2() trigger and domain types...
@ 2007-06-19 17:43 manchicken <manchicken@notsosoft.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: manchicken @ 2007-06-19 17:43 UTC (permalink / raw)
To: pgsql-sql
On Tuesday 19 June 2007 09:08:23 Tom Lane wrote:
> oidtype = getBaseType(oidtype);
I patched this in a FreeBSD 6.2 port. Attached is the patch. Thanks a lot
for the help on this. It works like a charm.
--
~ manchicken <><
(A)bort, (R)etry, (I)nfluence with large hammer.
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Attachments:
tsearch2_domains_fix.patch (text/x-diff, 407B) download
*** tsvector.c Tue Jun 19 12:39:06 2007
--- tsvector.c.patched Tue Jun 19 12:38:37 2007
*************** tsearch2(PG_FUNCTION_ARGS)
*** 890,895 ****
--- 890,896 ----
continue;
}
oidtype = SPI_gettypeid(rel->rd_att, numattr);
+ oidtype = getBaseType(oidtype);
/* We assume char() and varchar() are binary-equivalent to text */
if (!(oidtype == TEXTOID ||
oidtype == VARCHAROID ||
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2007-06-19 17:43 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-18 21:09 tsearch2() trigger and domain types... Michael D. Stemle, Jr. <manchicken@notsosoft.net>
2007-06-18 22:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-06-19 13:55 ` manchicken <manchicken@notsosoft.net>
2007-06-19 14:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-06-19 17:43 ` manchicken <manchicken@notsosoft.net>
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