Cleanup - Removal of apply_typmod function in #if 0
Hi,
One of the function apply_typmod in numeric.c file present within #if 0.
This is like this for many years.
I felt this can be removed.
Attached patch contains the changes to handle removal of apply_typmod
present in #if 0.
Thoughts?
Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com
Attachments:
0001-Cleanup-removal-of-function-present-in-if-0.patchapplication/octet-stream; name=0001-Cleanup-removal-of-function-present-in-if-0.patchDownload
From fb9bd89b1f1dafb6cac060a87806291126230c84 Mon Sep 17 00:00:00 2001
From: vignesh <vignesh@localhost.localdomain>
Date: Sat, 26 Oct 2019 13:54:57 +0530
Subject: [PATCH] Cleanup, removal of function present in #if 0.
Removal of unused function apply_typmod present in #if 0, this function has
been present within #if 0 from many years. This function can be removed safely.
---
src/interfaces/ecpg/pgtypeslib/numeric.c | 83 --------------------------------
1 file changed, 83 deletions(-)
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index b6ca2d3..ab65e14 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -22,89 +22,6 @@
free(buf); \
} while (0)
-
-#if 0
-/* ----------
- * apply_typmod() -
- *
- * Do bounds checking and rounding according to the attributes
- * typmod field.
- * ----------
- */
-static int
-apply_typmod(numeric *var, long typmod)
-{
- int precision;
- int scale;
- int maxweight;
- int i;
-
- /* Do nothing if we have a default typmod (-1) */
- if (typmod < (long) (VARHDRSZ))
- return 0;
-
- typmod -= VARHDRSZ;
- precision = (typmod >> 16) & 0xffff;
- scale = typmod & 0xffff;
- maxweight = precision - scale;
-
- /* Round to target scale */
- i = scale + var->weight + 1;
- if (i >= 0 && var->ndigits > i)
- {
- int carry = (var->digits[i] > 4) ? 1 : 0;
-
- var->ndigits = i;
-
- while (carry)
- {
- carry += var->digits[--i];
- var->digits[i] = carry % 10;
- carry /= 10;
- }
-
- if (i < 0)
- {
- var->digits--;
- var->ndigits++;
- var->weight++;
- }
- }
- else
- var->ndigits = Max(0, Min(i, var->ndigits));
-
- /*
- * Check for overflow - note we can't do this before rounding, because
- * rounding could raise the weight. Also note that the var's weight could
- * be inflated by leading zeroes, which will be stripped before storage
- * but perhaps might not have been yet. In any case, we must recognize a
- * true zero, whose weight doesn't mean anything.
- */
- if (var->weight >= maxweight)
- {
- /* Determine true weight; and check for all-zero result */
- int tweight = var->weight;
-
- for (i = 0; i < var->ndigits; i++)
- {
- if (var->digits[i])
- break;
- tweight--;
- }
-
- if (tweight >= maxweight && i < var->ndigits)
- {
- errno = PGTYPES_NUM_OVERFLOW;
- return -1;
- }
- }
-
- var->rscale = scale;
- var->dscale = scale;
- return 0;
-}
-#endif
-
/* ----------
* alloc_var() -
*
--
1.8.3.1
On 2019-10-26 10:36, vignesh C wrote:
One of the function apply_typmod in numeric.c file present within #if 0.
This is like this for many years.
I felt this can be removed.
Attached patch contains the changes to handle removal of apply_typmod
present in #if 0.
committed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Mon, Mar 2, 2020 at 1:27 PM Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
On 2019-10-26 10:36, vignesh C wrote:
One of the function apply_typmod in numeric.c file present within #if 0.
This is like this for many years.
I felt this can be removed.
Attached patch contains the changes to handle removal of apply_typmod
present in #if 0.committed
Thanks Peter for committing.
Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com