!5965 A库模式,在词法中提前判断浮点数常量是否溢出
Merge pull request !5965 from zhubin79/tbf-def
This commit is contained in:
@ -114,6 +114,7 @@ static void addunicode(pg_wchar c, yyscan_t yyscanner);
|
||||
static void set_is_delimiter_name(char* text, core_yyscan_t yyscanner );
|
||||
static int process_decimal_float(char *token, int len, core_yyscan_t yyscanner, YYSTYPE *lval);
|
||||
static int process_decimal_double(char *token, int len, core_yyscan_t yyscanner, YYSTYPE *lval);
|
||||
static char *handle_float_overflow(char *token, core_yyscan_t yyscanner);
|
||||
|
||||
#define yyerror(msg) scanner_yyerror(msg, yyscanner)
|
||||
|
||||
@ -1040,7 +1041,9 @@ other .
|
||||
}
|
||||
{decimal} {
|
||||
SET_YYLLOC();
|
||||
yylval->str = pstrdup(yytext);
|
||||
char* val = pstrdup(yytext);
|
||||
val = handle_float_overflow(val, yyscanner);
|
||||
yylval->str = pstrdup(val);
|
||||
yyextra->is_hint_str = false;
|
||||
return FCONST;
|
||||
}
|
||||
@ -1109,7 +1112,9 @@ other .
|
||||
}
|
||||
{real} {
|
||||
SET_YYLLOC();
|
||||
yylval->str = pstrdup(yytext);
|
||||
char* val = pstrdup(yytext);
|
||||
val = handle_float_overflow(val, yyscanner);
|
||||
yylval->str = pstrdup(val);
|
||||
yyextra->is_hint_str = false;
|
||||
return FCONST;
|
||||
}
|
||||
@ -1600,7 +1605,9 @@ process_decimal_float(char *token, int len, core_yyscan_t yyscanner, YYSTYPE *lv
|
||||
{
|
||||
startlit();
|
||||
addlit(token, len-1, yyscanner);
|
||||
lval->str = litbufdup(yyscanner);
|
||||
char *val = litbufdup(yyscanner);
|
||||
val = handle_float_overflow(val, yyscanner);
|
||||
lval->str = val;
|
||||
return FCONST_F;
|
||||
}
|
||||
|
||||
@ -1609,10 +1616,41 @@ process_decimal_double(char *token, int len, core_yyscan_t yyscanner, YYSTYPE *l
|
||||
{
|
||||
startlit();
|
||||
addlit(token, len-1, yyscanner);
|
||||
lval->str = litbufdup(yyscanner);
|
||||
char *val = litbufdup(yyscanner);
|
||||
val = handle_float_overflow(val, yyscanner);
|
||||
lval->str = val;
|
||||
return FCONST_D;
|
||||
}
|
||||
|
||||
/* prejudge whether float const overflow */
|
||||
static char *
|
||||
handle_float_overflow(char *token, core_yyscan_t yyscanner)
|
||||
{
|
||||
|
||||
double val;
|
||||
char *endptr;
|
||||
char *result = token;
|
||||
|
||||
if (u_sess->attr.attr_sql.sql_compatibility != A_FORMAT) {
|
||||
return result;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
val = strtod(result, &endptr);
|
||||
|
||||
// if val < 1E-130, we assume it is 0
|
||||
if (val != 0 && log10(val) < -130) {
|
||||
result = "0";
|
||||
} else if (errno == ERANGE) {
|
||||
if (val == 0.0) {
|
||||
result = "0";
|
||||
} else {
|
||||
yyerror("number overflow");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
hexval(unsigned char c)
|
||||
{
|
||||
|
@ -1646,7 +1646,9 @@ EXECUTE isnan_num(11, 1.23E-100);
|
||||
EXECUTE isnan_num(12, -1.79E+100);
|
||||
EXECUTE isnan_num(13, 1.79E+100);
|
||||
EXECUTE isnan_num(14, 1.79E+400);
|
||||
ERROR: "17900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: EXECUTE isnan_num(14, 1.79E+400);
|
||||
^
|
||||
EXECUTE isnan_num(15, CAST('NaN' as float8));
|
||||
EXECUTE isnan_num(16, CAST('Inf' as float8));
|
||||
SELECT * FROM tnf2 ORDER BY c1;
|
||||
|
268
src/test/regress/expected/float_literals.out
Normal file
268
src/test/regress/expected/float_literals.out
Normal file
@ -0,0 +1,268 @@
|
||||
-- test float literals overflow in dbcompatibility A
|
||||
create database float_literals dbcompatibility 'A';
|
||||
\c float_literals
|
||||
SELECT 0.0;
|
||||
?column?
|
||||
----------
|
||||
0.0
|
||||
(1 row)
|
||||
|
||||
SELECT -0.0;
|
||||
?column?
|
||||
----------
|
||||
0.0
|
||||
(1 row)
|
||||
|
||||
SELECT 3.142596;
|
||||
?column?
|
||||
----------
|
||||
3.142596
|
||||
(1 row)
|
||||
|
||||
SELECT -3.142596;
|
||||
?column?
|
||||
-----------
|
||||
-3.142596
|
||||
(1 row)
|
||||
|
||||
SELECT 1.79E+400;
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT 1.79E+400;
|
||||
^
|
||||
SELECT 1.79E-400;
|
||||
?column?
|
||||
----------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT -1.79E+400;
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT -1.79E+400;
|
||||
^
|
||||
SELECT '0.0';
|
||||
?column?
|
||||
----------
|
||||
0.0
|
||||
(1 row)
|
||||
|
||||
SELECT '-0.0';
|
||||
?column?
|
||||
----------
|
||||
-0.0
|
||||
(1 row)
|
||||
|
||||
SELECT '3.142596';
|
||||
?column?
|
||||
----------
|
||||
3.142596
|
||||
(1 row)
|
||||
|
||||
SELECT '-3.142596';
|
||||
?column?
|
||||
-----------
|
||||
-3.142596
|
||||
(1 row)
|
||||
|
||||
SELECT '1.79E+400';
|
||||
?column?
|
||||
-----------
|
||||
1.79E+400
|
||||
(1 row)
|
||||
|
||||
SELECT '1.79E-400';
|
||||
?column?
|
||||
-----------
|
||||
1.79E-400
|
||||
(1 row)
|
||||
|
||||
SELECT '-1.79E+400';
|
||||
?column?
|
||||
------------
|
||||
-1.79E+400
|
||||
(1 row)
|
||||
|
||||
SELECT '0.0'::float8;
|
||||
float8
|
||||
--------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT '-0.0'::float8;
|
||||
float8
|
||||
--------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT '3.142596'::float8;
|
||||
float8
|
||||
----------
|
||||
3.142596
|
||||
(1 row)
|
||||
|
||||
SELECT '-3.142596'::float8;
|
||||
float8
|
||||
-----------
|
||||
-3.142596
|
||||
(1 row)
|
||||
|
||||
SELECT '1.79E+400'::float8;
|
||||
ERROR: "1.79E+400" is out of range for type double precision
|
||||
LINE 1: SELECT '1.79E+400'::float8;
|
||||
^
|
||||
CONTEXT: referenced column: float8
|
||||
SELECT '1.79E-400'::float8;
|
||||
ERROR: "1.79E-400" is out of range for type double precision
|
||||
LINE 1: SELECT '1.79E-400'::float8;
|
||||
^
|
||||
CONTEXT: referenced column: float8
|
||||
SELECT '-1.79E+400'::float8;
|
||||
ERROR: "-1.79E+400" is out of range for type double precision
|
||||
LINE 1: SELECT '-1.79E+400'::float8;
|
||||
^
|
||||
CONTEXT: referenced column: float8
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT y ON CONVERSION ERROR);
|
||||
ERROR: column "y" does not exist
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14 DEFAULT y ON CONVERSION ERROR);
|
||||
^
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(-3.14 DEFAULT + ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "ON CONVERSION ERROR"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(-3.14 DEFAULT + ON CONVERSION ERROR);
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT - ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "ON CONVERSION ERROR"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14 DEFAULT - ON CONVERSION ERROR);
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(-3.14 DEFAULT * ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "*"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(-3.14 DEFAULT * ON CONVERSION ERROR);
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT / ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "/"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14 DEFAULT / ON CONVERSION ERROR);
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT y ON CONVERSION ERROR);
|
||||
ERROR: column "y" does not exist
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('3.14' DEFAULT y ON CONVERSION ERROR)...
|
||||
^
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('-3.14' DEFAULT + ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "ON CONVERSION ERROR"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('-3.14' DEFAULT + ON CONVERSION ERROR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT - ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "ON CONVERSION ERROR"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('3.14' DEFAULT - ON CONVERSION ERROR)...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('-3.14' DEFAULT * ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "*"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('-3.14' DEFAULT * ON CONVERSION ERROR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT / ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "/"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('3.14' DEFAULT / ON CONVERSION ERROR)...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT y ON CONVERSION ERROR);
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT y ON CONVERSION ERR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT + ON CONVERSION ERROR);
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT + ON CONVERSION ERR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT - ON CONVERSION ERROR);
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT - ON CONVERSION ERR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT * ON CONVERSION ERROR);
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT * ON CONVERSION ERR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT / ON CONVERSION ERROR);
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT / ON CONVERSION ERR...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('1.79E+400' DEFAULT y ON CONVERSION ERROR);
|
||||
ERROR: column "y" does not exist
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('1.79E+400' DEFAULT y ON CONVERSION E...
|
||||
^
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT('1.79E-400' DEFAULT + ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "ON CONVERSION ERROR"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('1.79E-400' DEFAULT + ON CONVERSION E...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('-1.79E+400' DEFAULT - ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "ON CONVERSION ERROR"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('-1.79E+400' DEFAULT - ON CONVERSION ...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('-1.79E-400' DEFAULT * ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "*"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('-1.79E-400' DEFAULT * ON CONVERSION ...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('1.79E+400' DEFAULT / ON CONVERSION ERROR);
|
||||
ERROR: syntax error at or near "/"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('1.79E+400' DEFAULT / ON CONVERSION E...
|
||||
^
|
||||
CREATE TABLE t_float_literals (id int, c1 float8);
|
||||
INSERT INTO t_float_literals VALUES (1, 0.0);
|
||||
INSERT INTO t_float_literals VALUES (2, 3.14);
|
||||
INSERT INTO t_float_literals VALUES (3, 3.14E+40);
|
||||
INSERT INTO t_float_literals VALUES (4, -3.14E+40);
|
||||
INSERT INTO t_float_literals VALUES (5, '3.14E+40'::float8);
|
||||
INSERT INTO t_float_literals VALUES (6, '-3.14E+40'::float8);
|
||||
INSERT INTO t_float_literals VALUES (7, 3.14E+400);
|
||||
ERROR: number overflow at or near "3.14E+400"
|
||||
LINE 1: INSERT INTO t_float_literals VALUES (7, 3.14E+400);
|
||||
^
|
||||
INSERT INTO t_float_literals VALUES (8, 3.14E-400);
|
||||
INSERT INTO t_float_literals VALUES (9, -3.14E+400);
|
||||
ERROR: number overflow at or near "3.14E+400"
|
||||
LINE 1: INSERT INTO t_float_literals VALUES (9, -3.14E+400);
|
||||
^
|
||||
INSERT INTO t_float_literals VALUES (10, '3.14E+400'::float8);
|
||||
ERROR: "3.14E+400" is out of range for type double precision
|
||||
LINE 1: INSERT INTO t_float_literals VALUES (10, '3.14E+400'::float8...
|
||||
^
|
||||
INSERT INTO t_float_literals VALUES (11, '3.14E-400'::float8);
|
||||
ERROR: "3.14E-400" is out of range for type double precision
|
||||
LINE 1: INSERT INTO t_float_literals VALUES (11, '3.14E-400'::float8...
|
||||
^
|
||||
INSERT INTO t_float_literals VALUES (12, '-3.14E+400'::float8);
|
||||
ERROR: "-3.14E+400" is out of range for type double precision
|
||||
LINE 1: INSERT INTO t_float_literals VALUES (12, '-3.14E+400'::float...
|
||||
^
|
||||
SELECT * FROM t_float_literals ORDER bY id;
|
||||
id | c1
|
||||
----+-----------
|
||||
1 | 0
|
||||
2 | 3.14
|
||||
3 | 3.14e+40
|
||||
4 | -3.14e+40
|
||||
5 | 3.14e+40
|
||||
6 | -3.14e+40
|
||||
8 | 0
|
||||
(7 rows)
|
||||
|
||||
UPDATE t_float_iterals SET c1 = 1.79E+400 WHERE id = 1;
|
||||
ERROR: number overflow at or near "1.79E+400"
|
||||
LINE 1: UPDATE t_float_iterals SET c1 = 1.79E+400 WHERE id = 1;
|
||||
^
|
||||
UPDATE t_float_iterals SET c1 = '1.79E+400'::float8 WHERE id = 2;
|
||||
ERROR: relation "t_float_iterals" does not exist on datanode1
|
||||
LINE 1: UPDATE t_float_iterals SET c1 = '1.79E+400'::float8 WHERE id...
|
||||
^
|
||||
UPDATE t_float_iterals SET c1 = 1.79E+40 WHERE id = 3;
|
||||
ERROR: relation "t_float_iterals" does not exist on datanode1
|
||||
LINE 1: UPDATE t_float_iterals SET c1 = 1.79E+40 WHERE id = 3;
|
||||
^
|
||||
UPDATE t_float_iterals SET c1 = '1.79E+40'::float8 WHERE id = 4;
|
||||
ERROR: relation "t_float_iterals" does not exist on datanode1
|
||||
LINE 1: UPDATE t_float_iterals SET c1 = '1.79E+40'::float8 WHERE id ...
|
||||
^
|
||||
SELECT * FROM t_float_iterals ORDER BY c1;
|
||||
ERROR: relation "t_float_iterals" does not exist on datanode1
|
||||
LINE 1: SELECT * FROM t_float_iterals ORDER BY c1;
|
||||
^
|
||||
drop table t_float_literals;
|
||||
\c regression
|
||||
drop database float_literals;
|
@ -102,8 +102,9 @@ SELECT TO_BINARY_FLOAT(2.22507485850720E-100);
|
||||
(1 row)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+310); -- error: overflow
|
||||
ERROR: "17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "1.79769313486231E+310"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79769313486231E+310);
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('1.79769313486231E+100');
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -459,10 +460,9 @@ SELECT TO_BINARY_FLOAT('test' DEFAULT 3.04E+100 ON CONVERSION ERROR);
|
||||
|
||||
-- test default column
|
||||
SELECT TO_BINARY_FLOAT(1.79E+309 DEFAULT y ON CONVERSION ERROR);
|
||||
ERROR: column "y" does not exist
|
||||
ERROR: number overflow at or near "1.79E+309"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79E+309 DEFAULT y ON CONVERSION ERR...
|
||||
^
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(c3 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1;
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -532,11 +532,13 @@ SELECT TO_BINARY_FLOAT(3.14E+100 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER
|
||||
(8 rows)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- overflow
|
||||
ERROR: "31400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "3.14E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c3 ON CONVERSION ER...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- overflow
|
||||
ERROR: "31400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "3.14E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT c4 ON CONVERSION ER...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
@ -561,6 +563,14 @@ CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
ERROR: default argument must be a literal or bind
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT ab ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- overflow
|
||||
ERROR: number overflow at or near "3.14E+400"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT ab ON CONVERSION ER...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400 DEFAULT' ab ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
ERROR: syntax error at or near "ab"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT('3.14E+400 DEFAULT' ab ON CONVERSION ...
|
||||
^
|
||||
-- test overflow and null
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT 3.14 ON CONVERSION ERROR);
|
||||
to_binary_float
|
||||
@ -587,8 +597,9 @@ SELECT TO_BINARY_FLOAT('2.22507485850720E-100' DEFAULT 3.14 ON CONVERSION ERROR)
|
||||
(1 row)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+310 DEFAULT 3.14 ON CONVERSION ERROR); -- error: overflow
|
||||
ERROR: "17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "1.79769313486231E+310"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79769313486231E+310 DEFAULT 3.14 ON...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('1.79769313486231E+310' DEFAULT 3.14 ON CONVERSION ERROR); -- inf
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -608,8 +619,9 @@ SELECT TO_BINARY_FLOAT(3.14 DEFAULT '1.79769313486231E+100' ON CONVERSION ERROR)
|
||||
(1 row)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT 1.79769313486231E+310 ON CONVERSION ERROR); -- error: overflow
|
||||
ERROR: "17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "1.79769313486231E+310"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(3.14 DEFAULT 1.79769313486231E+310 ON...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT '1.79769313486231E+310' ON CONVERSION ERROR);
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -629,8 +641,9 @@ SELECT TO_BINARY_FLOAT('1.79769313486231E+100' DEFAULT NULL ON CONVERSION ERROR)
|
||||
(1 row)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+310 DEFAULT NULL ON CONVERSION ERROR); -- error: overflow
|
||||
ERROR: "17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "1.79769313486231E+310"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(1.79769313486231E+310 DEFAULT NULL ON...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT('1.79769313486231E+310' DEFAULT NULL ON CONVERSION ERROR); -- inf
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -650,8 +663,9 @@ SELECT TO_BINARY_FLOAT(NULL DEFAULT '1.79769313486231E+100' ON CONVERSION ERROR)
|
||||
(1 row)
|
||||
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT 1.79769313486231E+310 ON CONVERSION ERROR); -- error: overflow
|
||||
ERROR: "17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: to_binary_float
|
||||
ERROR: number overflow at or near "1.79769313486231E+310"
|
||||
LINE 1: SELECT TO_BINARY_FLOAT(NULL DEFAULT 1.79769313486231E+310 ON...
|
||||
^
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT '1.79769313486231E+310' ON CONVERSION ERROR); -- NULL
|
||||
to_binary_float
|
||||
-----------------
|
||||
@ -746,9 +760,21 @@ EXECUTE default_param_text2(13, NULL, 3.14);
|
||||
EXECUTE default_param_text2(14, 1.79769313486231E+100, 3.14);
|
||||
EXECUTE default_param_text2(15, 3.14, 1.79769313486231E+100);
|
||||
EXECUTE default_param_text2(16, 1.79769313486231E+400, 3.14);
|
||||
ERROR: number overflow at or near "1.79769313486231E+400"
|
||||
LINE 1: EXECUTE default_param_text2(16, 1.79769313486231E+400, 3.14)...
|
||||
^
|
||||
EXECUTE default_param_text2(17, 3.14, 1.79769313486231E+400);
|
||||
ERROR: number overflow at or near "1.79769313486231E+400"
|
||||
LINE 1: EXECUTE default_param_text2(17, 3.14, 1.79769313486231E+400)...
|
||||
^
|
||||
EXECUTE default_param_text2(18, 1.79769313486231E+400, NULL);
|
||||
ERROR: number overflow at or near "1.79769313486231E+400"
|
||||
LINE 1: EXECUTE default_param_text2(18, 1.79769313486231E+400, NULL)...
|
||||
^
|
||||
EXECUTE default_param_text2(19, NULL, 1.79769313486231E+400);
|
||||
ERROR: number overflow at or near "1.79769313486231E+400"
|
||||
LINE 1: EXECUTE default_param_text2(19, NULL, 1.79769313486231E+400)...
|
||||
^
|
||||
PREPARE default_param_text_num(int, text, float8) AS INSERT INTO t2 VALUES ($1, CONCAT('TO_BINARY_FLOAT(', $2, ' DEFAULT ', $3, ' ON CONVERSION ERROR)'), TO_BINARY_FLOAT($2 DEFAULT $3 ON CONVERSION ERROR));
|
||||
ERROR: relation "t2" does not exist on datanode1
|
||||
LINE 1: ..._param_text_num(int, text, float8) AS INSERT INTO t2 VALUES ...
|
||||
@ -759,43 +785,43 @@ EXECUTE default_param_text2(22, '1.79769313486231E+100', 6.666666);
|
||||
EXECUTE default_param_text2(23, '6.666666', 1.79769313486231E+100);
|
||||
EXECUTE default_param_text2(24, '1.79769313486231E+400', 6.666666);
|
||||
EXECUTE default_param_text2(25, '6.666666', 1.79769313486231E+400);
|
||||
ERROR: number overflow at or near "1.79769313486231E+400"
|
||||
LINE 1: EXECUTE default_param_text2(25, '6.666666', 1.79769313486231...
|
||||
^
|
||||
PREPARE default_param_num_text(int, float8, text) AS INSERT INTO tbf2 VALUES ($1, CONCAT('TO_BINARY_FLOAT(', $2, ' DEFAULT ', $3, ' ON CONVERSION ERROR)'), TO_BINARY_FLOAT($2 DEFAULT $3 ON CONVERSION ERROR));
|
||||
EXECUTE default_param_text2(26, 1.79769313486231E+100, '6.666666');
|
||||
EXECUTE default_param_text2(27, 6.666666, '1.79769313486231E+100');
|
||||
EXECUTE default_param_text2(28, 1.79769313486231E+400, '6.666666');
|
||||
ERROR: number overflow at or near "1.79769313486231E+400"
|
||||
LINE 1: EXECUTE default_param_text2(28, 1.79769313486231E+400, '6.66...
|
||||
^
|
||||
EXECUTE default_param_text2(29, 6.666666, '1.79769313486231E+400');
|
||||
SELECT * FROM tbf2 ORDER BY c1;
|
||||
c1 | func_info | res
|
||||
----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------
|
||||
1 | TO_BINARY_FLOAT(3.14 DEFAULT 6.66 ON CONVERSION ERROR) | 3.14
|
||||
2 | TO_BINARY_FLOAT(3.14# DEFAULT 6.66 ON CONVERSION ERROR) | 6.66
|
||||
4 | TO_BINARY_FLOAT( -3.14 DEFAULT 6.66 ON CONVERSION ERROR) | -3.14
|
||||
5 | TO_BINARY_FLOAT( DEFAULT 6.66 ON CONVERSION ERROR) |
|
||||
6 | TO_BINARY_FLOAT(6.66 DEFAULT ON CONVERSION ERROR) | 6.66
|
||||
7 | TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT ON CONVERSION ERROR) | Infinity
|
||||
8 | TO_BINARY_FLOAT( DEFAULT 1.79769313486231E+100 ON CONVERSION ERROR) |
|
||||
9 | TO_BINARY_FLOAT(1.79769313486231E+400 DEFAULT ON CONVERSION ERROR) | Infinity
|
||||
10 | TO_BINARY_FLOAT( DEFAULT 1.79769313486231E+400 ON CONVERSION ERROR) |
|
||||
11 | TO_BINARY_FLOAT(3.14 DEFAULT 6.666666 ON CONVERSION ERROR) | 3.14
|
||||
12 | TO_BINARY_FLOAT(3.14 DEFAULT ON CONVERSION ERROR) | 3.14
|
||||
13 | TO_BINARY_FLOAT( DEFAULT 3.14 ON CONVERSION ERROR) |
|
||||
14 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT 3.14 ON CONVERSION ERROR) | Infinity
|
||||
15 | TO_BINARY_FLOAT(3.14 DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) | 3.14
|
||||
16 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT 3.14 ON CONVERSION ERROR) | Infinity
|
||||
17 | TO_BINARY_FLOAT(3.14 DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) | 3.14
|
||||
18 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT ON CONVERSION ERROR) | Infinity
|
||||
19 | TO_BINARY_FLOAT( DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) |
|
||||
20 | TO_BINARY_FLOAT(3.14 DEFAULT 6.666666 ON CONVERSION ERROR) | 3.14
|
||||
21 | TO_BINARY_FLOAT( +3.14 DEFAULT 6.666666 ON CONVERSION ERROR) | 3.14
|
||||
22 | TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
23 | TO_BINARY_FLOAT(6.666666 DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) | 6.66667
|
||||
24 | TO_BINARY_FLOAT(1.79769313486231E+400 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
25 | TO_BINARY_FLOAT(6.666666 DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) | 6.66667
|
||||
26 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
27 | TO_BINARY_FLOAT(6.666666 DEFAULT 1.79769313486231E+100 ON CONVERSION ERROR) | 6.66667
|
||||
28 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
29 | TO_BINARY_FLOAT(6.666666 DEFAULT 1.79769313486231E+400 ON CONVERSION ERROR) | 6.66667
|
||||
(28 rows)
|
||||
c1 | func_info | res
|
||||
----+-------------------------------------------------------------------------------------------------------------------------------------------------------------+----------
|
||||
1 | TO_BINARY_FLOAT(3.14 DEFAULT 6.66 ON CONVERSION ERROR) | 3.14
|
||||
2 | TO_BINARY_FLOAT(3.14# DEFAULT 6.66 ON CONVERSION ERROR) | 6.66
|
||||
4 | TO_BINARY_FLOAT( -3.14 DEFAULT 6.66 ON CONVERSION ERROR) | -3.14
|
||||
5 | TO_BINARY_FLOAT( DEFAULT 6.66 ON CONVERSION ERROR) |
|
||||
6 | TO_BINARY_FLOAT(6.66 DEFAULT ON CONVERSION ERROR) | 6.66
|
||||
7 | TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT ON CONVERSION ERROR) | Infinity
|
||||
8 | TO_BINARY_FLOAT( DEFAULT 1.79769313486231E+100 ON CONVERSION ERROR) |
|
||||
9 | TO_BINARY_FLOAT(1.79769313486231E+400 DEFAULT ON CONVERSION ERROR) | Infinity
|
||||
10 | TO_BINARY_FLOAT( DEFAULT 1.79769313486231E+400 ON CONVERSION ERROR) |
|
||||
11 | TO_BINARY_FLOAT(3.14 DEFAULT 6.666666 ON CONVERSION ERROR) | 3.14
|
||||
12 | TO_BINARY_FLOAT(3.14 DEFAULT ON CONVERSION ERROR) | 3.14
|
||||
13 | TO_BINARY_FLOAT( DEFAULT 3.14 ON CONVERSION ERROR) |
|
||||
14 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT 3.14 ON CONVERSION ERROR) | Infinity
|
||||
15 | TO_BINARY_FLOAT(3.14 DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) | 3.14
|
||||
20 | TO_BINARY_FLOAT(3.14 DEFAULT 6.666666 ON CONVERSION ERROR) | 3.14
|
||||
21 | TO_BINARY_FLOAT( +3.14 DEFAULT 6.666666 ON CONVERSION ERROR) | 3.14
|
||||
22 | TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
23 | TO_BINARY_FLOAT(6.666666 DEFAULT 17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ON CONVERSION ERROR) | 6.66667
|
||||
24 | TO_BINARY_FLOAT(1.79769313486231E+400 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
26 | TO_BINARY_FLOAT(17976931348623100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 DEFAULT 6.666666 ON CONVERSION ERROR) | Infinity
|
||||
27 | TO_BINARY_FLOAT(6.666666 DEFAULT 1.79769313486231E+100 ON CONVERSION ERROR) | 6.66667
|
||||
29 | TO_BINARY_FLOAT(6.666666 DEFAULT 1.79769313486231E+400 ON CONVERSION ERROR) | 6.66667
|
||||
(22 rows)
|
||||
|
||||
DROP TABLE tbf;
|
||||
DROP TABLE tbf2;
|
||||
|
@ -222,19 +222,19 @@ CREATE TABLE test_type(
|
||||
INSERT INTO test_type VALUES(15.23448);
|
||||
INSERT INTO test_type VALUES(1E-323);
|
||||
INSERT INTO test_type VALUES(1E-324);
|
||||
--?ERROR.*
|
||||
CONTEXT: referenced column: my_double
|
||||
INSERT INTO test_type VALUES(1E+308);
|
||||
INSERT INTO test_type VALUES(1E+309);
|
||||
ERROR: "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: my_double
|
||||
ERROR: number overflow at or near "1E+309"
|
||||
LINE 1: INSERT INTO test_type VALUES(1E+309);
|
||||
^
|
||||
SELECT * FROM test_type order by 1;
|
||||
my_double
|
||||
-----------------------
|
||||
9.88131291682493e-324
|
||||
15.23448
|
||||
1e+308
|
||||
(3 rows)
|
||||
my_double
|
||||
-----------
|
||||
0
|
||||
0
|
||||
15.23448
|
||||
1e+308
|
||||
(4 rows)
|
||||
|
||||
DROP TABLE test_type;
|
||||
/* g.Type BINARY_INTEGER */
|
||||
|
@ -663,19 +663,19 @@ CREATE TABLE test_type(
|
||||
INSERT INTO test_type VALUES(15.23448);
|
||||
INSERT INTO test_type VALUES(1E-323);
|
||||
INSERT INTO test_type VALUES(1E-324);
|
||||
--?ERROR.*
|
||||
CONTEXT: referenced column: my_double
|
||||
INSERT INTO test_type VALUES(1E+308);
|
||||
INSERT INTO test_type VALUES(1E+309);
|
||||
ERROR: "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: referenced column: my_double
|
||||
ERROR: number overflow at or near "1E+309"
|
||||
LINE 1: INSERT INTO test_type VALUES(1E+309);
|
||||
^
|
||||
SELECT * FROM test_type order by 1;
|
||||
my_double
|
||||
-----------------------
|
||||
9.88131291682493e-324
|
||||
15.23448
|
||||
1e+308
|
||||
(3 rows)
|
||||
my_double
|
||||
-----------
|
||||
0
|
||||
0
|
||||
15.23448
|
||||
1e+308
|
||||
(4 rows)
|
||||
|
||||
DROP TABLE test_type;
|
||||
/* g.Type BINARY_INTEGER */
|
||||
|
@ -45,8 +45,9 @@ copy test from '@abs_srcdir@/data/copy_support_transform.data' transform (mes1 c
|
||||
ERROR: value too long for type character(3)
|
||||
CONTEXT: COPY test, line 1, column mes1: "mmoo"
|
||||
copy test from '@abs_srcdir@/data/copy_support_transform.data' transform (mes1 text AS mes1 || mes2, mes2 float8 AS mes2 + 1E400, mes3 timestamp with time zone AS date_trunc('year', mes3));
|
||||
ERROR: "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision
|
||||
CONTEXT: COPY test, line 1: "1 mmoo 12.6789 Thu Jan 01 15:04:28 1970 PST 32767"
|
||||
ERROR: number overflow at or near "1E400"
|
||||
LINE 1: ...(mes1 text AS mes1 || mes2, mes2 float8 AS mes2 + 1E400, mes...
|
||||
^
|
||||
copy test from '@abs_srcdir@/data/copy_support_transform.data' transform (mes5 text AS mes1 || mes2, mes2 float8 AS mes2 + 1, mes3 timestamp with time zone AS date_trunc('year', mes3));
|
||||
ERROR: column "mes5" of relation "test" does not exist
|
||||
copy test from '@abs_srcdir@/data/copy_support_transform.data' transform (mes1 text AS mes5 || mes2, mes2 float8 AS mes2 + 1, mes3 timestamp with time zone AS date_trunc('year', mes3));
|
||||
|
76
src/test/regress/sql/float_literals.sql
Normal file
76
src/test/regress/sql/float_literals.sql
Normal file
@ -0,0 +1,76 @@
|
||||
-- test float literals overflow in dbcompatibility A
|
||||
create database float_literals dbcompatibility 'A';
|
||||
\c float_literals
|
||||
|
||||
SELECT 0.0;
|
||||
SELECT -0.0;
|
||||
SELECT 3.142596;
|
||||
SELECT -3.142596;
|
||||
SELECT 1.79E+400;
|
||||
SELECT 1.79E-400;
|
||||
SELECT -1.79E+400;
|
||||
|
||||
SELECT '0.0';
|
||||
SELECT '-0.0';
|
||||
SELECT '3.142596';
|
||||
SELECT '-3.142596';
|
||||
SELECT '1.79E+400';
|
||||
SELECT '1.79E-400';
|
||||
SELECT '-1.79E+400';
|
||||
|
||||
SELECT '0.0'::float8;
|
||||
SELECT '-0.0'::float8;
|
||||
SELECT '3.142596'::float8;
|
||||
SELECT '-3.142596'::float8;
|
||||
SELECT '1.79E+400'::float8;
|
||||
SELECT '1.79E-400'::float8;
|
||||
SELECT '-1.79E+400'::float8;
|
||||
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT y ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(-3.14 DEFAULT + ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT - ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(-3.14 DEFAULT * ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(3.14 DEFAULT / ON CONVERSION ERROR);
|
||||
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT y ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('-3.14' DEFAULT + ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT - ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('-3.14' DEFAULT * ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('3.14' DEFAULT / ON CONVERSION ERROR);
|
||||
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT y ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT + ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT - ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT * ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT(1.79E+400 DEFAULT / ON CONVERSION ERROR);
|
||||
|
||||
SELECT TO_BINARY_FLOAT('1.79E+400' DEFAULT y ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('1.79E-400' DEFAULT + ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('-1.79E+400' DEFAULT - ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('-1.79E-400' DEFAULT * ON CONVERSION ERROR);
|
||||
SELECT TO_BINARY_FLOAT('1.79E+400' DEFAULT / ON CONVERSION ERROR);
|
||||
|
||||
CREATE TABLE t_float_literals (id int, c1 float8);
|
||||
INSERT INTO t_float_literals VALUES (1, 0.0);
|
||||
INSERT INTO t_float_literals VALUES (2, 3.14);
|
||||
INSERT INTO t_float_literals VALUES (3, 3.14E+40);
|
||||
INSERT INTO t_float_literals VALUES (4, -3.14E+40);
|
||||
INSERT INTO t_float_literals VALUES (5, '3.14E+40'::float8);
|
||||
INSERT INTO t_float_literals VALUES (6, '-3.14E+40'::float8);
|
||||
INSERT INTO t_float_literals VALUES (7, 3.14E+400);
|
||||
INSERT INTO t_float_literals VALUES (8, 3.14E-400);
|
||||
INSERT INTO t_float_literals VALUES (9, -3.14E+400);
|
||||
INSERT INTO t_float_literals VALUES (10, '3.14E+400'::float8);
|
||||
INSERT INTO t_float_literals VALUES (11, '3.14E-400'::float8);
|
||||
INSERT INTO t_float_literals VALUES (12, '-3.14E+400'::float8);
|
||||
SELECT * FROM t_float_literals ORDER bY id;
|
||||
|
||||
UPDATE t_float_iterals SET c1 = 1.79E+400 WHERE id = 1;
|
||||
UPDATE t_float_iterals SET c1 = '1.79E+400'::float8 WHERE id = 2;
|
||||
UPDATE t_float_iterals SET c1 = 1.79E+40 WHERE id = 3;
|
||||
UPDATE t_float_iterals SET c1 = '1.79E+40'::float8 WHERE id = 4;
|
||||
SELECT * FROM t_float_iterals ORDER BY c1;
|
||||
|
||||
drop table t_float_literals;
|
||||
\c regression
|
||||
drop database float_literals;
|
@ -96,6 +96,8 @@ SELECT TO_BINARY_FLOAT('3.14E+400' DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDE
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400' DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER By c1; -- error
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c3 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
SELECT TO_BINARY_FLOAT(NULL DEFAULT c4 ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
SELECT TO_BINARY_FLOAT(3.14E+400 DEFAULT ab ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- overflow
|
||||
SELECT TO_BINARY_FLOAT('3.14E+400 DEFAULT' ab ON CONVERSION ERROR) FROM tbf ORDER BY c1; -- error
|
||||
|
||||
-- test overflow and null
|
||||
SELECT TO_BINARY_FLOAT(1.79769313486231E+100 DEFAULT 3.14 ON CONVERSION ERROR);
|
||||
|
Reference in New Issue
Block a user