Re: Problem with ALTER TYPE, Indexes and cast
От | Tom Lane |
---|---|
Тема | Re: Problem with ALTER TYPE, Indexes and cast |
Дата | |
Msg-id | 20647.1436363033@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Problem with ALTER TYPE, Indexes and cast (Marc Mamin <M.Mamin@intershop.de>) |
Ответы |
Re: Problem with ALTER TYPE, Indexes and cast
|
Список | pgsql-general |
Marc Mamin <M.Mamin@intershop.de> writes: > 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 ? If the comparison values are always string literals, then you should just drop the casts altogether, ie WHERE month2.foo = 'XY' In this sort of situation the literal's type is preferentially resolved as being the same as whatever it's being compared to. regards, tom lane
В списке pgsql-general по дате отправления: