Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly
От | Thomas G. Lockhart |
---|---|
Тема | Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly |
Дата | |
Msg-id | 3521AAE2.2907AC5F@alumni.caltech.edu обсуждение исходный текст |
Ответы |
Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly
|
Список | pgsql-hackers |
> > I declared a column to be type "smallint". It works, except > > when I attempt to enter a negative number at which time the > > parser complains about its 'type'. See example, below. > > mdalphin=> insert into test values (-1); > > ERROR: parser: attribute 'number' is of type 'int2' but expression > > is of type 'int4' > This is a problem we have seen in a few places. It is caused by the > negative sign being handled in an unusual way. No fix known yet. There are two ways to address this for a fix as far as I can tell: 1) in the parser transformations (and/or in the optimizer), look for unary minus operators on constants, and convert those node subtrees to negative constant nodes. 2) try to do the right thing to convert types to be compatible with target columns. I'm working on this topic now, but I'm planning on addressing functions (first cut is done) and operators (starting now) before looking at target columns. Hopefully all three areas will be do-able. Anyone interested in looking at (1)? I think it would be a good thing to have even if (2) masks the problem away, unless of course the optimizer already gets rid of function calls on constants by executing them before run-time... - Tom
В списке pgsql-hackers по дате отправления: