Commit 7aee5ed3 authored by Bruce Momjian's avatar Bruce Momjian

Fix tid to in/out as unsigned.

parent 14f15883
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.49 2002/06/20 20:29:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.50 2002/07/16 17:55:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -46,7 +46,7 @@ int32
pg_atoi(char *s, int size, int c)
{
long l = 0;
char *badp = (char *) NULL;
char *badp;
Assert(s);
......@@ -71,7 +71,7 @@ pg_atoi(char *s, int size, int c)
*/
if (errno && errno != EINVAL)
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
if (badp && *badp && (*badp != c))
if (*badp && *badp != c)
elog(ERROR, "pg_atoi: error in \"%s\": can\'t parse \"%s\"", s, badp);
switch (size)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.31 2002/06/20 20:29:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.32 2002/07/16 17:55:25 momjian Exp $
*
* NOTES
* input routine largely stolen from boxin().
......@@ -18,6 +18,10 @@
#include "postgres.h"
#include <errno.h>
#include <math.h>
#include <limits.h>
#include "access/heapam.h"
#include "catalog/namespace.h"
#include "utils/builtins.h"
......@@ -47,6 +51,8 @@ tidin(PG_FUNCTION_ARGS)
ItemPointer result;
BlockNumber blockNumber;
OffsetNumber offsetNumber;
char *badp;
int hold_offset;
for (i = 0, p = str; *p && i < NTIDARGS && *p != RDELIM; p++)
if (*p == DELIM || (*p == LDELIM && !i))
......@@ -55,8 +61,16 @@ tidin(PG_FUNCTION_ARGS)
if (i < NTIDARGS)
elog(ERROR, "invalid tid format: '%s'", str);
blockNumber = (BlockNumber) atoi(coord[0]);
offsetNumber = (OffsetNumber) atoi(coord[1]);
errno = 0;
blockNumber = strtoul(coord[0], &badp, 10);
if (errno || *badp != DELIM)
elog(ERROR, "tidin: invalid value.");
hold_offset = strtol(coord[1], &badp, 10);
if (errno || *badp != RDELIM ||
hold_offset > USHRT_MAX || hold_offset < 0)
elog(ERROR, "tidin: invalid value.");
offsetNumber = hold_offset;
result = (ItemPointer) palloc(sizeof(ItemPointerData));
......@@ -87,7 +101,7 @@ tidout(PG_FUNCTION_ARGS)
blockNumber = BlockIdGetBlockNumber(blockId);
offsetNumber = itemPtr->ip_posid;
sprintf(buf, "(%d,%d)", (int) blockNumber, (int) offsetNumber);
sprintf(buf, "(%u,%u)", blockNumber, offsetNumber);
PG_RETURN_CSTRING(pstrdup(buf));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment