Re: Precision of calculated numeric fields
От | Tom Lane |
---|---|
Тема | Re: Precision of calculated numeric fields |
Дата | |
Msg-id | 24397.960307850@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Precision of calculated numeric fields (Travis Bauer <trbauer@indiana.edu>) |
Ответы |
Re: Precision of calculated numeric fields
|
Список | pgsql-general |
Travis Bauer <trbauer@indiana.edu> writes: > Consider the following: > trbauer=# create table t1 (x numberic(3,2)); > trbauer=# \d t1 > Attribute | Type | Modifier > ------------------------------------ > X | numeric(3,2) | > trbauer=# create view v1 as select x*2 from t1; > trbauer=# \d v1 > Attribute | Type | Modifier > ------------------------------------------- > ?column? | numeric(65535,65531) | > How do I get the precision on the calculated numeric field to be something > sane, like 3,2? You don't --- there isn't any way to specify the types of view columns. The view is being created with typmod -1 for the numeric column, which is correct behavior IMHO. The bug here is in psql: it should be showing the column type as plain "numeric", no decoration. > This is important for three reasons: 1.MSAccess chokes on views > containing these fields (citing the precision size). 2. The jdbc driver > takes _forever_ to retrieve these fields into big decimal. Sounds like the jdbc driver also gets confused when it sees typmod -1 for a numeric field. As a short-term workaround you could manually set pg_attribute's atttypmod column for the view's field. Use the same value you find in atttypmod for the underlying table's field. regards, tom lane
В списке pgsql-general по дате отправления: