Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3ec9fb8

Browse files
committed
Add a little more error checking and reporting to readDatum().
1 parent 31c1fea commit 3ec9fb8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/backend/nodes/readfuncs.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.111 2001/06/19 22:39:11 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.112 2001/07/03 16:52:48 tgl Exp $
1212
*
1313
* NOTES
1414
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -2052,7 +2052,11 @@ readDatum(bool typbyval)
20522052
token = pg_strtok(&tokenLength);
20532053
length = atoui(token);
20542054

2055-
token = pg_strtok(&tokenLength); /* skip the '[' */
2055+
token = pg_strtok(&tokenLength); /* read the '[' */
2056+
if (token == NULL || token[0] != '[')
2057+
elog(ERROR, "readDatum: expected '%s', got '%s'; length = %lu",
2058+
"[", token ? (const char *) token : "[NULL]",
2059+
(unsigned long) length);
20562060

20572061
if (typbyval)
20582062
{
@@ -2080,9 +2084,10 @@ readDatum(bool typbyval)
20802084
res = PointerGetDatum(s);
20812085
}
20822086

2083-
token = pg_strtok(&tokenLength); /* skip the ']' */
2087+
token = pg_strtok(&tokenLength); /* read the ']' */
20842088
if (token == NULL || token[0] != ']')
2085-
elog(ERROR, "readDatum: ']' expected, length = %lu",
2089+
elog(ERROR, "readDatum: expected '%s', got '%s'; length = %lu",
2090+
"]", token ? (const char *) token : "[NULL]",
20862091
(unsigned long) length);
20872092

20882093
return res;

0 commit comments

Comments
 (0)