git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b1f7cc)
Emit a warning when an empty string is input to the oid, float4, and
Thu, 4 Mar 2004 21:47:18 +0000 (21:47 +0000)
Thu, 4 Mar 2004 21:47:18 +0000 (21:47 +0000)
float8 types. This begins the deprecation of this feature: in 7.6,
this input will be rejected.

Also added a new error code for warnings about deprecated features,
and updated the regression tests.


diff --git a/doc/src/sgml/errcodes.sgml b/doc/src/sgml/errcodes.sgml
index 7628bbee2a53b28925ec45bae40ba62a65d2fb3e..3afb85ec794149bdcb2a80d50629c7f106ae6178 100644 (file)
--- a/doc/src/sgml/errcodes.sgml
+++ b/doc/src/sgml/errcodes.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/errcodes.sgml,v 1.2 2003年11月29日 19:51:37 pgsql Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/errcodes.sgml,v 1.3 2004年03月04日 21:47:18 neilc Exp $ -->
<appendix id="errcodes-appendix">
<title><productname>PostgreSQL</productname> Error Codes</title>
@@ -95,6 +95,10 @@
<entry>WARNING STRING DATA RIGHT TRUNCATION</entry>
</row>
+<row>
+<entry><literal>01P01</literal></entry>
+<entry>WARNING DEPRECATED FEATURE</entry>
+</row>
<row>
<entry>Class 02</entry>
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 7a869e2b3a311ae674d4f15ca2a36033289b6bd8..f9c4894794f4e73c4ff857900ff8d53e7cebba31 100644 (file)
--- 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.96 2003年11月29日 19:51:58 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.97 2004年03月04日 21:47:18 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -208,6 +208,19 @@ float4in(PG_FUNCTION_ARGS)
errmsg("\"%s\" is out of range for type real", num)));
}
+ /*
+ * In releases prior to 7.5, we accepted an empty string as valid
+ * input (yielding a float4 of 0). In 7.5, we accept empty
+ * strings, but emit a warning noting that the feature is
+ * deprecated. In 7.6+, the warning should be replaced by an error.
+ */
+ if (num == endptr)
+ 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.")));
+
/*
* if we get here, we have a legal double, still need to check to see
* if it's a legal float
@@ -309,6 +322,19 @@ float8in(PG_FUNCTION_ARGS)
errmsg("\"%s\" is out of range for type double precision", num)));
}
+ /*
+ * In releases prior to 7.5, we accepted an empty string as valid
+ * input (yielding a float8 of 0). In 7.5, we accept empty
+ * strings, but emit a warning noting that the feature is
+ * deprecated. In 7.6+, the warning should be replaced by an error.
+ */
+ if (num == endptr)
+ 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.")));
+
CheckFloat8Val(val);
PG_RETURN_FLOAT8(val);
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index c6a47d1bfd47392514f36f6f35d9c5b297075588..2119936d39fccb5cf077d7fc4303a4d363dccac4 100644 (file)
--- 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.54 2004年02月18日 00:01:34 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.55 2004年03月04日 21:47:18 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,15 +40,27 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
* strtoul() normally only sets ERANGE. On some systems it also may
* set EINVAL, which simply means it couldn't parse the input string.
* This is handled by the second "if" consistent across platforms.
- * Note that for historical reasons we accept an empty string as
- * meaning 0.
*/
if (errno && errno != ERANGE && errno != EINVAL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"",
s)));
- if (endptr == s && *endptr)
+
+ /*
+ * In releases prior to 7.5, we accepted an empty string as valid
+ * input (yielding an OID of 0). In 7.5, we accept empty strings,
+ * but emit a warning noting that the feature is deprecated. In
+ * 7.6+, 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.")));
+
+ if (endptr == s && *s)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"",
diff --git a/src/include/utils/errcodes.h b/src/include/utils/errcodes.h
index 2c9eba9998703ce4abbf7c00bcd92faf03ddea98..c6f4e7bb9712dc880eee0aeae85ed301a08fa1a6 100644 (file)
--- a/src/include/utils/errcodes.h
+++ b/src/include/utils/errcodes.h
@@ -11,7 +11,7 @@
*
* Copyright (c) 2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/utils/errcodes.h,v 1.7 2003年11月29日 22:41:15 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/utils/errcodes.h,v 1.8 2004年03月04日 21:47:18 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -44,6 +44,7 @@
#define ERRCODE_WARNING_IMPLICIT_ZERO_BIT_PADDING MAKE_SQLSTATE('0','1', '0','0','8')
#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1', '0','0','4')
+#define ERRCODE_WARNING_DEPRECATED_FEATURE MAKE_SQLSTATE('0','1', 'P','0','1')
/* Class 02 - No Data --- this is also a warning class per SQL99 */
/* (do not use this class for failure conditions!) */
diff --git a/src/test/regress/expected/oid.out b/src/test/regress/expected/oid.out
index ce43b92bbf58243e43611074364f71ace9cab62c..570a4c77b36db712d00b69fb1cc556ea07f79898 100644 (file)
--- a/src/test/regress/expected/oid.out
+++ b/src/test/regress/expected/oid.out
@@ -7,7 +7,6 @@ INSERT INTO OID_TBL(f1) VALUES ('1235');
INSERT INTO OID_TBL(f1) VALUES ('987');
INSERT INTO OID_TBL(f1) VALUES ('-1040');
INSERT INTO OID_TBL(f1) VALUES ('99999999');
-INSERT INTO OID_TBL(f1) VALUES ('');
-- bad inputs
INSERT INTO OID_TBL(f1) VALUES ('asdfasd');
ERROR: invalid input syntax for type oid: "asdfasd"
@@ -21,8 +20,7 @@ SELECT '' AS six, OID_TBL.*;
| 987
| 4294966256
| 99999999
- | 0
-(6 rows)
+(5 rows)
SELECT '' AS one, o.* FROM OID_TBL o WHERE o.f1 = 1234;
one | f1
@@ -37,23 +35,20 @@ SELECT '' AS five, o.* FROM OID_TBL o WHERE o.f1 <> '1234';
| 987
| 4294966256
| 99999999
- | 0
-(5 rows)
+(4 rows)
SELECT '' AS three, o.* FROM OID_TBL o WHERE o.f1 <= '1234';
three | f1
-------+------
| 1234
| 987
- | 0
-(3 rows)
+(2 rows)
SELECT '' AS two, o.* FROM OID_TBL o WHERE o.f1 < '1234';
two | f1
-----+-----
| 987
- | 0
-(2 rows)
+(1 row)
SELECT '' AS four, o.* FROM OID_TBL o WHERE o.f1 >= '1234';
four | f1
diff --git a/src/test/regress/sql/oid.sql b/src/test/regress/sql/oid.sql
index 17bfd01942d4d9f6f64178d0f623cbcc16009638..a19f8fe998f6d52f9c9382d7bcce51ce5ba1c4be 100644 (file)
--- a/src/test/regress/sql/oid.sql
+++ b/src/test/regress/sql/oid.sql
@@ -14,8 +14,6 @@ INSERT INTO OID_TBL(f1) VALUES ('-1040');
INSERT INTO OID_TBL(f1) VALUES ('99999999');
-INSERT INTO OID_TBL(f1) VALUES ('');
-
-- bad inputs
INSERT INTO OID_TBL(f1) VALUES ('asdfasd');
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /