Problem with ALTER TYPE, Indexes and cast - Mailing list pgsql-general

From Marc Mamin
Subject Problem with ALTER TYPE, Indexes and cast
Date
Msg-id B6F6FD62F2624C4C9916AC0175D56D8828BF11F3@jenmbs01.ad.intershop.net
Whole thread Raw
Responses Re: Problem with ALTER TYPE, Indexes and cast  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello,

I plan to replace some btree indexes through btree_gin on some timed tables(e.g. monthly tables)
For this, I first need to change the data type from character(n) to varchar,
but I can't afford it on historical tables as this would be too time consuming, so only new tables should get the
varchartype. 

Now I have generated queries that include cast information in order to ensure that the indexes get used.

e.g.:  WHERE month1.foo = cast('XY' as character(2))

with mixed type, this should become something like:

 SELECT ... FROM month1
 WHERE month1.foo = cast('XY' as character(2))
 UNION ALL
 SELECT... FROM month2
 WHERE month2.foo = cast('XY' as varchar)

 which is quite complicated to resolve in our "query builder framework"


 There seems to be no way to have dynamic casting, something like:

  WHERE month2.foo = cast('XY' as 'month2.foo'::regtype)

 Is there a way for it ?


 regards,
 Marc Mamin


pgsql-general by date:

Previous
From: Karsten Hilbert
Date:
Subject: Re: [pg_hba.conf] publish own Python application using PostgreSQL
Next
From: John McKown
Date:
Subject: Re: [pg_hba.conf] publish own Python application using PostgreSQL