summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-02-11 04:09:05 +0000
committerNeil Conway <neilc@samurai.com>2005-02-11 04:09:05 +0000
commit975e27377aadcabab6504155c091d27ea2fa4c53 (patch)
treecbf5435f931969d09543401af0c1d8bb5dcb3d56 /src
parent4db84f0880716ece570db2debf99b773bfb82dd3 (diff)
downloadpostgresql-975e27377aadcabab6504155c091d27ea2fa4c53.tar.gz
Adjust input routines for float4, float8 and oid to reject the empty string
as valid input (it was previously treated as 0). This input was deprecated in 8.0 (and a warning was emitted). Regression tests updated.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/float.c36
-rw-r--r--src/backend/utils/adt/oid.c17
-rw-r--r--src/test/regress/expected/float4-exp-three-digits.out2
-rw-r--r--src/test/regress/expected/float4.out2
-rw-r--r--src/test/regress/expected/float8-exp-three-digits-win32.out2
-rw-r--r--src/test/regress/expected/float8-exp-three-digits.out2
-rw-r--r--src/test/regress/expected/float8-small-is-zero.out2
-rw-r--r--src/test/regress/expected/float8-small-is-zero_1.out2
-rw-r--r--src/test/regress/expected/float8.out2
-rw-r--r--src/test/regress/expected/oid.out6
-rw-r--r--src/test/regress/sql/float4.sql1
-rw-r--r--src/test/regress/sql/float8.sql1
-rw-r--r--src/test/regress/sql/oid.sql4
13 files changed, 36 insertions, 43 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 4804445c32..e51babfebf 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.112 2004/12/31 22:01:21 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.113 2005/02/11 04:08:58 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -267,21 +267,12 @@ float4in(PG_FUNCTION_ARGS)
/*
* Check for an empty-string input to begin with, to avoid the
* vagaries of strtod() on different platforms.
- *
- * In releases prior to 8.0, we accepted an empty string as valid input
- * (yielding a float4 of 0). In 8.0, we accept empty strings, but emit
- * a warning noting that the feature is deprecated. In 8.1+, the
- * warning should be replaced by an error.
*/
if (*num == '\0')
- {
- ereport(WARNING,
- (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
- errmsg("deprecated input syntax for type real: \"\""),
- errdetail("This input will be rejected in "
- "a future release of PostgreSQL.")));
- PG_RETURN_FLOAT4((float4) 0.0);
- }
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for type real: \"%s\"",
+ orig_num)));
/* skip leading whitespace */
while (*num != '\0' && isspace((unsigned char) *num))
@@ -444,21 +435,12 @@ float8in(PG_FUNCTION_ARGS)
/*
* Check for an empty-string input to begin with, to avoid the
* vagaries of strtod() on different platforms.
- *
- * In releases prior to 8.0, we accepted an empty string as valid input
- * (yielding a float8 of 0). In 8.0, we accept empty strings, but emit
- * a warning noting that the feature is deprecated. In 8.1+, the
- * warning should be replaced by an error.
*/
if (*num == '\0')
- {
- ereport(WARNING,
- (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
- errmsg("deprecated input syntax for type double precision: \"\""),
- errdetail("This input will be rejected in "
- "a future release of PostgreSQL.")));
- PG_RETURN_FLOAT8(0.0);
- }
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for type double precision: \"%s\"",
+ orig_num)));
/* skip leading whitespace */
while (*num != '\0' && isspace((unsigned char) *num))
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index f499ae71b0..ababe641b2 100644
--- a/src/backend/utils/adt/oid.c
+++ b/src/backend/utils/adt/oid.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.60 2004/12/31 22:01:22 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.61 2005/02/11 04:08:58 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,18 +33,11 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
char *endptr;
Oid result;
- /*
- * In releases prior to 8.0, we accepted an empty string as valid
- * input (yielding an OID of 0). In 8.0, we accept empty strings, but
- * emit a warning noting that the feature is deprecated. In 8.1+, the
- * warning should be replaced by an error.
- */
if (*s == '\0')
- ereport(WARNING,
- (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
- errmsg("deprecated input syntax for type oid: \"\""),
- errdetail("This input will be rejected in "
- "a future release of PostgreSQL.")));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for type oid: \"%s\"",
+ s)));
errno = 0;
cvt = strtoul(s, &endptr, 10);
diff --git a/src/test/regress/expected/float4-exp-three-digits.out b/src/test/regress/expected/float4-exp-three-digits.out
index 01fabddcc5..8e0d643d25 100644
--- a/src/test/regress/expected/float4-exp-three-digits.out
+++ b/src/test/regress/expected/float4-exp-three-digits.out
@@ -17,6 +17,8 @@ ERROR: type "real" value out of range: underflow
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-40');
ERROR: type "real" value out of range: underflow
-- bad input
+INSERT INTO FLOAT4_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type real: ""
INSERT INTO FLOAT4_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type real: " "
INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/float4.out b/src/test/regress/expected/float4.out
index e4d460359f..8ababaad6e 100644
--- a/src/test/regress/expected/float4.out
+++ b/src/test/regress/expected/float4.out
@@ -17,6 +17,8 @@ ERROR: type "real" value out of range: underflow
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-40');
ERROR: type "real" value out of range: underflow
-- bad input
+INSERT INTO FLOAT4_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type real: ""
INSERT INTO FLOAT4_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type real: " "
INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/float8-exp-three-digits-win32.out b/src/test/regress/expected/float8-exp-three-digits-win32.out
index c6f3064b67..a7f15c5bbd 100644
--- a/src/test/regress/expected/float8-exp-three-digits-win32.out
+++ b/src/test/regress/expected/float8-exp-three-digits-win32.out
@@ -17,6 +17,8 @@ ERROR: "10e-400" is out of range for type double precision
SELECT '-10e-400'::float8;
ERROR: "-10e-400" is out of range for type double precision
-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type double precision: ""
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type double precision: " "
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/float8-exp-three-digits.out b/src/test/regress/expected/float8-exp-three-digits.out
index 479503959b..c466ce6402 100644
--- a/src/test/regress/expected/float8-exp-three-digits.out
+++ b/src/test/regress/expected/float8-exp-three-digits.out
@@ -17,6 +17,8 @@ ERROR: "10e-400" is out of range for type double precision
SELECT '-10e-400'::float8;
ERROR: "-10e-400" is out of range for type double precision
-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type double precision: ""
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type double precision: " "
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/float8-small-is-zero.out b/src/test/regress/expected/float8-small-is-zero.out
index b599c1ca5d..afa892ae24 100644
--- a/src/test/regress/expected/float8-small-is-zero.out
+++ b/src/test/regress/expected/float8-small-is-zero.out
@@ -25,6 +25,8 @@ SELECT '-10e-400'::float8;
(1 row)
-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type double precision: ""
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type double precision: " "
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/float8-small-is-zero_1.out b/src/test/regress/expected/float8-small-is-zero_1.out
index 3a74505b4e..a6b1ae2c04 100644
--- a/src/test/regress/expected/float8-small-is-zero_1.out
+++ b/src/test/regress/expected/float8-small-is-zero_1.out
@@ -25,6 +25,8 @@ SELECT '-10e-400'::float8;
(1 row)
-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type double precision: ""
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type double precision: " "
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out
index 8ba64db020..579f80abfe 100644
--- a/src/test/regress/expected/float8.out
+++ b/src/test/regress/expected/float8.out
@@ -17,6 +17,8 @@ ERROR: "10e-400" is out of range for type double precision
SELECT '-10e-400'::float8;
ERROR: "-10e-400" is out of range for type double precision
-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type double precision: ""
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for type double precision: " "
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
diff --git a/src/test/regress/expected/oid.out b/src/test/regress/expected/oid.out
index 092c9b1cfa..2297621806 100644
--- a/src/test/regress/expected/oid.out
+++ b/src/test/regress/expected/oid.out
@@ -12,6 +12,10 @@ INSERT INTO OID_TBL(f1) VALUES (' 10 ');
-- leading/trailing hard tab is also allowed
INSERT INTO OID_TBL(f1) VALUES (' 15 ');
-- bad inputs
+INSERT INTO OID_TBL(f1) VALUES ('');
+ERROR: invalid input syntax for type oid: ""
+INSERT INTO OID_TBL(f1) VALUES (' ');
+ERROR: invalid input syntax for type oid: " "
INSERT INTO OID_TBL(f1) VALUES ('asdfasd');
ERROR: invalid input syntax for type oid: "asdfasd"
INSERT INTO OID_TBL(f1) VALUES ('99asdfasd');
@@ -22,8 +26,6 @@ INSERT INTO OID_TBL(f1) VALUES (' 5d');
ERROR: invalid input syntax for type oid: " 5d"
INSERT INTO OID_TBL(f1) VALUES ('5 5');
ERROR: invalid input syntax for type oid: "5 5"
-INSERT INTO OID_TBL(f1) VALUES (' ');
-ERROR: invalid input syntax for type oid: " "
INSERT INTO OID_TBL(f1) VALUES (' - 500');
ERROR: invalid input syntax for type oid: " - 500"
INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935');
diff --git a/src/test/regress/sql/float4.sql b/src/test/regress/sql/float4.sql
index a7147409ec..916431fbcc 100644
--- a/src/test/regress/sql/float4.sql
+++ b/src/test/regress/sql/float4.sql
@@ -17,6 +17,7 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-40');
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-40');
-- bad input
+INSERT INTO FLOAT4_TBL(f1) VALUES ('');
INSERT INTO FLOAT4_TBL(f1) VALUES (' ');
INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz');
INSERT INTO FLOAT4_TBL(f1) VALUES ('5.0.0');
diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql
index 83f0763c6f..0ff71be5d4 100644
--- a/src/test/regress/sql/float8.sql
+++ b/src/test/regress/sql/float8.sql
@@ -17,6 +17,7 @@ SELECT '10e-400'::float8;
SELECT '-10e-400'::float8;
-- bad input
+INSERT INTO FLOAT8_TBL(f1) VALUES ('');
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
diff --git a/src/test/regress/sql/oid.sql b/src/test/regress/sql/oid.sql
index a3ed212b6a..e2357cd2e5 100644
--- a/src/test/regress/sql/oid.sql
+++ b/src/test/regress/sql/oid.sql
@@ -15,13 +15,13 @@ INSERT INTO OID_TBL(f1) VALUES (' 10 ');
INSERT INTO OID_TBL(f1) VALUES (' 15 ');
-- bad inputs
-
+INSERT INTO OID_TBL(f1) VALUES ('');
+INSERT INTO OID_TBL(f1) VALUES (' ');
INSERT INTO OID_TBL(f1) VALUES ('asdfasd');
INSERT INTO OID_TBL(f1) VALUES ('99asdfasd');
INSERT INTO OID_TBL(f1) VALUES ('5 d');
INSERT INTO OID_TBL(f1) VALUES (' 5d');
INSERT INTO OID_TBL(f1) VALUES ('5 5');
-INSERT INTO OID_TBL(f1) VALUES (' ');
INSERT INTO OID_TBL(f1) VALUES (' - 500');
INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935');
INSERT INTO OID_TBL(f1) VALUES ('-23582358720398502385');