diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 614f557..23cb6fa 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -5409,10 +5409,8 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})'); EEEE (scientific notation) cannot be used in combination with any of the other special formatting patterns or - modifiers, must be at the end of the format string, and requires a - format with exactly one digit before the decimal point. (E.g., - 9.99EEEE is a valid pattern, but - 99.99EEEE is not.) + modifiers and must be at the end of the format string + (e.g., 9.99EEEE is a valid pattern). diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 30d7b8a..4d0ed30 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -492,20 +492,6 @@ do { \ errhint("Intervals are not tied to specific calendar dates."))); \ } while(0) -/* - * When using scientific notation (EEEE) the numeric format must have exactly - * one digit prior to the decimal place. - */ -#define VERIFY_EEEE_FORMAT(_X) \ -do { \ - if (_X.pre != 1) \ - ereport(ERROR, \ - (errcode(ERRCODE_SYNTAX_ERROR), \ - errmsg("invalid format for scientific notation"), \ - errdetail("\"EEEE\" requires exactly one digit before the decimal point."), \ - errhint("For example, \"9.999EEEE\" is a valid format."))); \ -} while(0) - /***************************************************************************** * KeyWord definitions *****************************************************************************/ @@ -853,7 +839,7 @@ static const KeyWord NUM_keywords[] = { {"b", 1, NUM_B}, /* b */ {"c", 1, NUM_C}, /* c */ {"d", 1, NUM_D}, /* d */ - {"e", 1, NUM_E}, /* e */ + {"eeee", 4, NUM_E}, /* e */ {"fm", 2, NUM_FM}, /* f */ {"g", 1, NUM_G}, /* g */ {"l", 1, NUM_L}, /* l */ @@ -4679,8 +4665,6 @@ numeric_to_char(PG_FUNCTION_ARGS) { float8 val; - VERIFY_EEEE_FORMAT(Num); - val = DatumGetFloat8(DirectFunctionCall1(numeric_float8, NumericGetDatum(value))); @@ -4779,8 +4763,6 @@ int4_to_char(PG_FUNCTION_ARGS) float8 val = (float8) value; numstr = orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1); - VERIFY_EEEE_FORMAT(Num); - snprintf(orgnum, MAXDOUBLEWIDTH + 1, "%.*e", Num.post, val); } else @@ -4866,7 +4848,6 @@ int8_to_char(PG_FUNCTION_ARGS) float8 val = (float8) value; numstr = orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1); - VERIFY_EEEE_FORMAT(Num); len = snprintf(orgnum, MAXDOUBLEWIDTH + 1, "%.*e", Num.post, val); if (len > Num.pre + Num.post + 5) @@ -4953,8 +4934,6 @@ float4_to_char(PG_FUNCTION_ARGS) else if (IS_EEEE(&Num)) { numstr = orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1); - VERIFY_EEEE_FORMAT(Num); - if (isnan(value) || is_infinite(value)) { numstr = (char *) palloc(Num.pre + Num.post + 6); @@ -5042,8 +5021,6 @@ float8_to_char(PG_FUNCTION_ARGS) else if (IS_EEEE(&Num)) { numstr = orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1); - VERIFY_EEEE_FORMAT(Num); - len = snprintf(orgnum, MAXDOUBLEWIDTH + 1, "%.*e", Num.post, value); if (isnan(value) || is_infinite(value) || len > Num.pre + Num.post + 5)