Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cloqv-0005U7-CL for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Mar 2017 03:34:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cloqu-0001cR-Dv for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Mar 2017 03:34:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cloqt-0001cA-MX for pgsql-bugs@postgresql.org; Thu, 09 Mar 2017 03:34:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cloqq-00073P-IW for pgsql-bugs@postgresql.org; Thu, 09 Mar 2017 03:34:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v293YkPx024976; Wed, 8 Mar 2017 22:34:46 -0500 From: Tom Lane To: Matt Magoffin cc: pgsql-bugs@postgresql.org, Teodor Sigaev Subject: Re: tsvector_update_trigger() fails in 9.6 on character(2) column In-reply-to: <016F132F-67E0-4576-A388-A5FABAC89235@msqr.us> References: <016F132F-67E0-4576-A388-A5FABAC89235@msqr.us> Comments: In-reply-to Matt Magoffin message dated "Thu, 09 Mar 2017 16:17:50 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24974.1489030486.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Mar 2017 22:34:46 -0500 Message-ID: <24975.1489030486@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Matt Magoffin writes: > I am migrating a 9.3 database to 9.6, and came across what looks like a p= ossible regression somewhere in tsvector_update_trigger() when passed a col= umn of type character. The following works in 9.3: > CREATE TABLE public.foo ( > foo_id integer NOT NULL, > country character(2) NOT NULL, > fts tsvector, > CONSTRAINT foo_pk PRIMARY KEY (foo_id) > ); > CREATE TRIGGER maintain_fts > BEFORE INSERT OR UPDATE > ON public.foo > FOR EACH ROW > EXECUTE PROCEDURE tsvector_update_trigger('fts', 'pg_catalog.english', = 'country'); > INSERT INTO public.foo (foo_id, country) VALUES (1, 'US'); > But the same thing in 9.6 results in : > ERROR: column "country" is not of a character type This is a consequence of commit 9acb9007de30b3daaa9efc16763c3bc6e3e0a92d, which replaced a handwritten type-compatibility check with an IsBinaryCoercible() test. Since char(n) is in fact not binary-coercible to text, IsBinaryCoercible() rejects this case. (A char(n)-to-text cast normally involves a function that strips trailing blanks.) If we're willing to assume that tsvector never cares about trailing blanks in its input string, then we could just allow the case, along the lines of - if (!IsBinaryCoercible(SPI_gettypeid(rel->rd_att, numattr), TEXTOID= )) + if (!IsBinaryCoercible(SPI_gettypeid(rel->rd_att, numattr), TEXTOID= ) && + !IsBinaryCoercible(SPI_gettypeid(rel->rd_att, numattr), BPCHARO= ID)) Not entirely sure that it's worth the trouble, as this seems like a rather strange use-case to me. regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs