From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Mike Lissner <mlissner@michaeljaylissner.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Does converting an indexed varchar to text rewrite its index? Docs say so, tests say no.
Date: Thu, 23 Jan 2020 17:21:40 -0500
Message-ID: <21237.1579818100@sss.pgh.pa.us> (raw)
In-Reply-To: <f3a6e34e-ebc6-e740-0f6f-f79d7a568f76@aklaver.com>
References: <CAMp9=ExXtH0NeF+LTsNrew_oXycAJTNVKbRYnqgoEAT01t=67A@mail.gmail.com>
<18e832ea-4bae-8c47-fdfe-e2cf316f52ce@aklaver.com>
<CAMp9=EyEMDKswjY5r9F7B0b2_FaeY_oYVbze=aeBTEExuaC7RQ@mail.gmail.com>
<7c433efb-0a46-1ab2-930a-04e83efa31af@aklaver.com>
<CAMp9=EyRZdxNR1+_gO-odzhqNREiOYPRvA8+XT80U7_Wy=x=ng@mail.gmail.com>
<f3a6e34e-ebc6-e740-0f6f-f79d7a568f76@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 1/23/20 1:28 PM, Mike Lissner wrote:
>> OK, so then the docs *are* wrong? They say that:
>>> any indexes on the affected columns must still be rebuilt.
>> But that doesn't happen? Sorry to be persistent. I'm just a bit confused
>> here.
> My guess is that it is because in Postgres varchar is just text with an
> optional length restriction.
More directly, it's because varchar piggybacks on text's operators and
index opclass. If we've decided that we don't need to rewrite the table,
and if indexcmds.c's CheckIndexCompatible() says that the old and new
index definitions are 100% compatible, then we skip rebuilding the index
contents as well. But you need the same opclasses to be compatible.
Commit 367bc426a, which added that behavior, seems to have been a lot
lazier about updating the user-facing docs than it should've been.
I can agree with the position that all the weird little cases in
CheckIndexCompatible() are a bit much to be documenting, but not
changing the ALTER TABLE reference page at all seems inadequate.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, mlissner@michaeljaylissner.com
Subject: Re: Does converting an indexed varchar to text rewrite its index? Docs say so, tests say no.
In-Reply-To: <21237.1579818100@sss.pgh.pa.us>
References: <CAMp9=ExXtH0NeF+LTsNrew_oXycAJTNVKbRYnqgoEAT01t=67A@mail.gmail.com> <18e832ea-4bae-8c47-fdfe-e2cf316f52ce@aklaver.com> <CAMp9=EyEMDKswjY5r9F7B0b2_FaeY_oYVbze=aeBTEExuaC7RQ@mail.gmail.com> <7c433efb-0a46-1ab2-930a-04e83efa31af@aklaver.com> <CAMp9=EyRZdxNR1+_gO-odzhqNREiOYPRvA8+XT80U7_Wy=x=ng@mail.gmail.com> <f3a6e34e-ebc6-e740-0f6f-f79d7a568f76@aklaver.com> <21237.1579818100@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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