!609 openGauss supports binary_float

Merge pull request !609 from liang/413
This commit is contained in:
opengauss-bot
2021-02-08 09:26:50 +08:00
committed by Gitee
7 changed files with 225 additions and 2 deletions

View File

@ -704,7 +704,7 @@ static void parameter_check_execute_direct(const char* query);
AGGREGATE ALGORITHM ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APP ARRAY AS ASC
ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUDIT 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 BYTEAWITHOUTORDER BYTEAWITHOUTORDERWITHEQUAL
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
@ -16901,6 +16901,11 @@ Numeric: INT_P
$$ = SystemTypeName("float8");
$$->location = @1;
}
| BINARY_FLOAT
{
$$ = SystemTypeName("float4");
$$->location = @1;
}
| BINARY_INTEGER
{
$$ = SystemTypeName("int4");
@ -20444,6 +20449,7 @@ col_name_keyword:
BETWEEN
| BIGINT
| BINARY_DOUBLE
| BINARY_FLOAT
| BINARY_INTEGER
| BIT
| BOOLEAN_P

View File

@ -493,7 +493,7 @@ extern THR_LOCAL bool stmt_contains_operator_plus;
AGGREGATE ALGORITHM ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APP ARRAY AS ASC
ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUDIT AUDIT_POLICY AUTHID AUTHORIZATION AUTOEXTEND AUTOMAPPED
BACKWARD BARRIER BEFORE BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_INTEGER BIT BLOB_P BOGUS
BACKWARD BARRIER BEFORE BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_FLOAT BINARY_INTEGER BIT BLOB_P BOGUS
BOOLEAN_P BOTH BUCKETS BY BYTEAWITHOUTORDER BYTEAWITHOUTORDERWITHEQUAL
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
@ -7517,6 +7517,11 @@ Numeric: INT_P
$$ = SystemTypeName("float8");
$$->location = @1;
}
| BINARY_FLOAT
{
$$ = SystemTypeName("float4");
$$->location = @1;
}
| BINARY_INTEGER
{
$$ = SystemTypeName("int4");
@ -10903,6 +10908,7 @@ col_name_keyword:
BETWEEN
| BIGINT
| BINARY_DOUBLE
| BINARY_FLOAT
| BINARY_INTEGER
| BIT
| BOOLEAN_P

View File

@ -70,6 +70,7 @@ PG_KEYWORD("between", BETWEEN, COL_NAME_KEYWORD)
PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD)
PG_KEYWORD("binary", BINARY, TYPE_FUNC_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("bit", BIT, COL_NAME_KEYWORD)
PG_KEYWORD("blob", BLOB_P, UNRESERVED_KEYWORD)

View File

@ -236,6 +236,85 @@ SELECT * FROM test_type order by 1;
1e+308
(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;
/* g.Type BINARY_INTEGER */
CREATE TABLE test_type(

View File

@ -674,6 +674,85 @@ SELECT * FROM test_type order by 1;
1e+308
(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;
/* g.Type BINARY_INTEGER */
CREATE TABLE test_type(

View File

@ -127,6 +127,32 @@ INSERT INTO test_type VALUES(1E+309);
SELECT * FROM test_type order by 1;
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 */
CREATE TABLE test_type(
my_double BINARY_INTEGER

View File

@ -267,6 +267,32 @@ INSERT INTO test_type VALUES(1E+309);
SELECT * FROM test_type order by 1;
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 */
CREATE TABLE test_type(
my_double BINARY_INTEGER