char *intString = PG_GETARG_CSTRING(0);
Node *escontext = fcinfo->context;
int2vector *result;
+ int nalloc;
int n;
- result = (int2vector *) palloc0(Int2VectorSize(FUNC_MAX_ARGS));
+ nalloc = 32; /* arbitrary initial size guess */
+ result = (int2vector *) palloc0(Int2VectorSize(nalloc));
- for (n = 0; n < FUNC_MAX_ARGS; n++)
+ for (n = 0;; n++)
{
long l;
char *endp;
if (*intString == '\0')
break;
+ if (n >= nalloc)
+ {
+ nalloc *= 2;
+ result = (int2vector *) repalloc(result, Int2VectorSize(nalloc));
+ }
+
errno = 0;
l = strtol(intString, &endp, 10);
ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type %s: \"%s\"",
- "integer", intString)));
+ "smallint", intString)));
result->values[n] = l;
intString = endp;
}
- while (*intString && isspace((unsigned char) *intString))
- intString++;
- if (*intString)
- ereturn(escontext, (Datum) 0,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("int2vector has too many elements")));
SET_VARSIZE(result, Int2VectorSize(n));
result->ndim = 1;
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid int2vector data")));
- /* check length for consistency with int2vectorin() */
- if (ARR_DIMS(result)[0] > FUNC_MAX_ARGS)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("oidvector has too many elements")));
-
PG_RETURN_POINTER(result);
}
char *oidString = PG_GETARG_CSTRING(0);
Node *escontext = fcinfo->context;
oidvector *result;
+ int nalloc;
int n;
- result = (oidvector *) palloc0(OidVectorSize(FUNC_MAX_ARGS));
+ nalloc = 32; /* arbitrary initial size guess */
+ result = (oidvector *) palloc0(OidVectorSize(nalloc));
- for (n = 0; n < FUNC_MAX_ARGS; n++)
+ for (n = 0;; n++)
{
while (*oidString && isspace((unsigned char) *oidString))
oidString++;
if (*oidString == '\0')
break;
+
+ if (n >= nalloc)
+ {
+ nalloc *= 2;
+ result = (oidvector *) repalloc(result, OidVectorSize(nalloc));
+ }
+
result->values[n] = uint32in_subr(oidString, &oidString,
"oid", escontext);
if (SOFT_ERROR_OCCURRED(escontext))
PG_RETURN_NULL();
}
- while (*oidString && isspace((unsigned char) *oidString))
- oidString++;
- if (*oidString)
- ereturn(escontext, (Datum) 0,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("oidvector has too many elements")));
SET_VARSIZE(result, OidVectorSize(n));
result->ndim = 1;
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid oidvector data")));
- /* check length for consistency with oidvectorin() */
- if (ARR_DIMS(result)[0] > FUNC_MAX_ARGS)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("oidvector has too many elements")));
-
PG_RETURN_POINTER(result);
}