Skip to content

Commit 09ed012

Browse files
authored
Fix: pgrx cannot find function after numeric change interface (#410)
After CBDB public part of numeric defines, then numeric_is_nan/numeric_is_inf have been replace with macro NUMERIC_IS_NAN/NUMERIC_IS_INF. But some of extension may not write by c/c++, then it can't direct call the macro NUMERIC_IS_NAN/NUMERIC_IS_INF. So current change add these function back.
1 parent eaf4629 commit 09ed012

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

src/backend/utils/adt/numeric.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,51 @@ numeric_is_integral(Numeric num)
546546
return (arg.ndigits == 0 || arg.ndigits <= arg.weight + 1);
547547
}
548548

549+
550+
/*
551+
* numeric_is_nan() -
552+
*
553+
* Is Numeric value a NaN?
554+
*/
555+
bool
556+
numeric_is_nan(Numeric num)
557+
{
558+
return NUMERIC_IS_NAN(num);
559+
}
560+
561+
/*
562+
* numeric_digits() -
563+
*
564+
* Output function for numeric's digits
565+
*/
566+
NumericDigit *
567+
numeric_digits(Numeric num)
568+
{
569+
return NUMERIC_DIGITS(num);
570+
}
571+
572+
/*
573+
* numeric_len() -
574+
*
575+
* Output size of digits in bytes
576+
*/
577+
int
578+
numeric_len(Numeric num)
579+
{
580+
return NUMERIC_NDIGITS(num) * sizeof(NumericDigit);
581+
}
582+
583+
/*
584+
* numeric_is_inf() -
585+
*
586+
* Is Numeric value an infinity?
587+
*/
588+
bool
589+
numeric_is_inf(Numeric num)
590+
{
591+
return NUMERIC_IS_INF(num);
592+
}
593+
549594
/*
550595
* numeric_maximum_size() -
551596
*

src/include/utils/numeric.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ extern float8 numeric_li_fraction(Numeric x, Numeric x0, Numeric x1,
342342
bool *eq_bounds, bool *eq_abscissas);
343343
extern Numeric numeric_li_value(float8 f, Numeric y0, Numeric y1);
344344

345+
/*
346+
* Some of utility functions. which have same definition as the macro,
347+
* but some of extension will these function rather than use the marco
348+
* like `pgrx`.
349+
*/
350+
extern int16 *numeric_digits(Numeric num);
351+
extern int numeric_len(Numeric num);
352+
extern bool numeric_is_nan(Numeric num);
353+
extern bool numeric_is_inf(Numeric num);
354+
345355
/*
346356
* Utility functions in numeric.c
347357
*/

0 commit comments

Comments
 (0)