Thread: pgsql: Re-implement division for numeric values using the traditional
pgsql: Re-implement division for numeric values using the traditional
From
tgl@postgresql.org (Tom Lane)
Date:
Log Message: ----------- Re-implement division for numeric values using the traditional "schoolbook" algorithm. This is a good deal slower than our old roundoff-error-prone code for long inputs, so we keep the old code for use in the transcendental functions, where everything is approximate anyway. Also create a user-accessible function div(numeric, numeric) to provide access to the exact result of trunc(x/y) --- since the regular numeric / operator will round off its result, simply computing that expression in SQL doesn't reliably give the desired answer. This fixes bug #3387 and various related corner cases, and improves the usefulness of PG for high-precision integer arithmetic. Modified Files: -------------- pgsql/doc/src/sgml: func.sgml (r1.426 -> r1.427) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/func.sgml?r1=1.426&r2=1.427) pgsql/src/backend/utils/adt: numeric.c (r1.108 -> r1.109) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/numeric.c?r1=1.108&r2=1.109) pgsql/src/include/catalog: catversion.h (r1.444 -> r1.445) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.444&r2=1.445) pg_proc.h (r1.486 -> r1.487) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h?r1=1.486&r2=1.487) pgsql/src/include/utils: builtins.h (r1.311 -> r1.312) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/builtins.h?r1=1.311&r2=1.312) pgsql/src/test/regress/expected: numeric.out (r1.21 -> r1.22) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/numeric.out?r1=1.21&r2=1.22) pgsql/src/test/regress/sql: numeric.sql (r1.14 -> r1.15) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/numeric.sql?r1=1.14&r2=1.15)