diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index 6e3ea7b40..25db3b53d 100755 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -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 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 CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P @@ -14936,6 +14936,11 @@ Numeric: INT_P $$ = SystemTypeName("float8"); $$->location = @1; } + | BINARY_FLOAT + { + $$ = SystemTypeName("float4"); + $$->location = @1; + } | BINARY_INTEGER { $$ = SystemTypeName("int4"); @@ -18323,6 +18328,7 @@ col_name_keyword: BETWEEN | BIGINT | BINARY_DOUBLE + | BINARY_FLOAT | BINARY_INTEGER | BIT | BOOLEAN_P diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index 1b5bdf635..d0b827cc8 100755 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -68,6 +68,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) diff --git a/src/test/regress/expected/hw_datatype.out b/src/test/regress/expected/hw_datatype.out index 62a13878a..55162fe42 100644 --- a/src/test/regress/expected/hw_datatype.out +++ b/src/test/regress/expected/hw_datatype.out @@ -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( diff --git a/src/test/regress/expected/hw_datatype_2.out b/src/test/regress/expected/hw_datatype_2.out index a2107751d..f5a2a58fd 100644 --- a/src/test/regress/expected/hw_datatype_2.out +++ b/src/test/regress/expected/hw_datatype_2.out @@ -676,6 +676,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( diff --git a/src/test/regress/sql/hw_datatype.sql b/src/test/regress/sql/hw_datatype.sql index a3f48a8dd..48b8ac167 100644 --- a/src/test/regress/sql/hw_datatype.sql +++ b/src/test/regress/sql/hw_datatype.sql @@ -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 diff --git a/src/test/regress/sql/hw_datatype_2.sql b/src/test/regress/sql/hw_datatype_2.sql index 25e3df85e..6d1d7b9d8 100644 --- a/src/test/regress/sql/hw_datatype_2.sql +++ b/src/test/regress/sql/hw_datatype_2.sql @@ -268,6 +268,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