Re: typcategory for regconfig

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: "PostgreSQL-dev(dot)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: typcategory for regconfig
Date: 2018-04-05 13:27:47
Message-ID: 10713.1522934867@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dmitry Dolgov <9erthalion6(at)gmail(dot)com> writes:
> Does anyone know, why `typcategory` value for tsvector `regconfig` is
> `TYPCATEGORY_NUMERIC`,

Because OID is. I think we need all the OID-alias types to be the same
category as OID, else we're likely to have issues with queries like

... where oid = 'foo'::regwhatever

It's conceivable that we could move OID and all the reg* types into
their own category, but then the other time-honored locution of

... where oid = 25

would possibly give issues.

> It's probably not a big deal, but in this thread [1] it prevents me from
> adopting the nice solution with a boolean flag for `to_tsvector` function,
> because Postgres can't distinguish between `to_tsvector(regconfig, text)` and
> `to_tsvector(jsonb, boolean)` in the expression:

We are *not* putting these in category string. They are not strings.
Furthermore, if we did so because

> ... then everything will be fine,
> since a string type will win.

then the odds are very good that these types would start to "win" some
other cases that we'd rather they didn't.

> Also, it doesn't break any existing tests

Doesn't prove a thing. We do not have a suite of test cases exercising
whether the type resolution code will avoid doing the wrong thing.

I think you need to bite the bullet and just provide the flag in
the 3-argument case (regconfig,json[b],bool).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dent John 2018-04-05 13:41:15 Query Rewrite for Materialized Views (FDW Extension)
Previous Message Ernst-Georg Schmid 2018-04-05 13:20:52 AW: Get the name of the target Relation from Query struct?