Re: typcategory for regconfig - Mailing list pgsql-hackers

From Tom Lane
Subject Re: typcategory for regconfig
Date
Msg-id 10713.1522934867@sss.pgh.pa.us
Whole thread Raw
In response to typcategory for regconfig  (Dmitry Dolgov <9erthalion6@gmail.com>)
Responses Re: typcategory for regconfig
List pgsql-hackers
Dmitry Dolgov <9erthalion6@gmail.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


pgsql-hackers by date:

Previous
From: Ernst-Georg Schmid
Date:
Subject: AW: Get the name of the target Relation from Query struct?
Next
From: Dent John
Date:
Subject: Query Rewrite for Materialized Views (FDW Extension)