aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/oid.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-03-11 02:11:14 +0000
committerNeil Conway <neilc@samurai.com>2004-03-11 02:11:14 +0000
commite2ded829f6b672529d072620e43de65466286b59 (patch)
tree9ffc21ade136f5e667fb41dbd2e8b1c56436b3e5 /src/backend/utils/adt/oid.c
parent0b86ade1c2f3dcd2407e535baad1654e65252316 (diff)
downloadpostgresql-e2ded829f6b672529d072620e43de65466286b59.tar.gz
postgresql-e2ded829f6b672529d072620e43de65466286b59.zip
Revise int2/int4/int8/float4/float8 input routines to allow for
any amount of leading or trailing whitespace (where "whitespace" is defined by isspace()). This is for SQL conformance, as well as consistency with other numeric types (e.g. oid, numeric). Also refactor pg_atoi() to avoid looking at errno where not necessary, and add a bunch of regression tests for the input to these types.
Diffstat (limited to 'src/backend/utils/adt/oid.c')
-rw-r--r--src/backend/utils/adt/oid.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index 2119936d39f..7ff6c6a27c1 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.55 2004/03/04 21:47:18 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.56 2004/03/11 02:11:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,6 +33,19 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
char *endptr;
Oid result;
+ /*
+ * 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.")));
+
errno = 0;
cvt = strtoul(s, &endptr, 10);
@@ -47,20 +60,7 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
errmsg("invalid input syntax for type oid: \"%s\"",
s)));
- /*
- * 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)
+ if (endptr == s && *s != '\0')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"",