support BINARY_FLOAT

This commit is contained in:
hemny
2020-11-16 23:27:31 +08:00
parent 1e6f0c3818
commit ad32bf444a
6 changed files with 218 additions and 1 deletions

View File

@ -622,7 +622,7 @@ static void ParseUpdateMultiSet(List *set_target_list, SelectStmt *stmt, core_yy
AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APP ARRAY AS ASC AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APP ARRAY AS ASC
ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUTHID AUTHORIZATION AUTOEXTEND AUTOMAPPED ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUTHID AUTHORIZATION AUTOEXTEND AUTOMAPPED
BACKWARD BARRIER BEFORE BEGIN_NON_ANOYBLOCK BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_INTEGER BIT BLOB_P BOGUS BACKWARD BARRIER BEFORE BEGIN_NON_ANOYBLOCK BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_FLOAT BINARY_INTEGER BIT BLOB_P BOGUS
BOOLEAN_P BOTH BUCKETS BY BOOLEAN_P BOTH BUCKETS BY
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
@ -14936,6 +14936,11 @@ Numeric: INT_P
$$ = SystemTypeName("float8"); $$ = SystemTypeName("float8");
$$->location = @1; $$->location = @1;
} }
| BINARY_FLOAT
{
$$ = SystemTypeName("float4");
$$->location = @1;
}
| BINARY_INTEGER | BINARY_INTEGER
{ {
$$ = SystemTypeName("int4"); $$ = SystemTypeName("int4");
@ -18323,6 +18328,7 @@ col_name_keyword:
BETWEEN BETWEEN
| BIGINT | BIGINT
| BINARY_DOUBLE | BINARY_DOUBLE
| BINARY_FLOAT
| BINARY_INTEGER | BINARY_INTEGER
| BIT | BIT
| BOOLEAN_P | BOOLEAN_P

View File

@ -68,6 +68,7 @@ PG_KEYWORD("between", BETWEEN, COL_NAME_KEYWORD)
PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD) PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD)
PG_KEYWORD("binary", BINARY, TYPE_FUNC_NAME_KEYWORD) PG_KEYWORD("binary", BINARY, TYPE_FUNC_NAME_KEYWORD)
PG_KEYWORD("binary_double", BINARY_DOUBLE, COL_NAME_KEYWORD) PG_KEYWORD("binary_double", BINARY_DOUBLE, COL_NAME_KEYWORD)
PG_KEYWORD("binary_float", BINARY_FLOAT, COL_NAME_KEYWORD)
PG_KEYWORD("binary_integer", BINARY_INTEGER, COL_NAME_KEYWORD) PG_KEYWORD("binary_integer", BINARY_INTEGER, COL_NAME_KEYWORD)
PG_KEYWORD("bit", BIT, COL_NAME_KEYWORD) PG_KEYWORD("bit", BIT, COL_NAME_KEYWORD)
PG_KEYWORD("blob", BLOB_P, UNRESERVED_KEYWORD) PG_KEYWORD("blob", BLOB_P, UNRESERVED_KEYWORD)

View File

@ -236,6 +236,85 @@ SELECT * FROM test_type order by 1;
1e+308 1e+308
(3 rows) (3 rows)
DROP TABLE test_type;
/* f.BINARY_FLOAT type */
CREATE TABLE test_type(
my_float BINARY_FLOAT
);
INSERT INTO test_type VALUES (' 0.0');
INSERT INTO test_type VALUES ('1004.30 ');
INSERT INTO test_type VALUES (' -34.84 ');
INSERT INTO test_type VALUES ('1.2345678901234e+20');
INSERT INTO test_type VALUES ('1.2345678901234e-20');
-- test for over and under flow
INSERT INTO test_type VALUES ('10e70');
ERROR: value out of range: overflow
LINE 1: INSERT INTO test_type VALUES ('10e70');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('-10e70');
ERROR: value out of range: overflow
LINE 1: INSERT INTO test_type VALUES ('-10e70');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('10e-70');
ERROR: value out of range: underflow
LINE 1: INSERT INTO test_type VALUES ('10e-70');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('-10e-70');
ERROR: value out of range: underflow
LINE 1: INSERT INTO test_type VALUES ('-10e-70');
^
CONTEXT: referenced column: my_float
-- bad input
INSERT INTO test_type VALUES ('');
INSERT INTO test_type VALUES (' ');
ERROR: invalid input syntax for type real: " "
LINE 1: INSERT INTO test_type VALUES (' ');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('xyz');
ERROR: invalid input syntax for type real: "xyz"
LINE 1: INSERT INTO test_type VALUES ('xyz');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('5.0.0');
ERROR: invalid input syntax for type real: "5.0.0"
LINE 1: INSERT INTO test_type VALUES ('5.0.0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('5 . 0');
ERROR: invalid input syntax for type real: "5 . 0"
LINE 1: INSERT INTO test_type VALUES ('5 . 0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('5. 0');
ERROR: invalid input syntax for type real: "5. 0"
LINE 1: INSERT INTO test_type VALUES ('5. 0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES (' - 3.0');
ERROR: invalid input syntax for type real: " - 3.0"
LINE 1: INSERT INTO test_type VALUES (' - 3.0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('123 5');
ERROR: invalid input syntax for type real: "123 5"
LINE 1: INSERT INTO test_type VALUES ('123 5');
^
CONTEXT: referenced column: my_float
SELECT * FROM test_type order by 1;
my_float
-------------
-34.84
0
1.23457e-20
1004.3
1.23457e+20
(6 rows)
DROP TABLE test_type; DROP TABLE test_type;
/* g.Type BINARY_INTEGER */ /* g.Type BINARY_INTEGER */
CREATE TABLE test_type( CREATE TABLE test_type(

View File

@ -676,6 +676,85 @@ SELECT * FROM test_type order by 1;
1e+308 1e+308
(3 rows) (3 rows)
DROP TABLE test_type;
/* f.BINARY_FLOAT type */
CREATE TABLE test_type(
my_float BINARY_FLOAT
);
INSERT INTO test_type VALUES (' 0.0');
INSERT INTO test_type VALUES ('1004.30 ');
INSERT INTO test_type VALUES (' -34.84 ');
INSERT INTO test_type VALUES ('1.2345678901234e+20');
INSERT INTO test_type VALUES ('1.2345678901234e-20');
-- test for over and under flow
INSERT INTO test_type VALUES ('10e70');
ERROR: value out of range: overflow
LINE 1: INSERT INTO test_type VALUES ('10e70');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('-10e70');
ERROR: value out of range: overflow
LINE 1: INSERT INTO test_type VALUES ('-10e70');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('10e-70');
ERROR: value out of range: underflow
LINE 1: INSERT INTO test_type VALUES ('10e-70');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('-10e-70');
ERROR: value out of range: underflow
LINE 1: INSERT INTO test_type VALUES ('-10e-70');
^
CONTEXT: referenced column: my_float
-- bad input
INSERT INTO test_type VALUES ('');
INSERT INTO test_type VALUES (' ');
ERROR: invalid input syntax for type real: " "
LINE 1: INSERT INTO test_type VALUES (' ');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('xyz');
ERROR: invalid input syntax for type real: "xyz"
LINE 1: INSERT INTO test_type VALUES ('xyz');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('5.0.0');
ERROR: invalid input syntax for type real: "5.0.0"
LINE 1: INSERT INTO test_type VALUES ('5.0.0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('5 . 0');
ERROR: invalid input syntax for type real: "5 . 0"
LINE 1: INSERT INTO test_type VALUES ('5 . 0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('5. 0');
ERROR: invalid input syntax for type real: "5. 0"
LINE 1: INSERT INTO test_type VALUES ('5. 0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES (' - 3.0');
ERROR: invalid input syntax for type real: " - 3.0"
LINE 1: INSERT INTO test_type VALUES (' - 3.0');
^
CONTEXT: referenced column: my_float
INSERT INTO test_type VALUES ('123 5');
ERROR: invalid input syntax for type real: "123 5"
LINE 1: INSERT INTO test_type VALUES ('123 5');
^
CONTEXT: referenced column: my_float
SELECT * FROM test_type order by 1;
my_float
-------------
-34.84
0
1.23457e-20
1004.3
1.23457e+20
(6 rows)
DROP TABLE test_type; DROP TABLE test_type;
/* g.Type BINARY_INTEGER */ /* g.Type BINARY_INTEGER */
CREATE TABLE test_type( CREATE TABLE test_type(

View File

@ -127,6 +127,32 @@ INSERT INTO test_type VALUES(1E+309);
SELECT * FROM test_type order by 1; SELECT * FROM test_type order by 1;
DROP TABLE test_type; DROP TABLE test_type;
/* f.BINARY_FLOAT type */
CREATE TABLE test_type(
my_float BINARY_FLOAT
);
INSERT INTO test_type VALUES (' 0.0');
INSERT INTO test_type VALUES ('1004.30 ');
INSERT INTO test_type VALUES (' -34.84 ');
INSERT INTO test_type VALUES ('1.2345678901234e+20');
INSERT INTO test_type VALUES ('1.2345678901234e-20');
-- test for over and under flow
INSERT INTO test_type VALUES ('10e70');
INSERT INTO test_type VALUES ('-10e70');
INSERT INTO test_type VALUES ('10e-70');
INSERT INTO test_type VALUES ('-10e-70');
-- bad input
INSERT INTO test_type VALUES ('');
INSERT INTO test_type VALUES (' ');
INSERT INTO test_type VALUES ('xyz');
INSERT INTO test_type VALUES ('5.0.0');
INSERT INTO test_type VALUES ('5 . 0');
INSERT INTO test_type VALUES ('5. 0');
INSERT INTO test_type VALUES (' - 3.0');
INSERT INTO test_type VALUES ('123 5');
SELECT * FROM test_type order by 1;
DROP TABLE test_type;
/* g.Type BINARY_INTEGER */ /* g.Type BINARY_INTEGER */
CREATE TABLE test_type( CREATE TABLE test_type(
my_double BINARY_INTEGER my_double BINARY_INTEGER

View File

@ -268,6 +268,32 @@ INSERT INTO test_type VALUES(1E+309);
SELECT * FROM test_type order by 1; SELECT * FROM test_type order by 1;
DROP TABLE test_type; DROP TABLE test_type;
/* f.BINARY_FLOAT type */
CREATE TABLE test_type(
my_float BINARY_FLOAT
);
INSERT INTO test_type VALUES (' 0.0');
INSERT INTO test_type VALUES ('1004.30 ');
INSERT INTO test_type VALUES (' -34.84 ');
INSERT INTO test_type VALUES ('1.2345678901234e+20');
INSERT INTO test_type VALUES ('1.2345678901234e-20');
-- test for over and under flow
INSERT INTO test_type VALUES ('10e70');
INSERT INTO test_type VALUES ('-10e70');
INSERT INTO test_type VALUES ('10e-70');
INSERT INTO test_type VALUES ('-10e-70');
-- bad input
INSERT INTO test_type VALUES ('');
INSERT INTO test_type VALUES (' ');
INSERT INTO test_type VALUES ('xyz');
INSERT INTO test_type VALUES ('5.0.0');
INSERT INTO test_type VALUES ('5 . 0');
INSERT INTO test_type VALUES ('5. 0');
INSERT INTO test_type VALUES (' - 3.0');
INSERT INTO test_type VALUES ('123 5');
SELECT * FROM test_type order by 1;
DROP TABLE test_type;
/* g.Type BINARY_INTEGER */ /* g.Type BINARY_INTEGER */
CREATE TABLE test_type( CREATE TABLE test_type(
my_double BINARY_INTEGER my_double BINARY_INTEGER