Re: Does converting an indexed varchar to text rewrite its index?Docs say so, tests say no. - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Does converting an indexed varchar to text rewrite its index?Docs say so, tests say no.
Date
Msg-id f3a6e34e-ebc6-e740-0f6f-f79d7a568f76@aklaver.com
Whole thread Raw
In response to Re: Does converting an indexed varchar to text rewrite its index?Docs say so, tests say no.  (Mike Lissner <mlissner@michaeljaylissner.com>)
Responses Re: Does converting an indexed varchar to text rewrite its index? Docs say so, tests say no.
List pgsql-general
On 1/23/20 1:28 PM, Mike Lissner wrote:
> You wrote:
> 
>   > Well it did not rebuilt the index("t1_name_idx") you created on name.
> 
> 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. I say optional because you can do:

CREATE TABLE t2 (id serial PRIMARY KEY, name varchar);

So as I understand it when you are go from varchar to text you are not 
really changing type, just the type oid. I tried searching the source 
for confirmation of this to no avail. A definitive answer is going to 
need come from someone with more knowledge of the internals.




-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Mike Lissner
Date:
Subject: Re: Does converting an indexed varchar to text rewrite its index?Docs say so, tests say no.
Next
From: Tom Lane
Date:
Subject: Re: Does converting an indexed varchar to text rewrite its index? Docs say so, tests say no.