Skip to content

Commit

Permalink
Fix: pgrx cannot find function after numeric change interface (#410)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jiaqizho authored Apr 23, 2024
1 parent eaf4629 commit 09ed012
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/backend/utils/adt/numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,51 @@ numeric_is_integral(Numeric num)
return (arg.ndigits == 0 || arg.ndigits <= arg.weight + 1);
}


/*
* numeric_is_nan() -
*
* Is Numeric value a NaN?
*/
bool
numeric_is_nan(Numeric num)
{
return NUMERIC_IS_NAN(num);
}

/*
* numeric_digits() -
*
* Output function for numeric's digits
*/
NumericDigit *
numeric_digits(Numeric num)
{
return NUMERIC_DIGITS(num);
}

/*
* numeric_len() -
*
* Output size of digits in bytes
*/
int
numeric_len(Numeric num)
{
return NUMERIC_NDIGITS(num) * sizeof(NumericDigit);
}

/*
* numeric_is_inf() -
*
* Is Numeric value an infinity?
*/
bool
numeric_is_inf(Numeric num)
{
return NUMERIC_IS_INF(num);
}

/*
* numeric_maximum_size() -
*
Expand Down
10 changes: 10 additions & 0 deletions src/include/utils/numeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,16 @@ extern float8 numeric_li_fraction(Numeric x, Numeric x0, Numeric x1,
bool *eq_bounds, bool *eq_abscissas);
extern Numeric numeric_li_value(float8 f, Numeric y0, Numeric y1);

/*
* Some of utility functions. which have same definition as the macro,
* but some of extension will these function rather than use the marco
* like `pgrx`.
*/
extern int16 *numeric_digits(Numeric num);
extern int numeric_len(Numeric num);
extern bool numeric_is_nan(Numeric num);
extern bool numeric_is_inf(Numeric num);

/*
* Utility functions in numeric.c
*/
Expand Down

0 comments on commit 09ed012

Please sign in to comment.