|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.42 2000/12/22 21:36:09 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.43 2000/12/28 01:51:15 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -67,14 +67,21 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
|
67 | 67 | result= (Oid)cvt;
|
68 | 68 |
|
69 | 69 | /*
|
70 |
| - * Cope with possibility that unsigned long is wider than Oid. |
| 70 | + * Cope with possibility that unsigned long is wider than Oid, |
| 71 | + * in which case strtoul will not raise an error for some values |
| 72 | + * that are out of the range of Oid. |
| 73 | + * |
| 74 | + * For backwards compatibility, we want to accept inputs that |
| 75 | + * are given with a minus sign, so allow the input value if it |
| 76 | + * matches after either signed or unsigned extension to long. |
71 | 77 | *
|
72 | 78 | * To ensure consistent results on 32-bit and 64-bit platforms,
|
73 | 79 | * make sure the error message is the same as if strtoul() had
|
74 | 80 | * returned ERANGE.
|
75 | 81 | */
|
76 |
| -#ifOID_MAX<ULONG_MAX |
77 |
| -if (cvt> (unsigned long)OID_MAX) |
| 82 | +#ifOID_MAX!=ULONG_MAX |
| 83 | +if (cvt!= (unsigned long)result&& |
| 84 | +cvt!= (unsigned long) ((int)result)) |
78 | 85 | elog(ERROR,"%s: error reading \"%s\": %s",
|
79 | 86 | funcname,s,strerror(ERANGE));
|
80 | 87 | #endif
|
|