Re: [HACKERS] different results selecting from base tables or views
От | Thomas G. Lockhart |
---|---|
Тема | Re: [HACKERS] different results selecting from base tables or views |
Дата | |
Msg-id | 36A4984E.DDBD806B@alumni.caltech.edu обсуждение исходный текст |
Ответ на | different results selecting from base tables or views (Matthias Schmitt <freak001@mmp.lu>) |
Список | pgsql-hackers |
> I discovered different results when selecting data from base tables or > their views. The only thing I can image for this strange behaviour is > using the date constant 'today' when creating the view. Does 'today' > in a view use the current day time of the view creation or the time > the query is made? That is probably the problem. For most data types, a string constant is really constant, and Postgres evaluates it once, during parsing. For a few data types this is not correct behavior, since the "constant" should be evaluated at run time. The workaround, at least in some cases, is to force the string constant to be a real string type. Postgres will then do the conversion to your intended type at run time. I'm not sure what your view looks like, but the same issue comes up when defining default values for columns: create table t1 (d datetime default 'now'); gives unexpected results, while create table t2 (d datetime default text 'now'); does what you would (presumably) prefer. - Tom
В списке pgsql-hackers по дате отправления: