Error message editing in utils/adt. Again thanks to Joe Conway for doing
the bulk of the heavy lifting ...
This commit is contained in:
parent
524cfad23f
commit
b6a1d25b0a
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.91 2003/06/27 00:33:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.92 2003/07/27 04:53:02 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -90,8 +90,12 @@ getid(const char *s, char *n)
|
||||
else
|
||||
{
|
||||
if (len >= NAMEDATALEN-1)
|
||||
elog(ERROR, "identifier must be less than %d characters",
|
||||
NAMEDATALEN);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NAME_TOO_LONG),
|
||||
errmsg("identifier too long"),
|
||||
errdetail("Identifier must be less than %d characters.",
|
||||
NAMEDATALEN)));
|
||||
|
||||
n[len++] = *s;
|
||||
}
|
||||
}
|
||||
@ -157,26 +161,34 @@ aclparse(const char *s, AclItem *aip)
|
||||
Assert(s && aip);
|
||||
|
||||
#ifdef ACLDEBUG
|
||||
elog(LOG, "aclparse: input = '%s'", s);
|
||||
elog(LOG, "aclparse: input = \"%s\"", s);
|
||||
#endif
|
||||
idtype = ACL_IDTYPE_UID;
|
||||
s = getid(s, name);
|
||||
if (*s != '=')
|
||||
{
|
||||
/* we just read a keyword, not a name */
|
||||
if (strncmp(name, ACL_IDTYPE_GID_KEYWORD, sizeof(name)) == 0)
|
||||
if (strcmp(name, ACL_IDTYPE_GID_KEYWORD) == 0)
|
||||
idtype = ACL_IDTYPE_GID;
|
||||
else if (strncmp(name, ACL_IDTYPE_UID_KEYWORD, sizeof(name)) != 0)
|
||||
elog(ERROR, "aclparse: bad keyword, must be [group|user]");
|
||||
else if (strcmp(name, ACL_IDTYPE_UID_KEYWORD) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("unrecognized keyword: \"%s\"", name),
|
||||
errhint("ACL keyword must be \"group\" or \"user\".")));
|
||||
s = getid(s, name); /* move s to the name beyond the keyword */
|
||||
if (name[0] == '\0')
|
||||
elog(ERROR, "aclparse: a name must follow the [group|user] keyword");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing name"),
|
||||
errhint("A name must follow the [group|user] keyword.")));
|
||||
}
|
||||
if (name[0] == '\0')
|
||||
idtype = ACL_IDTYPE_WORLD;
|
||||
|
||||
if (*s != '=')
|
||||
elog(ERROR, "aclparse: expecting \"=\" sign");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing \"=\" sign")));
|
||||
|
||||
privs = goption = ACL_NO_RIGHTS;
|
||||
|
||||
@ -221,8 +233,10 @@ aclparse(const char *s, AclItem *aip)
|
||||
read = ACL_CREATE_TEMP;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "aclparse: mode flags must use \"%s\"",
|
||||
ACL_ALL_RIGHTS_STR);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid mode character: must be one of \"%s\"",
|
||||
ACL_ALL_RIGHTS_STR)));
|
||||
}
|
||||
|
||||
privs |= read;
|
||||
@ -247,14 +261,18 @@ aclparse(const char *s, AclItem *aip)
|
||||
{
|
||||
s = getid(s + 1, name2);
|
||||
if (name2[0] == '\0')
|
||||
elog(ERROR, "aclparse: a name must follow the \"/\" sign");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("a name must follow the \"/\" sign")));
|
||||
|
||||
aip->ai_grantor = get_usesysid(name2);
|
||||
}
|
||||
else
|
||||
{
|
||||
aip->ai_grantor = BOOTSTRAP_USESYSID;
|
||||
elog(WARNING, "defaulting grantor to %u", BOOTSTRAP_USESYSID);
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INVALID_GRANTOR),
|
||||
errmsg("defaulting grantor to %u", BOOTSTRAP_USESYSID)));
|
||||
}
|
||||
|
||||
ACLITEM_SET_PRIVS_IDTYPE(*aip, privs, goption, idtype);
|
||||
@ -280,7 +298,7 @@ allocacl(int n)
|
||||
Size size;
|
||||
|
||||
if (n < 0)
|
||||
elog(ERROR, "allocacl: invalid size: %d", n);
|
||||
elog(ERROR, "invalid size: %d", n);
|
||||
size = ACL_N_SIZE(n);
|
||||
new_acl = (Acl *) palloc0(size);
|
||||
new_acl->size = size;
|
||||
@ -311,7 +329,10 @@ aclitemin(PG_FUNCTION_ARGS)
|
||||
while (isspace((unsigned char) *s))
|
||||
++s;
|
||||
if (*s)
|
||||
elog(ERROR, "aclitemin: extra garbage at end of specification");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("extra garbage at the end of the ACL specification")));
|
||||
|
||||
PG_RETURN_ACLITEM_P(aip);
|
||||
}
|
||||
|
||||
@ -373,8 +394,8 @@ aclitemout(PG_FUNCTION_ARGS)
|
||||
case ACL_IDTYPE_WORLD:
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "aclitemout: bad idtype: %d",
|
||||
ACLITEM_GET_IDTYPE(*aip));
|
||||
elog(ERROR, "unrecognized idtype: %d",
|
||||
(int) ACLITEM_GET_IDTYPE(*aip));
|
||||
break;
|
||||
}
|
||||
while (*p)
|
||||
@ -482,7 +503,7 @@ acldefault(GrantObjectType objtype, AclId ownerid)
|
||||
owner_default = ACL_ALL_RIGHTS_NAMESPACE;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "acldefault: bogus objtype %d", (int) objtype);
|
||||
elog(ERROR, "unrecognized objtype: %d", (int) objtype);
|
||||
world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
owner_default = ACL_NO_RIGHTS;
|
||||
break;
|
||||
@ -644,7 +665,10 @@ restart:
|
||||
AclItem mod_acl;
|
||||
|
||||
if (behavior == DROP_RESTRICT)
|
||||
elog(ERROR, "dependent privileges exist (use CASCADE to revoke them too)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
|
||||
errmsg("dependent privileges exist"),
|
||||
errhint("Use CASCADE to revoke them too.")));
|
||||
|
||||
mod_acl.ai_grantor = grantee;
|
||||
mod_acl.ai_grantee = aip[i].ai_grantee;
|
||||
@ -718,7 +742,9 @@ aclremove(PG_FUNCTION_ARGS)
|
||||
new_aip = ACL_DAT(new_acl);
|
||||
if (dst == 0)
|
||||
{ /* start */
|
||||
elog(ERROR, "aclremove: removal of the world ACL??");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot remove the world ACL")));
|
||||
}
|
||||
else if (dst == old_num - 1)
|
||||
{ /* end */
|
||||
@ -784,7 +810,9 @@ makeaclitem(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else if (u_grantee != 0 && g_grantee != 0)
|
||||
{
|
||||
elog(ERROR, "cannot specify both user and group");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot specify both user and group")));
|
||||
}
|
||||
else if (u_grantee != 0)
|
||||
{
|
||||
@ -840,7 +868,9 @@ convert_priv_string(text *priv_type_text)
|
||||
if (strcasecmp(priv_type, "TEMPORARY") == 0)
|
||||
return ACL_CREATE_TEMP;
|
||||
|
||||
elog(ERROR, "invalid privilege type %s", priv_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
return ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1063,8 +1093,9 @@ convert_table_priv_string(text *priv_type_text)
|
||||
if (strcasecmp(priv_type, "TRIGGER WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_TRIGGER);
|
||||
|
||||
elog(ERROR, "has_table_privilege: invalid privilege type %s",
|
||||
priv_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
return ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1237,7 +1268,9 @@ convert_database_name(text *databasename)
|
||||
|
||||
oid = get_database_oid(dbname);
|
||||
if (!OidIsValid(oid))
|
||||
elog(ERROR, "database \"%s\" does not exist", dbname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_DATABASE),
|
||||
errmsg("database \"%s\" does not exist", dbname)));
|
||||
|
||||
return oid;
|
||||
}
|
||||
@ -1272,8 +1305,9 @@ convert_database_priv_string(text *priv_type_text)
|
||||
if (strcasecmp(priv_type, "TEMP WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP);
|
||||
|
||||
elog(ERROR, "has_database_privilege: invalid privilege type %s",
|
||||
priv_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
return ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1448,7 +1482,9 @@ convert_function_name(text *functionname)
|
||||
CStringGetDatum(funcname)));
|
||||
|
||||
if (!OidIsValid(oid))
|
||||
elog(ERROR, "function \"%s\" does not exist", funcname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function \"%s\" does not exist", funcname)));
|
||||
|
||||
return oid;
|
||||
}
|
||||
@ -1473,8 +1509,9 @@ convert_function_priv_string(text *priv_type_text)
|
||||
if (strcasecmp(priv_type, "EXECUTE WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_EXECUTE);
|
||||
|
||||
elog(ERROR, "has_function_privilege: invalid privilege type %s",
|
||||
priv_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
return ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1649,7 +1686,9 @@ convert_language_name(text *languagename)
|
||||
CStringGetDatum(langname),
|
||||
0, 0, 0);
|
||||
if (!OidIsValid(oid))
|
||||
elog(ERROR, "language \"%s\" does not exist", langname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("language \"%s\" does not exist", langname)));
|
||||
|
||||
return oid;
|
||||
}
|
||||
@ -1674,8 +1713,9 @@ convert_language_priv_string(text *priv_type_text)
|
||||
if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_USAGE);
|
||||
|
||||
elog(ERROR, "has_language_privilege: invalid privilege type %s",
|
||||
priv_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
return ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1850,7 +1890,9 @@ convert_schema_name(text *schemaname)
|
||||
CStringGetDatum(nspname),
|
||||
0, 0, 0);
|
||||
if (!OidIsValid(oid))
|
||||
elog(ERROR, "schema \"%s\" does not exist", nspname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_SCHEMA),
|
||||
errmsg("schema \"%s\" does not exist", nspname)));
|
||||
|
||||
return oid;
|
||||
}
|
||||
@ -1880,7 +1922,8 @@ convert_schema_priv_string(text *priv_type_text)
|
||||
if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0)
|
||||
return ACL_GRANT_OPTION_FOR(ACL_USAGE);
|
||||
|
||||
elog(ERROR, "has_schema_privilege: invalid privilege type %s",
|
||||
priv_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
|
||||
return ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Copyright (c) 2003, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.5 2003/07/01 00:04:38 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.6 2003/07/27 04:53:02 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -15,6 +15,7 @@
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "utils/array.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
@ -44,7 +45,10 @@ array_push(PG_FUNCTION_ARGS)
|
||||
ArrayMetaState *my_extra;
|
||||
|
||||
if (arg0_typeid == InvalidOid || arg1_typeid == InvalidOid)
|
||||
elog(ERROR, "array_push: cannot determine input data types");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("could not determine input data types")));
|
||||
|
||||
arg0_elemid = get_element_type(arg0_typeid);
|
||||
arg1_elemid = get_element_type(arg1_typeid);
|
||||
|
||||
@ -63,7 +67,9 @@ array_push(PG_FUNCTION_ARGS)
|
||||
else
|
||||
{
|
||||
/* Shouldn't get here given proper type checking in parser */
|
||||
elog(ERROR, "array_push: neither input type is an array");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("neither input type is an array")));
|
||||
PG_RETURN_NULL(); /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -87,8 +93,9 @@ array_push(PG_FUNCTION_ARGS)
|
||||
else if (ARR_NDIM(v) == 0)
|
||||
indx = 1;
|
||||
else
|
||||
elog(ERROR, "only empty and one-dimensional arrays are supported");
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("input must be empty or one-dimensional array")));
|
||||
|
||||
/*
|
||||
* We arrange to look up info about element type only once per series
|
||||
@ -169,16 +176,25 @@ array_cat(PG_FUNCTION_ARGS)
|
||||
|
||||
/* the rest fall into combo 2, 3, or 4 */
|
||||
if (ndims1 != ndims2 && ndims1 != ndims2 - 1 && ndims1 != ndims2 + 1)
|
||||
elog(ERROR, "Cannot concatenate incompatible arrays of %d and "
|
||||
"%d dimensions", ndims1, ndims2);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("cannot concatenate incompatible arrays"),
|
||||
errdetail("Arrays of %d and %d dimensions are not "
|
||||
"compatible for concatenation.",
|
||||
ndims1, ndims2)));
|
||||
|
||||
element_type1 = ARR_ELEMTYPE(v1);
|
||||
element_type2 = ARR_ELEMTYPE(v2);
|
||||
|
||||
/* Do we have a matching element types */
|
||||
if (element_type1 != element_type2)
|
||||
elog(ERROR, "Cannot concatenate incompatible arrays with element "
|
||||
"type %u and %u", element_type1, element_type2);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot concatenate incompatible arrays"),
|
||||
errdetail("Arrays with element types %s and %s are not "
|
||||
"compatible for concatenation.",
|
||||
format_type_be(element_type1),
|
||||
format_type_be(element_type2))));
|
||||
|
||||
/* OK, use it */
|
||||
element_type = element_type1;
|
||||
@ -211,7 +227,11 @@ array_cat(PG_FUNCTION_ARGS)
|
||||
for (i = 0; i < ndims1; i++)
|
||||
{
|
||||
if (dims1[i] != dims2[i] || lbs1[i] != lbs2[i])
|
||||
elog(ERROR, "Cannot concatenate arrays with differing dimensions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("cannot concatenate incompatible arrays"),
|
||||
errdetail("Arrays with differing dimensions are not "
|
||||
"compatible for concatenation.")));
|
||||
|
||||
dims[i + 1] = dims1[i];
|
||||
lbs[i + 1] = lbs1[i];
|
||||
@ -237,7 +257,11 @@ array_cat(PG_FUNCTION_ARGS)
|
||||
for (i = 0; i < ndims1; i++)
|
||||
{
|
||||
if (dims1[i] != dims[i + 1] || lbs1[i] != lbs[i + 1])
|
||||
elog(ERROR, "Cannot concatenate arrays with differing dimensions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("cannot concatenate incompatible arrays"),
|
||||
errdetail("Arrays with differing dimensions are not "
|
||||
"compatible for concatenation.")));
|
||||
}
|
||||
}
|
||||
else /* (ndims1 == ndims2 + 1) */
|
||||
@ -260,7 +284,11 @@ array_cat(PG_FUNCTION_ARGS)
|
||||
for (i = 0; i < ndims2; i++)
|
||||
{
|
||||
if (dims2[i] != dims[i + 1] || lbs2[i] != lbs[i + 1])
|
||||
elog(ERROR, "Cannot concatenate arrays with differing dimensions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("cannot concatenate incompatible arrays"),
|
||||
errdetail("Arrays with differing dimensions are not "
|
||||
"compatible for concatenation.")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,9 +330,18 @@ create_singleton_array(FunctionCallInfo fcinfo,
|
||||
ArrayMetaState *my_extra;
|
||||
|
||||
if (element_type == 0)
|
||||
elog(ERROR, "Invalid array element type: %u", element_type);
|
||||
if (ndims < 1 || ndims > MAXDIM)
|
||||
elog(ERROR, "Invalid number of dimensions %d", ndims);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid array element type: %u", element_type)));
|
||||
if (ndims < 1)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid number of dimensions: %d", ndims)));
|
||||
if (ndims > MAXDIM)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("number of array dimensions exceeds the maximum allowed, %d",
|
||||
MAXDIM)));
|
||||
|
||||
dvalues[0] = element;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.93 2003/07/01 00:04:38 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.94 2003/07/27 04:53:02 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -203,10 +203,17 @@ array_in(PG_FUNCTION_ARGS)
|
||||
break; /* no more dimension items */
|
||||
p++;
|
||||
if (ndim >= MAXDIM)
|
||||
elog(ERROR, "array_in: more than %d dimensions", MAXDIM);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("number of array dimensions exceeds the maximum allowed, %d",
|
||||
MAXDIM)));
|
||||
|
||||
for (q = p; isdigit((unsigned char) *q); q++);
|
||||
if (q == p) /* no digits? */
|
||||
elog(ERROR, "array_in: missing dimension value");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing dimension value")));
|
||||
|
||||
if (*q == ':')
|
||||
{
|
||||
/* [m:n] format */
|
||||
@ -215,7 +222,9 @@ array_in(PG_FUNCTION_ARGS)
|
||||
p = q + 1;
|
||||
for (q = p; isdigit((unsigned char) *q); q++);
|
||||
if (q == p) /* no digits? */
|
||||
elog(ERROR, "array_in: missing dimension value");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing dimension value")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -223,12 +232,18 @@ array_in(PG_FUNCTION_ARGS)
|
||||
lBound[ndim] = 1;
|
||||
}
|
||||
if (*q != ']')
|
||||
elog(ERROR, "array_in: missing ']' in array declaration");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing \"]\" in array dimensions")));
|
||||
|
||||
*q = '\0';
|
||||
ub = atoi(p);
|
||||
p = q + 1;
|
||||
if (ub < lBound[ndim])
|
||||
elog(ERROR, "array_in: upper_bound cannot be < lower_bound");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("upper bound cannot be less than lower bound")));
|
||||
|
||||
dim[ndim] = ub - lBound[ndim] + 1;
|
||||
ndim++;
|
||||
}
|
||||
@ -237,7 +252,9 @@ array_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* No array dimensions, so intuit dimensions from brace structure */
|
||||
if (*p != '{')
|
||||
elog(ERROR, "array_in: Need to specify dimension");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("array value must start with \"{\" or dimension information")));
|
||||
ndim = ArrayCount(p, dim, typdelim);
|
||||
for (i = 0; i < ndim; i++)
|
||||
lBound[i] = 1;
|
||||
@ -246,7 +263,9 @@ array_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* If array dimensions are given, expect '=' operator */
|
||||
if (strncmp(p, ASSGN, strlen(ASSGN)) != 0)
|
||||
elog(ERROR, "array_in: missing assignment operator");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing assignment operator")));
|
||||
p += strlen(ASSGN);
|
||||
while (isspace((unsigned char) *p))
|
||||
p++;
|
||||
@ -272,7 +291,9 @@ array_in(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
if (*p != '{')
|
||||
elog(ERROR, "array_in: missing left brace");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("missing left brace")));
|
||||
|
||||
dataPtr = ReadArrayStr(p, nitems, ndim, dim, &my_extra->proc, typelem,
|
||||
typmod, typdelim, typlen, typbyval, typalign,
|
||||
@ -328,14 +349,18 @@ ArrayCount(char *str, int *dim, char typdelim)
|
||||
{
|
||||
case '\0':
|
||||
/* Signal a premature end of the string */
|
||||
elog(ERROR, "malformed array constant: %s", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", str)));
|
||||
break;
|
||||
case '\\':
|
||||
/* skip the escaped character */
|
||||
if (*(ptr + 1))
|
||||
ptr++;
|
||||
else
|
||||
elog(ERROR, "malformed array constant: %s", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", str)));
|
||||
break;
|
||||
case '\"':
|
||||
scanning_string = !scanning_string;
|
||||
@ -344,7 +369,10 @@ ArrayCount(char *str, int *dim, char typdelim)
|
||||
if (!scanning_string)
|
||||
{
|
||||
if (nest_level >= MAXDIM)
|
||||
elog(ERROR, "array_in: illformed array constant");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("number of array dimensions exceeds the maximum allowed, %d",
|
||||
MAXDIM)));
|
||||
temp[nest_level] = 0;
|
||||
nest_level++;
|
||||
if (ndim < nest_level)
|
||||
@ -355,7 +383,9 @@ ArrayCount(char *str, int *dim, char typdelim)
|
||||
if (!scanning_string)
|
||||
{
|
||||
if (nest_level == 0)
|
||||
elog(ERROR, "array_in: illformed array constant");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", str)));
|
||||
nest_level--;
|
||||
if (nest_level == 0)
|
||||
eoArray = itemdone = true;
|
||||
@ -447,7 +477,9 @@ ReadArrayStr(char *arrayStr,
|
||||
{
|
||||
case '\0':
|
||||
/* Signal a premature end of the string */
|
||||
elog(ERROR, "malformed array constant: %s", arrayStr);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", arrayStr)));
|
||||
break;
|
||||
case '\\':
|
||||
{
|
||||
@ -457,7 +489,9 @@ ReadArrayStr(char *arrayStr,
|
||||
for (cptr = ptr; *cptr != '\0'; cptr++)
|
||||
*cptr = *(cptr + 1);
|
||||
if (*ptr == '\0')
|
||||
elog(ERROR, "malformed array constant: %s", arrayStr);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", arrayStr)));
|
||||
break;
|
||||
}
|
||||
case '\"':
|
||||
@ -476,7 +510,9 @@ ReadArrayStr(char *arrayStr,
|
||||
if (!scanning_string)
|
||||
{
|
||||
if (nest_level >= ndim)
|
||||
elog(ERROR, "array_in: illformed array constant");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", arrayStr)));
|
||||
nest_level++;
|
||||
indx[nest_level - 1] = 0;
|
||||
/* skip leading whitespace */
|
||||
@ -489,7 +525,9 @@ ReadArrayStr(char *arrayStr,
|
||||
if (!scanning_string)
|
||||
{
|
||||
if (nest_level == 0)
|
||||
elog(ERROR, "array_in: illformed array constant");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", arrayStr)));
|
||||
if (i == -1)
|
||||
i = ArrayGetOffset0(ndim, indx, prod);
|
||||
indx[nest_level - 1] = 0;
|
||||
@ -525,7 +563,10 @@ ReadArrayStr(char *arrayStr,
|
||||
}
|
||||
*ptr++ = '\0';
|
||||
if (i < 0 || i >= nitems)
|
||||
elog(ERROR, "array_in: illformed array constant");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("malformed array literal: \"%s\"", arrayStr)));
|
||||
|
||||
values[i] = FunctionCall3(inputproc,
|
||||
CStringGetDatum(itemstart),
|
||||
ObjectIdGetDatum(typelem),
|
||||
@ -839,16 +880,29 @@ array_recv(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Get the array header information */
|
||||
ndim = pq_getmsgint(buf, 4);
|
||||
if (ndim < 0 || ndim > MAXDIM)
|
||||
elog(ERROR, "array_recv: invalid number of dimensions");
|
||||
if (ndim < 0) /* we do allow zero-dimension arrays */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid number of dimensions: %d", ndim)));
|
||||
if (ndim > MAXDIM)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("number of array dimensions exceeds the maximum allowed, %d",
|
||||
MAXDIM)));
|
||||
|
||||
flags = pq_getmsgint(buf, 4);
|
||||
if (flags != 0)
|
||||
elog(ERROR, "array_recv: invalid array flags");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid array flags")));
|
||||
|
||||
element_type = pq_getmsgint(buf, sizeof(Oid));
|
||||
if (element_type != spec_element_type)
|
||||
{
|
||||
/* XXX Can we allow taking the input element type in any cases? */
|
||||
elog(ERROR, "array_recv: wrong element type");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("wrong element type")));
|
||||
}
|
||||
|
||||
for (i = 0; i < ndim; i++)
|
||||
@ -889,8 +943,10 @@ array_recv(PG_FUNCTION_ARGS)
|
||||
&my_extra->typalign, &my_extra->typdelim,
|
||||
&my_extra->typelem, &my_extra->typiofunc);
|
||||
if (!OidIsValid(my_extra->typiofunc))
|
||||
elog(ERROR, "No binary input function available for type %s",
|
||||
format_type_be(element_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no binary input function available for type %s",
|
||||
format_type_be(element_type))));
|
||||
fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
|
||||
fcinfo->flinfo->fn_mcxt);
|
||||
my_extra->element_type = element_type;
|
||||
@ -955,7 +1011,9 @@ ReadArrayBinary(StringInfo buf,
|
||||
/* Get and check the item length */
|
||||
itemlen = pq_getmsgint(buf, 4);
|
||||
if (itemlen < 0 || itemlen > (buf->len - buf->cursor))
|
||||
elog(ERROR, "insufficient data left in message");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("insufficient data left in message")));
|
||||
|
||||
/*
|
||||
* Rather than copying data around, we just set up a phony
|
||||
@ -981,8 +1039,10 @@ ReadArrayBinary(StringInfo buf,
|
||||
|
||||
/* Trouble if it didn't eat the whole buffer */
|
||||
if (elem_buf.cursor != itemlen)
|
||||
elog(ERROR, "Improper binary format in array element %d",
|
||||
i + 1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("improper binary format in array element %d",
|
||||
i + 1)));
|
||||
|
||||
buf->data[buf->cursor] = csave;
|
||||
}
|
||||
@ -1060,8 +1120,10 @@ array_send(PG_FUNCTION_ARGS)
|
||||
&my_extra->typalign, &my_extra->typdelim,
|
||||
&my_extra->typelem, &my_extra->typiofunc);
|
||||
if (!OidIsValid(my_extra->typiofunc))
|
||||
elog(ERROR, "No binary output function available for type %s",
|
||||
format_type_be(element_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no binary output function available for type %s",
|
||||
format_type_be(element_type))));
|
||||
fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
|
||||
fcinfo->flinfo->fn_mcxt);
|
||||
my_extra->element_type = element_type;
|
||||
@ -1407,7 +1469,9 @@ array_get_slice(ArrayType *array,
|
||||
* Code below shows how we could support it if the parser were
|
||||
* changed to label output as a suitable varlena array type.
|
||||
*/
|
||||
elog(ERROR, "Slices of fixed-length arrays not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("slices of fixed-length arrays not implemented")));
|
||||
|
||||
/*
|
||||
* fixed-length arrays -- these are assumed to be 1-d, 0-based XXX
|
||||
@ -1543,9 +1607,15 @@ array_set(ArrayType *array,
|
||||
* cannot extend them, either.
|
||||
*/
|
||||
if (nSubscripts != 1)
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
|
||||
if (indx[0] < 0 || indx[0] * elmlen >= arraylen)
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
|
||||
newarray = (ArrayType *) palloc(arraylen);
|
||||
memcpy(newarray, array, arraylen);
|
||||
elt_ptr = (char *) newarray + indx[0] * elmlen;
|
||||
@ -1582,7 +1652,9 @@ array_set(ArrayType *array,
|
||||
}
|
||||
|
||||
if (ndim != nSubscripts || ndim <= 0 || ndim > MAXDIM)
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
|
||||
/* copy dim/lb since we may modify them */
|
||||
memcpy(dim, ARR_DIMS(array), ndim * sizeof(int));
|
||||
@ -1602,7 +1674,9 @@ array_set(ArrayType *array,
|
||||
extendbefore = true;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
}
|
||||
if (indx[i] >= (dim[i] + lb[i]))
|
||||
{
|
||||
@ -1612,7 +1686,9 @@ array_set(ArrayType *array,
|
||||
extendafter = true;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1727,7 +1803,9 @@ array_set_slice(ArrayType *array,
|
||||
/*
|
||||
* fixed-length arrays -- not got round to doing this...
|
||||
*/
|
||||
elog(ERROR, "Updates on slices of fixed-length arrays not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("updates on slices of fixed-length arrays not implemented")));
|
||||
}
|
||||
|
||||
/* detoast arrays if necessary */
|
||||
@ -1763,7 +1841,9 @@ array_set_slice(ArrayType *array,
|
||||
}
|
||||
|
||||
if (ndim < nSubscripts || ndim <= 0 || ndim > MAXDIM)
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
|
||||
/* copy dim/lb since we may modify them */
|
||||
memcpy(dim, ARR_DIMS(array), ndim * sizeof(int));
|
||||
@ -1778,7 +1858,9 @@ array_set_slice(ArrayType *array,
|
||||
for (i = 0; i < nSubscripts; i++)
|
||||
{
|
||||
if (lowerIndx[i] > upperIndx[i])
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
if (lowerIndx[i] < lb[i])
|
||||
{
|
||||
if (ndim == 1 && upperIndx[i] >= lb[i] - 1)
|
||||
@ -1787,14 +1869,18 @@ array_set_slice(ArrayType *array,
|
||||
lb[i] = lowerIndx[i];
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
}
|
||||
if (upperIndx[i] >= (dim[i] + lb[i]))
|
||||
{
|
||||
if (ndim == 1 && lowerIndx[i] <= (dim[i] + lb[i]))
|
||||
dim[i] = upperIndx[i] - lb[i] + 1;
|
||||
else
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
}
|
||||
}
|
||||
/* fill any missing subscript positions with full array range */
|
||||
@ -1803,7 +1889,9 @@ array_set_slice(ArrayType *array,
|
||||
lowerIndx[i] = lb[i];
|
||||
upperIndx[i] = dim[i] + lb[i] - 1;
|
||||
if (lowerIndx[i] > upperIndx[i])
|
||||
elog(ERROR, "Invalid array subscripts");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("invalid array subscripts")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1813,7 +1901,9 @@ array_set_slice(ArrayType *array,
|
||||
mda_get_range(ndim, span, lowerIndx, upperIndx);
|
||||
nsrcitems = ArrayGetNItems(ndim, span);
|
||||
if (nsrcitems > ArrayGetNItems(ARR_NDIM(srcArray), ARR_DIMS(srcArray)))
|
||||
elog(ERROR, "Source array too small");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("source array too small")));
|
||||
|
||||
/*
|
||||
* Compute space occupied by new entries, space occupied by replaced
|
||||
@ -1948,9 +2038,9 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType)
|
||||
|
||||
/* Get input array */
|
||||
if (fcinfo->nargs < 1)
|
||||
elog(ERROR, "array_map: invalid nargs: %d", fcinfo->nargs);
|
||||
elog(ERROR, "invalid nargs: %d", fcinfo->nargs);
|
||||
if (PG_ARGISNULL(0))
|
||||
elog(ERROR, "array_map: null input array");
|
||||
elog(ERROR, "null input array");
|
||||
v = PG_GETARG_ARRAYTYPE_P(0);
|
||||
|
||||
Assert(ARR_ELEMTYPE(v) == inpType);
|
||||
@ -2034,7 +2124,9 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType)
|
||||
fcinfo->isnull = false;
|
||||
values[i] = FunctionCallInvoke(fcinfo);
|
||||
if (fcinfo->isnull)
|
||||
elog(ERROR, "array_map: cannot handle NULL in array");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("NULL array elements not supported")));
|
||||
|
||||
/* Ensure data is not toasted */
|
||||
if (typlen == -1)
|
||||
@ -2129,9 +2221,30 @@ construct_md_array(Datum *elems,
|
||||
int i;
|
||||
int nelems;
|
||||
|
||||
if (ndims < 1 || ndims > MAXDIM)
|
||||
elog(ERROR, "Number of array dimensions, %d, exceeds the maximum allowed (%d)",
|
||||
ndims, MAXDIM);
|
||||
if (ndims < 0) /* we do allow zero-dimension arrays */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid number of dimensions: %d", ndims)));
|
||||
if (ndims > MAXDIM)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("number of array dimensions exceeds the maximum allowed, %d",
|
||||
MAXDIM)));
|
||||
|
||||
/* fast track for empty array */
|
||||
if (ndims == 0)
|
||||
{
|
||||
/* Allocate and initialize 0-D result array */
|
||||
nbytes = ARR_OVERHEAD(ndims);
|
||||
result = (ArrayType *) palloc(nbytes);
|
||||
|
||||
result->size = nbytes;
|
||||
result->ndim = ndims;
|
||||
result->flags = 0;
|
||||
result->elemtype = elmtype;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nelems = ArrayGetNItems(ndims, dims);
|
||||
|
||||
@ -2249,7 +2362,9 @@ array_eq(PG_FUNCTION_ARGS)
|
||||
FunctionCallInfoData locfcinfo;
|
||||
|
||||
if (element_type != ARR_ELEMTYPE(array2))
|
||||
elog(ERROR, "cannot compare arrays of different element types");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot compare arrays of different element types")));
|
||||
|
||||
/* fast path if the arrays do not have the same number of elements */
|
||||
if (nitems1 != nitems2)
|
||||
@ -2415,7 +2530,9 @@ array_cmp(FunctionCallInfo fcinfo)
|
||||
|
||||
element_type = ARR_ELEMTYPE(array1);
|
||||
if (element_type != ARR_ELEMTYPE(array2))
|
||||
elog(ERROR, "cannot compare arrays of different element types");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot compare arrays of different element types")));
|
||||
|
||||
/*
|
||||
* We arrange to look up the element type info and related functions
|
||||
@ -2797,10 +2914,15 @@ array_type_coerce(PG_FUNCTION_ARGS)
|
||||
Oid funcId;
|
||||
|
||||
if (tgt_type == InvalidOid)
|
||||
elog(ERROR, "Cannot determine target array type");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("could not determine target array type")));
|
||||
|
||||
tgt_elem_type = get_element_type(tgt_type);
|
||||
if (tgt_elem_type == InvalidOid)
|
||||
elog(ERROR, "Target type is not an array");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("target type is not an array")));
|
||||
|
||||
/*
|
||||
* We don't deal with domain constraints yet, so bail out.
|
||||
@ -2811,8 +2933,10 @@ array_type_coerce(PG_FUNCTION_ARGS)
|
||||
* check to the coercion.
|
||||
*/
|
||||
if (getBaseType(tgt_elem_type) != tgt_elem_type)
|
||||
elog(ERROR, "array coercion to domain type elements not " \
|
||||
"currently supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("array coercion to domain type elements not "
|
||||
"currently supported")));
|
||||
|
||||
if (!find_coercion_pathway(tgt_elem_type, src_elem_type,
|
||||
COERCION_EXPLICIT, &funcId))
|
||||
@ -2901,7 +3025,9 @@ accumArrayResult(ArrayBuildState *astate,
|
||||
}
|
||||
|
||||
if (disnull)
|
||||
elog(ERROR, "NULL elements not allowed in Arrays");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("NULL array elements not supported")));
|
||||
|
||||
/* Use datumCopy to ensure pass-by-ref stuff is copied into mcontext */
|
||||
astate->dvalues[astate->nelems++] =
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Portions Copyright (c) 1999-2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.15 2003/07/14 16:41:38 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.16 2003/07/27 04:53:03 tgl Exp $
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
@ -63,8 +63,10 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *dest, int
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "unsupported encoding conversion from %s to ASCII",
|
||||
pg_encoding_to_char(enc));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("unsupported encoding conversion from %s to ASCII",
|
||||
pg_encoding_to_char(enc))));
|
||||
return; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.27 2003/05/12 23:08:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.28 2003/07/27 04:53:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -75,7 +75,9 @@ boolin(PG_FUNCTION_ARGS)
|
||||
break;
|
||||
}
|
||||
|
||||
elog(ERROR, "Bad boolean external representation '%s'", b);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for boolean: \"%s\"", b)));
|
||||
|
||||
/* not reached */
|
||||
PG_RETURN_BOOL(false);
|
||||
|
@ -9,7 +9,7 @@
|
||||
* workings can be found in the book "Software Solutions in C" by
|
||||
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.58 2003/05/13 18:03:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.59 2003/07/27 04:53:03 tgl Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@ -193,7 +193,9 @@ cash_in(PG_FUNCTION_ARGS)
|
||||
s++;
|
||||
|
||||
if (*s != '\0')
|
||||
elog(ERROR, "Bad money external representation %s", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for money: \"%s\"", str)));
|
||||
|
||||
result = (value * sgn);
|
||||
|
||||
@ -290,7 +292,9 @@ cash_out(PG_FUNCTION_ARGS)
|
||||
if (minus)
|
||||
{
|
||||
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
|
||||
elog(ERROR, "Memory allocation failed, can't output cash");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
|
||||
/* Position code of 0 means use parens */
|
||||
if (convention == 0)
|
||||
@ -303,7 +307,9 @@ cash_out(PG_FUNCTION_ARGS)
|
||||
else
|
||||
{
|
||||
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count)))
|
||||
elog(ERROR, "Memory allocation failed, can't output cash");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
|
||||
strcpy(result, buf + count);
|
||||
}
|
||||
@ -468,7 +474,9 @@ cash_div_flt8(PG_FUNCTION_ARGS)
|
||||
Cash result;
|
||||
|
||||
if (f == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = rint(c / f);
|
||||
PG_RETURN_CASH(result);
|
||||
@ -518,7 +526,9 @@ cash_div_flt4(PG_FUNCTION_ARGS)
|
||||
Cash result;
|
||||
|
||||
if (f == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = rint(c / f);
|
||||
PG_RETURN_CASH(result);
|
||||
@ -569,7 +579,9 @@ cash_div_int4(PG_FUNCTION_ARGS)
|
||||
Cash result;
|
||||
|
||||
if (i == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = rint(c / i);
|
||||
|
||||
@ -619,7 +631,9 @@ cash_div_int2(PG_FUNCTION_ARGS)
|
||||
Cash result;
|
||||
|
||||
if (s == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = rint(c / s);
|
||||
PG_RETURN_CASH(result);
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.35 2003/05/12 23:08:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.36 2003/07/27 04:53:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -181,7 +181,9 @@ chardiv(PG_FUNCTION_ARGS)
|
||||
char arg2 = PG_GETARG_CHAR(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_CHAR((int8) arg1 / (int8) arg2);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.86 2003/07/24 04:38:19 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.87 2003/07/27 04:53:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -67,11 +67,15 @@ date_in(PG_FUNCTION_ARGS)
|
||||
char lowstr[MAXDATELEN + 1];
|
||||
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad date external representation (too long) '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for date: \"%s\"", str)));
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp) != 0))
|
||||
elog(ERROR, "Bad date external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for date: \"%s\"", str)));
|
||||
|
||||
switch (dtype)
|
||||
{
|
||||
@ -79,8 +83,10 @@ date_in(PG_FUNCTION_ARGS)
|
||||
break;
|
||||
|
||||
case DTK_CURRENT:
|
||||
elog(ERROR, "Date CURRENT no longer supported"
|
||||
"\n\tdate_in() internal coding error");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("\"current\" is no longer supported")));
|
||||
|
||||
GetCurrentDateTime(tm);
|
||||
break;
|
||||
|
||||
@ -89,7 +95,9 @@ date_in(PG_FUNCTION_ARGS)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "Unrecognized date external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for date: \"%s\"", str)));
|
||||
}
|
||||
|
||||
date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
|
||||
@ -356,7 +364,9 @@ timestamp_date(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
|
||||
elog(ERROR, "Unable to convert timestamp to date");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
|
||||
|
||||
@ -426,7 +436,9 @@ timestamptz_date(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
|
||||
elog(ERROR, "Unable to convert timestamp to date");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
|
||||
|
||||
@ -451,7 +463,9 @@ abstime_date(PG_FUNCTION_ARGS)
|
||||
case INVALID_ABSTIME:
|
||||
case NOSTART_ABSTIME:
|
||||
case NOEND_ABSTIME:
|
||||
elog(ERROR, "Unable to convert reserved abstime value to date");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert reserved abstime value to date")));
|
||||
|
||||
/*
|
||||
* pretend to drop through to make compiler think that result
|
||||
@ -510,7 +524,10 @@ text_date(PG_FUNCTION_ARGS)
|
||||
dstr[MAXDATELEN + 1];
|
||||
|
||||
if (VARSIZE(str) - VARHDRSZ > MAXDATELEN)
|
||||
elog(ERROR, "Bad date external representation (too long)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for date: \"%s\"",
|
||||
VARDATA(str))));
|
||||
|
||||
sp = VARDATA(str);
|
||||
dp = dstr;
|
||||
@ -548,11 +565,15 @@ time_in(PG_FUNCTION_ARGS)
|
||||
int ftype[MAXDATEFIELDS];
|
||||
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad time external representation (too long) '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for time: \"%s\"", str)));
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||
elog(ERROR, "Bad time external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for time: \"%s\"", str)));
|
||||
|
||||
tm2time(tm, fsec, &result);
|
||||
AdjustTimeForTypmod(&result, typmod);
|
||||
@ -978,7 +999,9 @@ timestamp_time(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
|
||||
elog(ERROR, "Unable to convert timestamp to time");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
|
||||
@ -1013,7 +1036,9 @@ timestamptz_time(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
|
||||
elog(ERROR, "Unable to convert timestamptz to time");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
|
||||
@ -1228,7 +1253,10 @@ text_time(PG_FUNCTION_ARGS)
|
||||
dstr[MAXDATELEN + 1];
|
||||
|
||||
if (VARSIZE(str) - VARHDRSZ > MAXDATELEN)
|
||||
elog(ERROR, "Bad time external representation (too long)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for time: \"%s\"",
|
||||
VARDATA(str))));
|
||||
|
||||
sp = VARDATA(str);
|
||||
dp = dstr;
|
||||
@ -1259,9 +1287,12 @@ time_part(PG_FUNCTION_ARGS)
|
||||
lowunits[MAXDATELEN + 1];
|
||||
|
||||
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
|
||||
elog(ERROR, "TIME units '%s' not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIME units \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))))));
|
||||
|
||||
up = VARDATA(units);
|
||||
lp = lowunits;
|
||||
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
|
||||
@ -1326,9 +1357,12 @@ time_part(PG_FUNCTION_ARGS)
|
||||
case DTK_CENTURY:
|
||||
case DTK_MILLENNIUM:
|
||||
default:
|
||||
elog(ERROR, "TIME units '%s' not supported",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIME units \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))))));
|
||||
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
@ -1342,9 +1376,11 @@ time_part(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "TIME units '%s' not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIME units \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))))));
|
||||
result = 0;
|
||||
}
|
||||
|
||||
@ -1394,12 +1430,17 @@ timetz_in(PG_FUNCTION_ARGS)
|
||||
int ftype[MAXDATEFIELDS];
|
||||
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad time with time zone"
|
||||
" external representation (too long) '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for time with time zone: \"%s\"",
|
||||
str)));
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||
elog(ERROR, "Bad time external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for time with time zone: \"%s\"",
|
||||
str)));
|
||||
|
||||
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
|
||||
tm2timetz(tm, fsec, tz, result);
|
||||
@ -1898,7 +1939,9 @@ timestamptz_timetz(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
|
||||
elog(ERROR, "Unable to convert timestamptz to timetz");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
|
||||
|
||||
@ -1974,7 +2017,10 @@ text_timetz(PG_FUNCTION_ARGS)
|
||||
dstr[MAXDATELEN + 1];
|
||||
|
||||
if (VARSIZE(str) - VARHDRSZ > MAXDATELEN)
|
||||
elog(ERROR, "Bad timetz external representation (too long)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for time with time zone: \"%s\"",
|
||||
VARDATA(str))));
|
||||
|
||||
sp = VARDATA(str);
|
||||
dp = dstr;
|
||||
@ -2005,9 +2051,12 @@ timetz_part(PG_FUNCTION_ARGS)
|
||||
lowunits[MAXDATELEN + 1];
|
||||
|
||||
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
|
||||
elog(ERROR, "TIMETZ units '%s' not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIMETZ units \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))))));
|
||||
|
||||
up = VARDATA(units);
|
||||
lp = lowunits;
|
||||
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
|
||||
@ -2086,9 +2135,12 @@ timetz_part(PG_FUNCTION_ARGS)
|
||||
case DTK_CENTURY:
|
||||
case DTK_MILLENNIUM:
|
||||
default:
|
||||
elog(ERROR, "TIMETZ units '%s' not supported",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIMETZ units \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))))));
|
||||
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
@ -2102,9 +2154,12 @@ timetz_part(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "TIMETZ units '%s' not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIMETZ units \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(units))))));
|
||||
|
||||
result = 0;
|
||||
}
|
||||
|
||||
@ -2129,9 +2184,12 @@ timetz_zone(PG_FUNCTION_ARGS)
|
||||
lowzone[MAXDATELEN + 1];
|
||||
|
||||
if (VARSIZE(zone) - VARHDRSZ > MAXDATELEN)
|
||||
elog(ERROR, "Time zone '%s' not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(zone))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("time zone \"%s\" not recognized",
|
||||
DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(zone))))));
|
||||
|
||||
up = VARDATA(zone);
|
||||
lp = lowzone;
|
||||
for (i = 0; i < (VARSIZE(zone) - VARHDRSZ); i++)
|
||||
@ -2163,7 +2221,10 @@ timetz_zone(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "Time zone '%s' not recognized", lowzone);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("time zone \"%s\" not recognized", lowzone)));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
@ -2182,9 +2243,11 @@ timetz_izone(PG_FUNCTION_ARGS)
|
||||
int tz;
|
||||
|
||||
if (zone->month != 0)
|
||||
elog(ERROR, "INTERVAL time zone '%s' not legal (month specified)",
|
||||
DatumGetCString(DirectFunctionCall1(interval_out,
|
||||
PointerGetDatum(zone))));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL time zone \"%s\" not legal",
|
||||
DatumGetCString(DirectFunctionCall1(interval_out,
|
||||
PointerGetDatum(zone))))));
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
tz = -(zone->time / INT64CONST(1000000));
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.106 2003/06/25 21:14:14 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.107 2003/07/27 04:53:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1251,7 +1251,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
switch (val)
|
||||
{
|
||||
case DTK_CURRENT:
|
||||
elog(ERROR, "'CURRENT' is no longer supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("\"current\" is no longer supported")));
|
||||
|
||||
return -1;
|
||||
break;
|
||||
|
||||
@ -1428,7 +1431,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
if (tm->tm_year > 0)
|
||||
tm->tm_year = -(tm->tm_year - 1);
|
||||
else
|
||||
elog(ERROR, "Inconsistent use of year %04d and 'BC'", tm->tm_year);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("inconsistent use of year %04d and \"BC\"",
|
||||
tm->tm_year)));
|
||||
}
|
||||
else if (is2digits)
|
||||
{
|
||||
@ -1965,7 +1971,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
|
||||
switch (val)
|
||||
{
|
||||
case DTK_CURRENT:
|
||||
elog(ERROR, "'CURRENT' is no longer supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("\"current\" is no longer supported")));
|
||||
return -1;
|
||||
break;
|
||||
|
||||
@ -2238,7 +2246,10 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm)
|
||||
if (tm->tm_year > 0)
|
||||
tm->tm_year = -(tm->tm_year - 1);
|
||||
else
|
||||
elog(ERROR, "Inconsistent use of year %04d and 'BC'", tm->tm_year);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("inconsistent use of year %04d and \"BC\"",
|
||||
tm->tm_year)));
|
||||
}
|
||||
else if (is2digits)
|
||||
{
|
||||
@ -2554,7 +2565,7 @@ DecodeNumberField(int len, char *str, int fmask,
|
||||
*
|
||||
* Return 0 if okay (and set *tzp), nonzero if not okay.
|
||||
*
|
||||
* NB: this must *not* elog on failure; see commands/variable.c.
|
||||
* NB: this must *not* ereport on failure; see commands/variable.c.
|
||||
*
|
||||
* Note: we allow timezone offsets up to 13:59. There are places that
|
||||
* use +1300 summer time.
|
||||
@ -2611,7 +2622,7 @@ DecodeTimezone(char *str, int *tzp)
|
||||
*
|
||||
* Return 0 if okay (and set *tzp), nonzero if not okay.
|
||||
*
|
||||
* NB: this must *not* elog on failure; see commands/variable.c.
|
||||
* NB: this must *not* ereport on failure; see commands/variable.c.
|
||||
*/
|
||||
int
|
||||
DecodePosixTimezone(char *str, int *tzp)
|
||||
@ -2663,7 +2674,7 @@ DecodePosixTimezone(char *str, int *tzp)
|
||||
* Implement a cache lookup since it is likely that dates
|
||||
* will be related in format.
|
||||
*
|
||||
* NB: this must *not* elog on failure;
|
||||
* NB: this must *not* ereport on failure;
|
||||
* see commands/variable.c.
|
||||
*/
|
||||
int
|
||||
@ -3715,7 +3726,7 @@ CheckDateTokenTable(const char *tablename, datetkn *base, unsigned int nel)
|
||||
{
|
||||
if (strncmp(base[i-1].token, base[i].token, TOKMAXLEN) >= 0)
|
||||
{
|
||||
elog(LOG, "Ordering error in %s table: \"%.*s\" >= \"%.*s\"",
|
||||
elog(LOG, "ordering error in %s table: \"%.*s\" >= \"%.*s\"",
|
||||
tablename,
|
||||
TOKMAXLEN, base[i-1].token,
|
||||
TOKMAXLEN, base[i].token);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.25 2002/09/04 20:31:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.26 2003/07/27 04:53:05 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -75,7 +75,10 @@ datumGetSize(Datum value, bool typByVal, int typLen)
|
||||
struct varlena *s = (struct varlena *) DatumGetPointer(value);
|
||||
|
||||
if (!PointerIsValid(s))
|
||||
elog(ERROR, "datumGetSize: Invalid Datum Pointer");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_EXCEPTION),
|
||||
errmsg("invalid Datum pointer")));
|
||||
|
||||
size = (Size) VARATT_SIZE(s);
|
||||
}
|
||||
else if (typLen == -2)
|
||||
@ -84,12 +87,15 @@ datumGetSize(Datum value, bool typByVal, int typLen)
|
||||
char *s = (char *) DatumGetPointer(value);
|
||||
|
||||
if (!PointerIsValid(s))
|
||||
elog(ERROR, "datumGetSize: Invalid Datum Pointer");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_EXCEPTION),
|
||||
errmsg("invalid Datum pointer")));
|
||||
|
||||
size = (Size) (strlen(s) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "datumGetSize: Invalid typLen %d", typLen);
|
||||
elog(ERROR, "invalid typLen: %d", typLen);
|
||||
size = 0; /* keep compiler quiet */
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.6 2001/11/05 17:46:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.7 2003/07/27 04:53:05 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -50,7 +50,9 @@ binary_encode(PG_FUNCTION_ARGS)
|
||||
|
||||
enc = pg_find_encoding(namebuf);
|
||||
if (enc == NULL)
|
||||
elog(ERROR, "No such encoding as '%s'", namebuf);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized encoding: \"%s\"", namebuf)));
|
||||
|
||||
resultlen = enc->encode_len(VARDATA(data), datalen);
|
||||
result = palloc(VARHDRSZ + resultlen);
|
||||
@ -59,7 +61,7 @@ binary_encode(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Make this FATAL 'cause we've trodden on memory ... */
|
||||
if (res > resultlen)
|
||||
elog(FATAL, "Overflow - encode estimate too small");
|
||||
elog(FATAL, "overflow - encode estimate too small");
|
||||
|
||||
VARATT_SIZEP(result) = VARHDRSZ + res;
|
||||
|
||||
@ -84,7 +86,9 @@ binary_decode(PG_FUNCTION_ARGS)
|
||||
|
||||
enc = pg_find_encoding(namebuf);
|
||||
if (enc == NULL)
|
||||
elog(ERROR, "No such encoding as '%s'", namebuf);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized encoding: \"%s\"", namebuf)));
|
||||
|
||||
resultlen = enc->decode_len(VARDATA(data), datalen);
|
||||
result = palloc(VARHDRSZ + resultlen);
|
||||
@ -93,7 +97,7 @@ binary_decode(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Make this FATAL 'cause we've trodden on memory ... */
|
||||
if (res > resultlen)
|
||||
elog(FATAL, "Overflow - decode estimate too small");
|
||||
elog(FATAL, "overflow - decode estimate too small");
|
||||
|
||||
VARATT_SIZEP(result) = VARHDRSZ + res;
|
||||
|
||||
@ -141,7 +145,9 @@ get_hex(unsigned c)
|
||||
res = hexlookup[c];
|
||||
|
||||
if (res < 0)
|
||||
elog(ERROR, "Bad hex code: '%c'", c);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid hex digit: \"%c\"", c)));
|
||||
|
||||
return (uint8) res;
|
||||
}
|
||||
@ -167,7 +173,10 @@ hex_decode(const uint8 *src, unsigned len, uint8 *dst)
|
||||
}
|
||||
v1 = get_hex(*s++) << 4;
|
||||
if (s >= srcend)
|
||||
elog(ERROR, "hex_decode: invalid data");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid hex data: odd number of digits")));
|
||||
|
||||
v2 = get_hex(*s++);
|
||||
*p++ = v1 | v2;
|
||||
}
|
||||
@ -281,7 +290,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
|
||||
else if (pos == 3)
|
||||
end = 2;
|
||||
else
|
||||
elog(ERROR, "base64: unexpected '='");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unexpected \"=\"")));
|
||||
}
|
||||
b = 0;
|
||||
}
|
||||
@ -291,7 +302,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
|
||||
if (c > 0 && c < 127)
|
||||
b = b64lookup[c];
|
||||
if (b < 0)
|
||||
elog(ERROR, "base64: Invalid symbol");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid symbol")));
|
||||
}
|
||||
/* add it to buffer */
|
||||
buf = (buf << 6) + b;
|
||||
@ -309,7 +322,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
|
||||
}
|
||||
|
||||
if (pos != 0)
|
||||
elog(ERROR, "base64: invalid end sequence");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid end sequence")));
|
||||
|
||||
return p - dst;
|
||||
}
|
||||
@ -416,7 +431,9 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
|
||||
* One backslash, not followed by ### valid octal. Should
|
||||
* never get here, since esc_dec_len does same check.
|
||||
*/
|
||||
elog(ERROR, "decode: Bad input string for type bytea");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for bytea")));
|
||||
}
|
||||
|
||||
len++;
|
||||
@ -479,7 +496,9 @@ esc_dec_len(const uint8 *src, unsigned srclen)
|
||||
/*
|
||||
* one backslash, not followed by ### valid octal
|
||||
*/
|
||||
elog(ERROR, "decode: Bad input string for type bytea");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for bytea")));
|
||||
}
|
||||
|
||||
len++;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.89 2003/05/26 00:55:25 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.90 2003/07/27 04:53:05 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -115,7 +115,7 @@ static void CheckFloat8Val(double val);
|
||||
* check to see if a float4 val is outside of
|
||||
* the FLOAT4_MIN, FLOAT4_MAX bounds.
|
||||
*
|
||||
* raise an elog warning if it is
|
||||
* raise an ereport warning if it is
|
||||
*/
|
||||
static void
|
||||
CheckFloat4Val(double val)
|
||||
@ -128,9 +128,14 @@ CheckFloat4Val(double val)
|
||||
return;
|
||||
#else
|
||||
if (fabs(val) > FLOAT4_MAX)
|
||||
elog(ERROR, "Bad float4 input format -- overflow");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("float4 value out of range: overflow")));
|
||||
if (val != 0.0 && fabs(val) < FLOAT4_MIN)
|
||||
elog(ERROR, "Bad float4 input format -- underflow");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("float4 value out of range: underflow")));
|
||||
|
||||
return;
|
||||
#endif /* UNSAFE_FLOATS */
|
||||
}
|
||||
@ -139,7 +144,7 @@ CheckFloat4Val(double val)
|
||||
* check to see if a float8 val is outside of
|
||||
* the FLOAT8_MIN, FLOAT8_MAX bounds.
|
||||
*
|
||||
* raise an elog error if it is
|
||||
* raise an ereport error if it is
|
||||
*/
|
||||
static void
|
||||
CheckFloat8Val(double val)
|
||||
@ -152,9 +157,13 @@ CheckFloat8Val(double val)
|
||||
return;
|
||||
#else
|
||||
if (fabs(val) > FLOAT8_MAX)
|
||||
elog(ERROR, "Bad float8 input format -- overflow");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("float8 value out of range: overflow")));
|
||||
if (val != 0.0 && fabs(val) < FLOAT8_MIN)
|
||||
elog(ERROR, "Bad float8 input format -- underflow");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("float8 value out of range: underflow")));
|
||||
#endif /* UNSAFE_FLOATS */
|
||||
}
|
||||
|
||||
@ -184,12 +193,17 @@ float4in(PG_FUNCTION_ARGS)
|
||||
if (strcasecmp(num, "NaN") == 0)
|
||||
val = NAN;
|
||||
else
|
||||
elog(ERROR, "Bad float4 input format '%s'", num);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for float4: \"%s\"",
|
||||
num)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errno == ERANGE)
|
||||
elog(ERROR, "Input '%s' is out of range for float4", num);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("\"%s\" is out of range for float4", num)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -280,12 +294,17 @@ float8in(PG_FUNCTION_ARGS)
|
||||
else if (strcasecmp(num, "-Infinity") == 0)
|
||||
val = -HUGE_VAL;
|
||||
else
|
||||
elog(ERROR, "Bad float8 input format '%s'", num);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for float8: \"%s\"",
|
||||
num)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errno == ERANGE)
|
||||
elog(ERROR, "Input '%s' is out of range for float8", num);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("\"%s\" is out of range for float8", num)));
|
||||
}
|
||||
|
||||
CheckFloat8Val(val);
|
||||
@ -535,7 +554,9 @@ float4div(PG_FUNCTION_ARGS)
|
||||
double result;
|
||||
|
||||
if (arg2 == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
/* Do division in float8, then check for overflow */
|
||||
result = (float8) arg1 / (float8) arg2;
|
||||
@ -597,7 +618,9 @@ float8div(PG_FUNCTION_ARGS)
|
||||
float8 result;
|
||||
|
||||
if (arg2 == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = arg1 / arg2;
|
||||
|
||||
@ -847,7 +870,9 @@ dtoi4(PG_FUNCTION_ARGS)
|
||||
int32 result;
|
||||
|
||||
if ((num < INT_MIN) || (num > INT_MAX))
|
||||
elog(ERROR, "dtoi4: integer out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
result = (int32) rint(num);
|
||||
PG_RETURN_INT32(result);
|
||||
@ -864,7 +889,9 @@ dtoi2(PG_FUNCTION_ARGS)
|
||||
int16 result;
|
||||
|
||||
if ((num < SHRT_MIN) || (num > SHRT_MAX))
|
||||
elog(ERROR, "dtoi2: integer out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
result = (int16) rint(num);
|
||||
PG_RETURN_INT16(result);
|
||||
@ -909,7 +936,9 @@ ftoi4(PG_FUNCTION_ARGS)
|
||||
int32 result;
|
||||
|
||||
if ((num < INT_MIN) || (num > INT_MAX))
|
||||
elog(ERROR, "ftoi4: integer out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
result = (int32) rint(num);
|
||||
PG_RETURN_INT32(result);
|
||||
@ -926,7 +955,9 @@ ftoi2(PG_FUNCTION_ARGS)
|
||||
int16 result;
|
||||
|
||||
if ((num < SHRT_MIN) || (num > SHRT_MAX))
|
||||
elog(ERROR, "ftoi2: integer out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
result = (int16) rint(num);
|
||||
PG_RETURN_INT16(result);
|
||||
@ -1160,7 +1191,9 @@ dsqrt(PG_FUNCTION_ARGS)
|
||||
float8 result;
|
||||
|
||||
if (arg1 < 0)
|
||||
elog(ERROR, "can't take sqrt of a negative number");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take square root of a negative number")));
|
||||
|
||||
result = sqrt(arg1);
|
||||
|
||||
@ -1204,7 +1237,9 @@ dpow(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "pow() result is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("result is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1232,7 +1267,9 @@ dexp(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "exp() result is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("result is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1250,9 +1287,14 @@ dlog1(PG_FUNCTION_ARGS)
|
||||
float8 result;
|
||||
|
||||
if (arg1 == 0.0)
|
||||
elog(ERROR, "can't take log of zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take log of zero")));
|
||||
|
||||
if (arg1 < 0)
|
||||
elog(ERROR, "can't take log of a negative number");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take log of a negative number")));
|
||||
|
||||
result = log(arg1);
|
||||
|
||||
@ -1271,9 +1313,14 @@ dlog10(PG_FUNCTION_ARGS)
|
||||
float8 result;
|
||||
|
||||
if (arg1 == 0.0)
|
||||
elog(ERROR, "can't take log of zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take log of zero")));
|
||||
|
||||
if (arg1 < 0)
|
||||
elog(ERROR, "can't take log of a negative number");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take log of a negative number")));
|
||||
|
||||
result = log10(arg1);
|
||||
|
||||
@ -1298,7 +1345,9 @@ dacos(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "acos(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1321,7 +1370,9 @@ dasin(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "asin(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1344,7 +1395,9 @@ datan(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "atan(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1368,7 +1421,9 @@ datan2(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "atan2(%f,%f) input is out of range", arg1, arg2);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1391,7 +1446,9 @@ dcos(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "cos(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1414,7 +1471,9 @@ dcot(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "cot(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
result = 1.0 / result;
|
||||
CheckFloat8Val(result);
|
||||
@ -1438,7 +1497,9 @@ dsin(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "sin(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1461,7 +1522,9 @@ dtan(PG_FUNCTION_ARGS)
|
||||
|| !finite(result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "tan(%f) input is out of range", arg1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("input is out of range")));
|
||||
|
||||
CheckFloat8Val(result);
|
||||
PG_RETURN_FLOAT8(result);
|
||||
@ -1777,7 +1840,9 @@ float48div(PG_FUNCTION_ARGS)
|
||||
float8 result;
|
||||
|
||||
if (arg2 == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = arg1 / arg2;
|
||||
CheckFloat8Val(result);
|
||||
@ -1837,7 +1902,9 @@ float84div(PG_FUNCTION_ARGS)
|
||||
float8 result;
|
||||
|
||||
if (arg2 == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = arg1 / arg2;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.34 2002/09/04 20:31:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.35 2003/07/27 04:53:05 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -133,8 +133,7 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
if (allow_invalid)
|
||||
return pstrdup("???");
|
||||
else
|
||||
elog(ERROR, "could not locate data type with oid %u in catalog",
|
||||
type_oid);
|
||||
elog(ERROR, "cache lookup failed for type %u", type_oid);
|
||||
}
|
||||
typeform = (Form_pg_type) GETSTRUCT(tuple);
|
||||
|
||||
@ -159,8 +158,7 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
if (allow_invalid)
|
||||
return pstrdup("???[]");
|
||||
else
|
||||
elog(ERROR, "could not locate data type with oid %u in catalog",
|
||||
type_oid);
|
||||
elog(ERROR, "cache lookup failed for type %u", type_oid);
|
||||
}
|
||||
typeform = (Form_pg_type) GETSTRUCT(tuple);
|
||||
type_oid = array_base_type;
|
||||
@ -312,7 +310,7 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
fieldstr = "";
|
||||
break;
|
||||
default:
|
||||
elog(LOG, "Invalid INTERVAL typmod 0x%x", typemod);
|
||||
elog(ERROR, "invalid INTERVAL typmod: 0x%x", typemod);
|
||||
fieldstr = "";
|
||||
break;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* formatting.c
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.63 2003/04/02 02:33:52 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.64 2003/07/27 04:53:05 tgl Exp $
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1999-2002, PostgreSQL Global Development Group
|
||||
@ -961,7 +961,9 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_BRACKET(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): '9' must be ahead of 'PR'.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("\"9\" must be ahead of \"PR\"")));
|
||||
}
|
||||
if (IS_MULTI(num))
|
||||
{
|
||||
@ -978,7 +980,9 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_BRACKET(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): '0' must be ahead of 'PR'.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("\"0\" must be ahead of \"PR\"")));
|
||||
}
|
||||
if (!IS_ZERO(num) && !IS_DECIMAL(num))
|
||||
{
|
||||
@ -1005,12 +1009,16 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_DECIMAL(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): not unique decimal point.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple decimal points")));
|
||||
}
|
||||
if (IS_MULTI(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'V' and decimal poin together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"V\" and decimal point together")));
|
||||
}
|
||||
num->flag |= NUM_F_DECIMAL;
|
||||
break;
|
||||
@ -1023,12 +1031,16 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_LSIGN(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): not unique 'S'.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("not unique \"S\"")));
|
||||
}
|
||||
if (IS_PLUS(num) || IS_MINUS(num) || IS_BRACKET(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'S' and 'PL'/'MI'/'SG'/'PR' together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together")));
|
||||
}
|
||||
if (!IS_DECIMAL(num))
|
||||
{
|
||||
@ -1050,7 +1062,9 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_LSIGN(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'S' and 'MI' together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"S\" and \"MI\" together")));
|
||||
}
|
||||
num->flag |= NUM_F_MINUS;
|
||||
if (IS_DECIMAL(num))
|
||||
@ -1061,7 +1075,9 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_LSIGN(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'S' and 'PL' together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"S\" and \"PL\" together")));
|
||||
}
|
||||
num->flag |= NUM_F_PLUS;
|
||||
if (IS_DECIMAL(num))
|
||||
@ -1072,7 +1088,9 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_LSIGN(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'S' and 'SG' together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"S\" and \"SG\" together")));
|
||||
}
|
||||
num->flag |= NUM_F_MINUS;
|
||||
num->flag |= NUM_F_PLUS;
|
||||
@ -1082,7 +1100,9 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_LSIGN(num) || IS_PLUS(num) || IS_MINUS(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'PR' and 'S'/'PL'/'MI'/'SG' together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together")));
|
||||
}
|
||||
num->flag |= NUM_F_BRACKET;
|
||||
break;
|
||||
@ -1101,14 +1121,18 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
||||
if (IS_DECIMAL(num))
|
||||
{
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): can't use 'V' and decimal poin together.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("cannot use \"V\" and decimal point together")));
|
||||
}
|
||||
num->flag |= NUM_F_MULTI;
|
||||
break;
|
||||
|
||||
case NUM_E:
|
||||
NUM_cache_remove(last_NUMCacheEntry);
|
||||
elog(ERROR, "to_char/to_number(): 'E' is not supported.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("\"E\" is not supported")));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1132,7 +1156,7 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
|
||||
last = 0;
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "to_char/number(): run parser.");
|
||||
elog(DEBUG_elog_output, "to_char/number(): run parser");
|
||||
#endif
|
||||
|
||||
n = node;
|
||||
@ -1343,7 +1367,7 @@ dump_node(FormatNode *node, int max)
|
||||
return;
|
||||
}
|
||||
else
|
||||
elog(DEBUG_elog_output, "%d:\t UnKnown NODE !!!", a);
|
||||
elog(DEBUG_elog_output, "%d:\t unknown NODE!", a);
|
||||
|
||||
}
|
||||
}
|
||||
@ -1367,7 +1391,9 @@ get_th(char *num, int type)
|
||||
|
||||
last = *(num + (len - 1));
|
||||
if (!isdigit((unsigned char) last))
|
||||
elog(ERROR, "get_th: '%s' is not number.", num);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("\"%s\" is not a number", num)));
|
||||
|
||||
/*
|
||||
* All "teens" (<x>1[0-9]) get 'TH/th', while <x>[02-9][123] still get
|
||||
@ -1628,7 +1654,9 @@ strdigits_len(char *str)
|
||||
return len;
|
||||
}
|
||||
|
||||
#define AMPM_ERROR elog(ERROR, "to_timestamp(): bad AM/PM string")
|
||||
#define AMPM_ERROR ereport(ERROR, \
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
|
||||
errmsg("invalid AM/PM string")));
|
||||
|
||||
/* ----------
|
||||
* Master function of TIME for:
|
||||
@ -1972,15 +2000,19 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
|
||||
return siz - 1;
|
||||
}
|
||||
else if (flag == FROM_CHAR)
|
||||
elog(ERROR, "to_timestamp(): TZ/tz not supported.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("\"TZ\"/\"tz\" not supported")));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define CHECK_SEQ_SEARCH(_l, _s) \
|
||||
do { \
|
||||
if (_l <= 0) { \
|
||||
elog(ERROR, "to_timestamp(): bad value for %s", _s); \
|
||||
if ((_l) <= 0) { \
|
||||
ereport(ERROR, \
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
|
||||
errmsg("invalid value for %s", (_s)))); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@ -2614,7 +2646,7 @@ DCH_cache_getnew(char *str)
|
||||
DCHCacheEntry *old = DCHCache + 0;
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Cache is full (%d)", n_DCHCache);
|
||||
elog(DEBUG_elog_output, "cache is full (%d)", n_DCHCache);
|
||||
#endif
|
||||
for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
|
||||
{
|
||||
@ -2788,17 +2820,16 @@ timestamp_to_char(PG_FUNCTION_ARGS)
|
||||
text *fmt = PG_GETARG_TEXT_P(1),
|
||||
*res;
|
||||
TmToChar tmtc;
|
||||
int r = 0;
|
||||
|
||||
if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
ZERO_tmtc(&tmtc);
|
||||
|
||||
r = timestamp2tm(dt, NULL, tmtcTm(&tmtc), &tmtcFsec(&tmtc), NULL);
|
||||
|
||||
if (r != 0)
|
||||
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
|
||||
if (timestamp2tm(dt, NULL, tmtcTm(&tmtc), &tmtcFsec(&tmtc), NULL) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
if (!(res = datetime_to_char_body(&tmtc, fmt)))
|
||||
PG_RETURN_NULL();
|
||||
@ -2813,18 +2844,17 @@ timestamptz_to_char(PG_FUNCTION_ARGS)
|
||||
text *fmt = PG_GETARG_TEXT_P(1),
|
||||
*res;
|
||||
TmToChar tmtc;
|
||||
int tz,
|
||||
r = 0;
|
||||
int tz;
|
||||
|
||||
if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
ZERO_tmtc(&tmtc);
|
||||
|
||||
r = timestamp2tm(dt, &tz, tmtcTm(&tmtc), &tmtcFsec(&tmtc), &tmtcTzn(&tmtc));
|
||||
|
||||
if (r != 0)
|
||||
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
|
||||
if (timestamp2tm(dt, &tz, tmtcTm(&tmtc), &tmtcFsec(&tmtc), &tmtcTzn(&tmtc)) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
if (!(res = datetime_to_char_body(&tmtc, fmt)))
|
||||
PG_RETURN_NULL();
|
||||
@ -3000,7 +3030,9 @@ to_timestamp(PG_FUNCTION_ARGS)
|
||||
if (tmfc.pm || tmfc.am)
|
||||
{
|
||||
if (tm.tm_hour < 1 || tm.tm_hour > 12)
|
||||
elog(ERROR, "to_timestamp(): AM/PM hour must be between 1 and 12");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("AM/PM hour must be between 1 and 12")));
|
||||
|
||||
if (tmfc.pm && tm.tm_hour < 12)
|
||||
tm.tm_hour += 12;
|
||||
@ -3037,7 +3069,10 @@ to_timestamp(PG_FUNCTION_ARGS)
|
||||
if (tm.tm_year > 0)
|
||||
tm.tm_year = -(tm.tm_year - 1);
|
||||
else
|
||||
elog(ERROR, "Inconsistent use of year %04d and 'BC'", tm.tm_year);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("inconsistent use of year %04d and \"BC\"",
|
||||
tm.tm_year)));
|
||||
}
|
||||
|
||||
if (tmfc.j)
|
||||
@ -3069,7 +3104,9 @@ to_timestamp(PG_FUNCTION_ARGS)
|
||||
{31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 0}};
|
||||
|
||||
if (!tm.tm_year)
|
||||
elog(ERROR, "to_timestamp() cat't convert yday without year information");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("cannot convert yday without year information")));
|
||||
|
||||
y = ysum[isleap(tm.tm_year)];
|
||||
|
||||
@ -3104,7 +3141,9 @@ to_timestamp(PG_FUNCTION_ARGS)
|
||||
tz = DetermineLocalTimeZone(&tm);
|
||||
|
||||
if (tm2timestamp(&tm, fsec, &tz, &result) != 0)
|
||||
elog(ERROR, "to_timestamp(): can't convert 'tm' to timestamp.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
|
||||
PG_RETURN_TIMESTAMP(result);
|
||||
}
|
||||
@ -3190,7 +3229,7 @@ NUM_cache_getnew(char *str)
|
||||
old = ent;
|
||||
}
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "OLD: '%s' AGE: %d", old->str, old->age);
|
||||
elog(DEBUG_elog_output, "OLD: \"%s\" AGE: %d", old->str, old->age);
|
||||
#endif
|
||||
StrNCpy(old->str, str, NUM_CACHE_SIZE + 1);
|
||||
/* old->format fill parser */
|
||||
@ -3477,7 +3516,7 @@ get_last_relevant_decnum(char *num)
|
||||
*p = strchr(num, '.');
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "CALL: get_last_relevant_decnum()");
|
||||
elog(DEBUG_elog_output, "get_last_relevant_decnum()");
|
||||
#endif
|
||||
|
||||
if (!p)
|
||||
@ -3523,7 +3562,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Try read sign (%c).", *Np->inout_p);
|
||||
elog(DEBUG_elog_output, "Try read sign (%c)", *Np->inout_p);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -3535,7 +3574,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
||||
int x = strlen(Np->L_negative_sign);
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Try read locale sign (%c).", *Np->inout_p);
|
||||
elog(DEBUG_elog_output, "Try read locale sign (%c)", *Np->inout_p);
|
||||
#endif
|
||||
if (!strncmp(Np->inout_p, Np->L_negative_sign, x))
|
||||
{
|
||||
@ -3554,7 +3593,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
||||
}
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Try read sipmle sign (%c).", *Np->inout_p);
|
||||
elog(DEBUG_elog_output, "Try read simple sign (%c)", *Np->inout_p);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -3595,7 +3634,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
||||
Np->read_post++;
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Read digit (%c).", *Np->inout_p);
|
||||
elog(DEBUG_elog_output, "Read digit (%c)", *Np->inout_p);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -3606,7 +3645,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Try read decimal point (%c).", *Np->inout_p);
|
||||
elog(DEBUG_elog_output, "Try read decimal point (%c)", *Np->inout_p);
|
||||
#endif
|
||||
if (*Np->inout_p == '.')
|
||||
{
|
||||
@ -3621,7 +3660,8 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
||||
int x = strlen(Np->decimal);
|
||||
|
||||
#ifdef DEBUG_TO_FROM_CHAR
|
||||
elog(DEBUG_elog_output, "Try read locale point (%c).", *Np->inout_p);
|
||||
elog(DEBUG_elog_output, "Try read locale point (%c)",
|
||||
*Np->inout_p);
|
||||
#endif
|
||||
if (!strncmp(Np->inout_p, Np->decimal, x))
|
||||
{
|
||||
@ -3661,8 +3701,7 @@ NUM_numpart_to_char(NUMProc *Np, int id)
|
||||
* current position in inout!
|
||||
*/
|
||||
elog(DEBUG_elog_output,
|
||||
|
||||
"SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: '%s', INOUT: '%s'",
|
||||
"SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
|
||||
Np->sign_wrote,
|
||||
Np->num_curr,
|
||||
Np->number_p,
|
||||
@ -3863,7 +3902,9 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
|
||||
if (IS_ROMAN(Np->Num))
|
||||
{
|
||||
if (Np->type == FROM_CHAR)
|
||||
elog(ERROR, "to_number(): RN is not supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("\"RN\" not supported")));
|
||||
|
||||
Np->Num->lsign = Np->Num->pre_lsign_num = Np->Num->post =
|
||||
Np->Num->pre = Np->num_pre = Np->sign = 0;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.77 2003/05/13 18:03:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.78 2003/07/27 04:53:05 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -287,7 +287,9 @@ path_encode(bool closed, int npts, Point *pt)
|
||||
|
||||
/* Check for integer overflow */
|
||||
if ((size - 2) / npts != (P_MAXLEN + 3))
|
||||
elog(ERROR, "Too many points requested");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("too many points requested")));
|
||||
|
||||
result = palloc(size);
|
||||
|
||||
@ -308,7 +310,10 @@ path_encode(bool closed, int npts, Point *pt)
|
||||
{
|
||||
*cp++ = LDELIM;
|
||||
if (!pair_encode(pt->x, pt->y, cp))
|
||||
elog(ERROR, "Unable to format path");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("could not format path")));
|
||||
|
||||
cp += strlen(cp);
|
||||
*cp++ = RDELIM;
|
||||
*cp++ = DELIM;
|
||||
@ -380,7 +385,9 @@ box_in(PG_FUNCTION_ARGS)
|
||||
|
||||
if ((!path_decode(FALSE, 2, str, &isopen, &s, &(box->high)))
|
||||
|| (*s != '\0'))
|
||||
elog(ERROR, "Bad box external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for box: \"%s\"", str)));
|
||||
|
||||
/* reorder corners if necessary... */
|
||||
if (box->high.x < box->low.x)
|
||||
@ -891,12 +898,17 @@ line_in(PG_FUNCTION_ARGS)
|
||||
|
||||
if ((!path_decode(TRUE, 2, str, &isopen, &s, &(lseg.p[0])))
|
||||
|| (*s != '\0'))
|
||||
elog(ERROR, "Bad line external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for line: \"%s\"", str)));
|
||||
|
||||
line = (LINE *) palloc(sizeof(LINE));
|
||||
line_construct_pts(line, &lseg.p[0], &lseg.p[1]);
|
||||
#else
|
||||
elog(ERROR, "line not yet implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("line not yet implemented")));
|
||||
|
||||
line = NULL;
|
||||
#endif
|
||||
|
||||
@ -960,7 +972,9 @@ line_out(PG_FUNCTION_ARGS)
|
||||
|
||||
return path_encode(TRUE, 2, (Point *) &(ls->p[0]));
|
||||
#else
|
||||
elog(ERROR, "line not yet implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("line not yet implemented")));
|
||||
result = NULL;
|
||||
#endif
|
||||
|
||||
@ -973,7 +987,9 @@ line_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
line_recv(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "line not yet implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("line not yet implemented")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -983,7 +999,9 @@ line_recv(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
line_send(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "line not yet implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("line not yet implemented")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1306,7 +1324,9 @@ path_in(PG_FUNCTION_ARGS)
|
||||
int depth = 0;
|
||||
|
||||
if ((npts = pair_count(str, ',')) <= 0)
|
||||
elog(ERROR, "Bad path external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for path: \"%s\"", str)));
|
||||
|
||||
s = str;
|
||||
while (isspace((unsigned char) *s))
|
||||
@ -1327,7 +1347,9 @@ path_in(PG_FUNCTION_ARGS)
|
||||
|
||||
if ((!path_decode(TRUE, npts, s, &isopen, &s, &(path->p[0])))
|
||||
&& (!((depth == 0) && (*s == '\0'))) && !((depth >= 1) && (*s == RDELIM)))
|
||||
elog(ERROR, "Bad path external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for path: \"%s\"", str)));
|
||||
|
||||
path->closed = (!isopen);
|
||||
|
||||
@ -1362,7 +1384,9 @@ path_recv(PG_FUNCTION_ARGS)
|
||||
closed = pq_getmsgbyte(buf);
|
||||
npts = pq_getmsgint(buf, sizeof(int32));
|
||||
if (npts < 0 || npts >= (int32) (INT_MAX / sizeof(Point)))
|
||||
elog(ERROR, "Invalid number of points in external path");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid number of points in external path")));
|
||||
|
||||
size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts;
|
||||
path = (PATH *) palloc(size);
|
||||
@ -1701,7 +1725,9 @@ point_in(PG_FUNCTION_ARGS)
|
||||
char *s;
|
||||
|
||||
if (!pair_decode(str, &x, &y, &s) || (*s != '\0'))
|
||||
elog(ERROR, "Bad point external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for point: \"%s\"", str)));
|
||||
|
||||
point = (Point *) palloc(sizeof(Point));
|
||||
|
||||
@ -1927,7 +1953,9 @@ lseg_in(PG_FUNCTION_ARGS)
|
||||
|
||||
if ((!path_decode(TRUE, 2, str, &isopen, &s, &(lseg->p[0])))
|
||||
|| (*s != '\0'))
|
||||
elog(ERROR, "Bad lseg external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for lseg: \"%s\"", str)));
|
||||
|
||||
#ifdef NOT_USED
|
||||
lseg->m = point_sl(&lseg->p[0], &lseg->p[1]);
|
||||
@ -2517,7 +2545,9 @@ dist_lb(PG_FUNCTION_ARGS)
|
||||
#endif
|
||||
|
||||
/* need to think about this one for a while */
|
||||
elog(ERROR, "dist_lb not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("dist_lb not implemented")));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
@ -3028,7 +3058,9 @@ close_lb(PG_FUNCTION_ARGS)
|
||||
#endif
|
||||
|
||||
/* think about this one for a while */
|
||||
elog(ERROR, "close_lb not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("close_lb not implemented")));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
@ -3305,7 +3337,9 @@ make_bound_box(POLYGON *poly)
|
||||
box_fill(&(poly->boundbox), x1, x2, y1, y2);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Unable to create bounding box for empty polygon");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("cannot create bounding box for empty polygon")));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
@ -3327,7 +3361,9 @@ poly_in(PG_FUNCTION_ARGS)
|
||||
char *s;
|
||||
|
||||
if ((npts = pair_count(str, ',')) <= 0)
|
||||
elog(ERROR, "Bad polygon external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for polygon: \"%s\"", str)));
|
||||
|
||||
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts;
|
||||
poly = (POLYGON *) palloc0(size); /* zero any holes */
|
||||
@ -3337,7 +3373,9 @@ poly_in(PG_FUNCTION_ARGS)
|
||||
|
||||
if ((!path_decode(FALSE, npts, str, &isopen, &s, &(poly->p[0])))
|
||||
|| (*s != '\0'))
|
||||
elog(ERROR, "Bad polygon external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for polygon: \"%s\"", str)));
|
||||
|
||||
make_bound_box(poly);
|
||||
|
||||
@ -3375,7 +3413,9 @@ poly_recv(PG_FUNCTION_ARGS)
|
||||
|
||||
npts = pq_getmsgint(buf, sizeof(int32));
|
||||
if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point)))
|
||||
elog(ERROR, "Invalid number of points in external polygon");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid number of points in external polygon")));
|
||||
|
||||
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts;
|
||||
poly = (POLYGON *) palloc0(size); /* zero any holes */
|
||||
@ -3683,7 +3723,9 @@ poly_distance(PG_FUNCTION_ARGS)
|
||||
POLYGON *polyb = PG_GETARG_POLYGON_P(1);
|
||||
#endif
|
||||
|
||||
elog(ERROR, "poly_distance not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("poly_distance not implemented")));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
@ -3762,7 +3804,9 @@ point_div(PG_FUNCTION_ARGS)
|
||||
div = (p2->x * p2->x) + (p2->y * p2->y);
|
||||
|
||||
if (div == 0.0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result->x = ((p1->x * p2->x) + (p1->y * p2->y)) / div;
|
||||
result->y = ((p2->x * p1->y) - (p2->y * p1->x)) / div;
|
||||
@ -3881,7 +3925,9 @@ path_add(PG_FUNCTION_ARGS)
|
||||
/* Check for integer overflow */
|
||||
if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) ||
|
||||
size <= base_size)
|
||||
elog(ERROR, "Too many points requested");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("too many points requested")));
|
||||
|
||||
result = (PATH *) palloc(size);
|
||||
|
||||
@ -3989,7 +4035,9 @@ path_center(PG_FUNCTION_ARGS)
|
||||
PATH *path = PG_GETARG_PATH_P(0);
|
||||
#endif
|
||||
|
||||
elog(ERROR, "path_center not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("path_center not implemented")));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
@ -4004,7 +4052,9 @@ path_poly(PG_FUNCTION_ARGS)
|
||||
|
||||
/* This is not very consistent --- other similar cases return NULL ... */
|
||||
if (!path->closed)
|
||||
elog(ERROR, "Open path cannot be converted to polygon");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("open path cannot be converted to polygon")));
|
||||
|
||||
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * path->npts;
|
||||
poly = (POLYGON *) palloc(size);
|
||||
@ -4169,7 +4219,9 @@ circle_in(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
if (!pair_decode(s, &circle->center.x, &circle->center.y, &s))
|
||||
elog(ERROR, "Bad circle external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for circle: \"%s\"", str)));
|
||||
|
||||
if (*s == DELIM)
|
||||
s++;
|
||||
@ -4177,7 +4229,9 @@ circle_in(PG_FUNCTION_ARGS)
|
||||
s++;
|
||||
|
||||
if ((!single_decode(s, &circle->radius, &s)) || (circle->radius < 0))
|
||||
elog(ERROR, "Bad circle external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for circle: \"%s\"", str)));
|
||||
|
||||
while (depth > 0)
|
||||
{
|
||||
@ -4190,11 +4244,15 @@ circle_in(PG_FUNCTION_ARGS)
|
||||
s++;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Bad circle external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for circle: \"%s\"", str)));
|
||||
}
|
||||
|
||||
if (*s != '\0')
|
||||
elog(ERROR, "Bad circle external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for circle: \"%s\"", str)));
|
||||
|
||||
PG_RETURN_CIRCLE_P(circle);
|
||||
}
|
||||
@ -4214,13 +4272,17 @@ circle_out(PG_FUNCTION_ARGS)
|
||||
*cp++ = LDELIM_C;
|
||||
*cp++ = LDELIM;
|
||||
if (!pair_encode(circle->center.x, circle->center.y, cp))
|
||||
elog(ERROR, "Unable to format circle");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("could not format circle")));
|
||||
|
||||
cp += strlen(cp);
|
||||
*cp++ = RDELIM;
|
||||
*cp++ = DELIM;
|
||||
if (!single_encode(circle->radius, cp))
|
||||
elog(ERROR, "Unable to format circle");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("could not format circle")));
|
||||
|
||||
cp += strlen(cp);
|
||||
*cp++ = RDELIM_C;
|
||||
@ -4245,7 +4307,9 @@ circle_recv(PG_FUNCTION_ARGS)
|
||||
circle->radius = pq_getmsgfloat8(buf);
|
||||
|
||||
if (circle->radius < 0)
|
||||
elog(ERROR, "Invalid radius in external circle");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid radius in external circle")));
|
||||
|
||||
PG_RETURN_CIRCLE_P(circle);
|
||||
}
|
||||
@ -4736,15 +4800,24 @@ circle_poly(PG_FUNCTION_ARGS)
|
||||
double angle;
|
||||
double anglestep;
|
||||
|
||||
if (FPzero(circle->radius) || (npts < 2))
|
||||
elog(ERROR, "Unable to convert circle to polygon");
|
||||
if (FPzero(circle->radius))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert zero-size circle to polygon")));
|
||||
|
||||
if (npts < 2)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("must request at least 2 points")));
|
||||
|
||||
base_size = sizeof(poly->p[0]) * npts;
|
||||
size = offsetof(POLYGON, p[0]) +base_size;
|
||||
|
||||
/* Check for integer overflow */
|
||||
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
|
||||
elog(ERROR, "Too many points requested");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("too many points requested")));
|
||||
|
||||
poly = (POLYGON *) palloc0(size); /* zero any holes */
|
||||
poly->size = size;
|
||||
@ -4777,7 +4850,9 @@ poly_circle(PG_FUNCTION_ARGS)
|
||||
int i;
|
||||
|
||||
if (poly->npts < 2)
|
||||
elog(ERROR, "Unable to convert polygon to circle");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("cannot convert empty polygon to circle")));
|
||||
|
||||
circle = (CIRCLE *) palloc(sizeof(CIRCLE));
|
||||
|
||||
@ -4798,7 +4873,9 @@ poly_circle(PG_FUNCTION_ARGS)
|
||||
circle->radius /= poly->npts;
|
||||
|
||||
if (FPzero(circle->radius))
|
||||
elog(ERROR, "Unable to convert polygon to circle");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("cannot convert empty polygon to circle")));
|
||||
|
||||
PG_RETURN_CIRCLE_P(circle);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.54 2003/05/09 15:44:40 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.55 2003/07/27 04:53:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -121,7 +121,10 @@ int2vectorin(PG_FUNCTION_ARGS)
|
||||
while (*intString && isspace((unsigned char) *intString))
|
||||
intString++;
|
||||
if (*intString)
|
||||
elog(ERROR, "int2vector value has too many values");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("int2vector has too many elements")));
|
||||
|
||||
while (slot < INDEX_MAX_KEYS)
|
||||
result[slot++] = 0;
|
||||
|
||||
@ -281,10 +284,10 @@ i4toi2(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int32 arg1 = PG_GETARG_INT32(0);
|
||||
|
||||
if (arg1 < SHRT_MIN)
|
||||
elog(ERROR, "i4toi2: '%d' causes int2 underflow", arg1);
|
||||
if (arg1 > SHRT_MAX)
|
||||
elog(ERROR, "i4toi2: '%d' causes int2 overflow", arg1);
|
||||
if (arg1 < SHRT_MIN || arg1 > SHRT_MAX)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT16((int16) arg1);
|
||||
}
|
||||
@ -640,7 +643,9 @@ int4div(PG_FUNCTION_ARGS)
|
||||
int32 arg2 = PG_GETARG_INT32(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT32(arg1 / arg2);
|
||||
}
|
||||
@ -703,7 +708,9 @@ int2div(PG_FUNCTION_ARGS)
|
||||
int16 arg2 = PG_GETARG_INT16(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT16(arg1 / arg2);
|
||||
}
|
||||
@ -742,7 +749,9 @@ int24div(PG_FUNCTION_ARGS)
|
||||
int32 arg2 = PG_GETARG_INT32(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT32(arg1 / arg2);
|
||||
}
|
||||
@ -781,7 +790,9 @@ int42div(PG_FUNCTION_ARGS)
|
||||
int16 arg2 = PG_GETARG_INT16(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT32(arg1 / arg2);
|
||||
}
|
||||
@ -793,7 +804,9 @@ int4mod(PG_FUNCTION_ARGS)
|
||||
int32 arg2 = PG_GETARG_INT32(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT32(arg1 % arg2);
|
||||
}
|
||||
@ -805,7 +818,9 @@ int2mod(PG_FUNCTION_ARGS)
|
||||
int16 arg2 = PG_GETARG_INT16(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT16(arg1 % arg2);
|
||||
}
|
||||
@ -817,7 +832,9 @@ int24mod(PG_FUNCTION_ARGS)
|
||||
int32 arg2 = PG_GETARG_INT32(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT32(arg1 % arg2);
|
||||
}
|
||||
@ -829,7 +846,9 @@ int42mod(PG_FUNCTION_ARGS)
|
||||
int16 arg2 = PG_GETARG_INT16(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT32(arg1 % arg2);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.44 2003/05/09 15:44:40 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.45 2003/07/27 04:53:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -36,7 +36,7 @@
|
||||
/*
|
||||
* scanint8 --- try to parse a string into an int8.
|
||||
*
|
||||
* If errorOK is false, elog a useful error message if the string is bad.
|
||||
* If errorOK is false, ereport a useful error message if the string is bad.
|
||||
* If errorOK is true, just return "false" for bad input.
|
||||
*/
|
||||
bool
|
||||
@ -83,7 +83,9 @@ scanint8(const char *str, bool errorOK, int64 *result)
|
||||
if (errorOK)
|
||||
return false;
|
||||
else
|
||||
elog(ERROR, "Bad int8 external representation \"%s\"", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for int8: \"%s\"", str)));
|
||||
}
|
||||
|
||||
/* process digits */
|
||||
@ -96,7 +98,9 @@ scanint8(const char *str, bool errorOK, int64 *result)
|
||||
if (errorOK)
|
||||
return false;
|
||||
else
|
||||
elog(ERROR, "int8 value out of range: \"%s\"", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
}
|
||||
tmp = newtmp;
|
||||
}
|
||||
@ -107,7 +111,9 @@ scanint8(const char *str, bool errorOK, int64 *result)
|
||||
if (errorOK)
|
||||
return false;
|
||||
else
|
||||
elog(ERROR, "Bad int8 external representation \"%s\"", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for int8: \"%s\"", str)));
|
||||
}
|
||||
|
||||
*result = (sign < 0) ? -tmp : tmp;
|
||||
@ -139,7 +145,7 @@ int8out(PG_FUNCTION_ARGS)
|
||||
char buf[MAXINT8LEN + 1];
|
||||
|
||||
if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
|
||||
elog(ERROR, "Unable to format int8");
|
||||
elog(ERROR, "could not format int8");
|
||||
|
||||
result = pstrdup(buf);
|
||||
PG_RETURN_CSTRING(result);
|
||||
@ -515,7 +521,9 @@ int8div(PG_FUNCTION_ARGS)
|
||||
int64 val2 = PG_GETARG_INT64(1);
|
||||
|
||||
if (val2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT64(val1 / val2);
|
||||
}
|
||||
@ -542,7 +550,9 @@ int8mod(PG_FUNCTION_ARGS)
|
||||
int64 result;
|
||||
|
||||
if (val2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
result = val1 / val2;
|
||||
result *= val2;
|
||||
@ -638,7 +648,9 @@ int84div(PG_FUNCTION_ARGS)
|
||||
int32 val2 = PG_GETARG_INT32(1);
|
||||
|
||||
if (val2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT64(val1 / val2);
|
||||
}
|
||||
@ -677,7 +689,9 @@ int48div(PG_FUNCTION_ARGS)
|
||||
int64 val2 = PG_GETARG_INT64(1);
|
||||
|
||||
if (val2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
PG_RETURN_INT64(val1 / val2);
|
||||
}
|
||||
@ -767,7 +781,9 @@ int84(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Test for overflow by reverse-conversion. */
|
||||
if ((int64) result != val)
|
||||
elog(ERROR, "int8 conversion to int4 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT32(result);
|
||||
}
|
||||
@ -790,7 +806,9 @@ int82(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Test for overflow by reverse-conversion. */
|
||||
if ((int64) result != val)
|
||||
elog(ERROR, "int8 conversion to int2 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT16(result);
|
||||
}
|
||||
@ -826,7 +844,9 @@ dtoi8(PG_FUNCTION_ARGS)
|
||||
result = (int64) val;
|
||||
|
||||
if ((float8) result != val)
|
||||
elog(ERROR, "Floating point conversion to int8 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
@ -863,7 +883,9 @@ ftoi8(PG_FUNCTION_ARGS)
|
||||
result = (int64) dval;
|
||||
|
||||
if ((float8) result != dval)
|
||||
elog(ERROR, "Floating point conversion to int8 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
@ -878,7 +900,9 @@ i8tooid(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Test for overflow by reverse-conversion. */
|
||||
if ((int64) result != val)
|
||||
elog(ERROR, "int8 conversion to OID is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("OID out of range")));
|
||||
|
||||
PG_RETURN_OID(result);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.53 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.54 2003/07/27 04:53:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -448,7 +448,11 @@ like_escape_bytea(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
BYTEA_NextChar(e, elen);
|
||||
if (elen != 0)
|
||||
elog(ERROR, "ESCAPE string must be empty or one character");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
|
||||
errmsg("invalid escape string"),
|
||||
errhint("Escape string must be empty or one character.")));
|
||||
|
||||
e = VARDATA(esc);
|
||||
|
||||
/*
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.4 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.5 2003/07/27 04:53:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -286,7 +286,11 @@ do_like_escape(text *pat, text *esc)
|
||||
*/
|
||||
NextChar(e, elen);
|
||||
if (elen != 0)
|
||||
elog(ERROR, "ESCAPE string must be empty or one character");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
|
||||
errmsg("invalid escape string"),
|
||||
errhint("Escape string must be empty or one character.")));
|
||||
|
||||
e = VARDATA(esc);
|
||||
|
||||
/*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PostgreSQL type definitions for MAC addresses.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.28 2003/05/13 18:03:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.29 2003/07/27 04:53:06 tgl Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@ -60,12 +60,16 @@ macaddr_in(PG_FUNCTION_ARGS)
|
||||
count = sscanf(str, "%2x%2x%2x%2x%2x%2x%1s",
|
||||
&a, &b, &c, &d, &e, &f, junk);
|
||||
if (count != 6)
|
||||
elog(ERROR, "macaddr_in: error in parsing \"%s\"", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for macaddr: \"%s\"", str)));
|
||||
|
||||
if ((a < 0) || (a > 255) || (b < 0) || (b > 255) ||
|
||||
(c < 0) || (c > 255) || (d < 0) || (d > 255) ||
|
||||
(e < 0) || (e > 255) || (f < 0) || (f > 255))
|
||||
elog(ERROR, "macaddr_in: illegal address \"%s\"", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("invalid octet value in macaddr: \"%s\"", str)));
|
||||
|
||||
result = (macaddr *) palloc(sizeof(macaddr));
|
||||
|
||||
@ -181,7 +185,9 @@ text_macaddr(PG_FUNCTION_ARGS)
|
||||
|
||||
len = (VARSIZE(addr) - VARHDRSZ);
|
||||
if (len >= sizeof(str))
|
||||
elog(ERROR, "Text is too long to convert to MAC address");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("text too long to convert to MAC address")));
|
||||
|
||||
memcpy(str, VARDATA(addr), len);
|
||||
*(str + len) = '\0';
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.109 2003/07/17 00:55:37 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.110 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -239,8 +239,10 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
|
||||
*/
|
||||
StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1);
|
||||
if (strlen(tm->tm_zone) > MAXTZLEN)
|
||||
elog(WARNING, "Invalid timezone \'%s\'",
|
||||
tm->tm_zone);
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid timezone name: \"%s\"",
|
||||
tm->tm_zone)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -273,8 +275,10 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
|
||||
*/
|
||||
StrNCpy(*tzn, tzname[tm->tm_isdst], MAXTZLEN + 1);
|
||||
if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
|
||||
elog(WARNING, "Invalid timezone \'%s\'",
|
||||
tzname[tm->tm_isdst]);
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid timezone name: \"%s\"",
|
||||
tzname[tm->tm_isdst])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -367,11 +371,15 @@ abstimein(PG_FUNCTION_ARGS)
|
||||
ftype[MAXDATEFIELDS];
|
||||
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad abstime external representation (too long) '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for abstime: \"%s\"", str)));
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||
elog(ERROR, "Bad abstime external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for abstime: \"%s\"", str)));
|
||||
|
||||
switch (dtype)
|
||||
{
|
||||
@ -401,7 +409,8 @@ abstimein(PG_FUNCTION_ARGS)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "Bad abstime (internal coding error) '%s'", str);
|
||||
elog(ERROR, "unexpected dtype %d while parsing abstime \"%s\"",
|
||||
dtype, str);
|
||||
result = INVALID_ABSTIME;
|
||||
break;
|
||||
};
|
||||
@ -513,7 +522,7 @@ abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b)
|
||||
return -1; /* non-INVALID < INVALID */
|
||||
|
||||
#if 0
|
||||
/* CURRENT is no longer stored internally... */
|
||||
/* CURRENT is no longer stored internally... */
|
||||
/* XXX this is broken, should go away: */
|
||||
if (a == CURRENT_ABSTIME)
|
||||
a = GetCurrentTransactionStartTime();
|
||||
@ -617,7 +626,9 @@ timestamp_abstime(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "Unable to convert timestamp to abstime");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
result = INVALID_ABSTIME;
|
||||
}
|
||||
|
||||
@ -641,7 +652,9 @@ abstime_timestamp(PG_FUNCTION_ARGS)
|
||||
switch (abstime)
|
||||
{
|
||||
case INVALID_ABSTIME:
|
||||
elog(ERROR, "Unable to convert abstime 'invalid' to timestamp");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert \"invalid\" abstime to timestamp")));
|
||||
TIMESTAMP_NOBEGIN(result);
|
||||
break;
|
||||
|
||||
@ -656,8 +669,9 @@ abstime_timestamp(PG_FUNCTION_ARGS)
|
||||
default:
|
||||
abstime2tm(abstime, &tz, tm, &tzn);
|
||||
if (tm2timestamp(tm, 0, NULL, &result) != 0)
|
||||
elog(ERROR, "Unable to convert ABSTIME to TIMESTAMP"
|
||||
"\n\tabstime_timestamp() internal error");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
break;
|
||||
};
|
||||
|
||||
@ -685,7 +699,9 @@ timestamptz_abstime(PG_FUNCTION_ARGS)
|
||||
result = tm2abstime(tm, 0);
|
||||
else
|
||||
{
|
||||
elog(ERROR, "Unable to convert timestamp to abstime");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
result = INVALID_ABSTIME;
|
||||
}
|
||||
|
||||
@ -709,7 +725,9 @@ abstime_timestamptz(PG_FUNCTION_ARGS)
|
||||
switch (abstime)
|
||||
{
|
||||
case INVALID_ABSTIME:
|
||||
elog(ERROR, "Unable to convert abstime 'invalid' to timestamptz");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert \"invalid\" abstime to timestamptz")));
|
||||
TIMESTAMP_NOBEGIN(result);
|
||||
break;
|
||||
|
||||
@ -724,8 +742,9 @@ abstime_timestamptz(PG_FUNCTION_ARGS)
|
||||
default:
|
||||
abstime2tm(abstime, &tz, tm, &tzn);
|
||||
if (tm2timestamp(tm, 0, &tz, &result) != 0)
|
||||
elog(ERROR, "Unable to convert ABSTIME to TIMESTAMP WITH TIME ZONE"
|
||||
"\n\tabstime_timestamptz() internal error");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||
errmsg("timestamp out of range")));
|
||||
break;
|
||||
};
|
||||
|
||||
@ -755,11 +774,15 @@ reltimein(PG_FUNCTION_ARGS)
|
||||
char lowstr[MAXDATELEN + 1];
|
||||
|
||||
if (strlen(str) >= sizeof(lowstr))
|
||||
elog(ERROR, "Bad reltime external representation (too long) '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for reltime: \"%s\"", str)));
|
||||
|
||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
||||
elog(ERROR, "Bad reltime external representation '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for reltime: \"%s\"", str)));
|
||||
|
||||
switch (dtype)
|
||||
{
|
||||
@ -769,7 +792,8 @@ reltimein(PG_FUNCTION_ARGS)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "Bad reltime (internal coding error) '%s'", str);
|
||||
elog(ERROR, "unexpected dtype %d while parsing reltime \"%s\"",
|
||||
dtype, str);
|
||||
result = INVALID_RELTIME;
|
||||
break;
|
||||
}
|
||||
@ -851,7 +875,10 @@ tintervalin(PG_FUNCTION_ARGS)
|
||||
|
||||
interval = (TimeInterval) palloc(sizeof(TimeIntervalData));
|
||||
if (istinterval(intervalstr, &t1, &t2) == 0)
|
||||
elog(ERROR, "Unable to decode tinterval '%s'", intervalstr);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
||||
errmsg("invalid input syntax for tinterval: \"%s\"",
|
||||
intervalstr)));
|
||||
|
||||
if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME)
|
||||
interval->status = T_INTERVAL_INVAL; /* undefined */
|
||||
@ -911,7 +938,10 @@ tintervalrecv(PG_FUNCTION_ARGS)
|
||||
interval->status = pq_getmsgint(buf, sizeof(interval->status));
|
||||
if (!(interval->status == T_INTERVAL_INVAL ||
|
||||
interval->status == T_INTERVAL_VALID))
|
||||
elog(ERROR, "Invalid status in external tinterval");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid status in external tinterval")));
|
||||
|
||||
interval->data[0] = pq_getmsgint(buf, sizeof(interval->data[0]));
|
||||
interval->data[1] = pq_getmsgint(buf, sizeof(interval->data[1]));
|
||||
|
||||
@ -1000,7 +1030,9 @@ reltime_interval(PG_FUNCTION_ARGS)
|
||||
switch (reltime)
|
||||
{
|
||||
case INVALID_RELTIME:
|
||||
elog(ERROR, "Unable to convert reltime 'invalid' to interval");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert \"invalid\" reltime to interval")));
|
||||
result->time = 0;
|
||||
result->month = 0;
|
||||
break;
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.46 2003/05/15 15:50:18 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.47 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,12 +48,10 @@ namein(PG_FUNCTION_ARGS)
|
||||
char *s = PG_GETARG_CSTRING(0);
|
||||
NameData *result;
|
||||
int len;
|
||||
char *ermsg;
|
||||
|
||||
/* verify encoding */
|
||||
len = strlen(s);
|
||||
if ((ermsg = pg_verifymbstr(s, len)))
|
||||
elog(ERROR, "%s", ermsg);
|
||||
pg_verifymbstr(s, len, false);
|
||||
|
||||
len = pg_mbcliplen(s, len, NAMEDATALEN - 1);
|
||||
|
||||
@ -87,7 +85,11 @@ namerecv(PG_FUNCTION_ARGS)
|
||||
|
||||
str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
|
||||
if (nbytes >= NAMEDATALEN)
|
||||
elog(ERROR, "namerecv: input name too long");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NAME_TOO_LONG),
|
||||
errmsg("identifier too long"),
|
||||
errdetail("Identifier must be less than %d characters.",
|
||||
NAMEDATALEN)));
|
||||
result = (NameData *) palloc0(NAMEDATALEN);
|
||||
memcpy(result, str, nbytes);
|
||||
pfree(str);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PostgreSQL type definitions for the INET and CIDR types.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.42 2003/06/24 22:21:22 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.43 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
* Jon Postel RIP 16 Oct 1998
|
||||
*/
|
||||
@ -85,17 +85,23 @@ network_in(char *src, int type)
|
||||
bits = inet_net_pton(ip_family(dst), src, ip_addr(dst),
|
||||
type ? ip_addrsize(dst) : -1);
|
||||
if ((bits < 0) || (bits > ip_maxbits(dst)))
|
||||
elog(ERROR, "invalid %s value '%s'",
|
||||
type ? "CIDR" : "INET", src);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
/* translator: first %s is inet or cidr */
|
||||
errmsg("invalid input syntax for %s: \"%s\"",
|
||||
type ? "cidr" : "inet", src)));
|
||||
|
||||
/*
|
||||
/*
|
||||
* Error check: CIDR values must not have any bits set beyond
|
||||
* the masklen.
|
||||
*/
|
||||
if (type)
|
||||
*/
|
||||
if (type)
|
||||
{
|
||||
if (!addressOK(ip_addr(dst), bits, ip_family(dst)))
|
||||
elog(ERROR, "invalid CIDR value '%s': has bits set to right of mask", src);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid cidr value: \"%s\"", src),
|
||||
errdetail("Value has bits set to right of mask.")));
|
||||
}
|
||||
|
||||
VARATT_SIZEP(dst) = VARHDRSZ
|
||||
@ -139,7 +145,10 @@ inet_out(PG_FUNCTION_ARGS)
|
||||
dst = inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src),
|
||||
tmp, sizeof(tmp));
|
||||
if (dst == NULL)
|
||||
elog(ERROR, "unable to print address (%s)", strerror(errno));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("could not format inet value: %m")));
|
||||
|
||||
/* For CIDR, add /n if not present */
|
||||
if (ip_type(src) && strchr(tmp, '/') == NULL)
|
||||
{
|
||||
@ -180,18 +189,25 @@ inet_recv(PG_FUNCTION_ARGS)
|
||||
|
||||
ip_family(addr) = pq_getmsgbyte(buf);
|
||||
if (ip_family(addr) != AF_INET)
|
||||
elog(ERROR, "Invalid family in external inet");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid family in external inet")));
|
||||
bits = pq_getmsgbyte(buf);
|
||||
if (bits < 0 || bits > ip_maxbits(addr))
|
||||
elog(ERROR, "Invalid bits in external inet");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid bits in external inet")));
|
||||
ip_bits(addr) = bits;
|
||||
ip_type(addr) = pq_getmsgbyte(buf);
|
||||
if (ip_type(addr) != 0 && ip_type(addr) != 1)
|
||||
elog(ERROR, "Invalid type in external inet");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid type in external inet")));
|
||||
nb = pq_getmsgbyte(buf);
|
||||
if (nb != ip_addrsize(addr))
|
||||
elog(ERROR, "Invalid length in external inet");
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid length in external inet")));
|
||||
VARATT_SIZEP(addr) = VARHDRSZ
|
||||
+ ((char *)ip_addr(addr) - (char *) VARDATA(addr))
|
||||
+ ip_addrsize(addr);
|
||||
@ -207,7 +223,10 @@ inet_recv(PG_FUNCTION_ARGS)
|
||||
if (ip_type(addr))
|
||||
{
|
||||
if (!addressOK(ip_addr(addr), bits, ip_family(addr)))
|
||||
elog(ERROR, "invalid external CIDR value: has bits set to right of mask");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid external CIDR value"),
|
||||
errdetail("Value has bits set to right of mask.")));
|
||||
}
|
||||
|
||||
PG_RETURN_INET_P(addr);
|
||||
@ -291,7 +310,9 @@ inet_set_masklen(PG_FUNCTION_ARGS)
|
||||
bits = ip_maxbits(src);
|
||||
|
||||
if ((bits < 0) || (bits > ip_maxbits(src)))
|
||||
elog(ERROR, "set_masklen - invalid value '%d'", bits);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid mask length: %d", bits)));
|
||||
|
||||
/* clone the original data */
|
||||
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
|
||||
@ -477,7 +498,9 @@ network_host(PG_FUNCTION_ARGS)
|
||||
/* force display of max bits, regardless of masklen... */
|
||||
if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
|
||||
tmp, sizeof(tmp)) == NULL)
|
||||
elog(ERROR, "unable to print host (%s)", strerror(errno));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("could not format inet value: %m")));
|
||||
|
||||
/* Suppress /n if present (shouldn't happen now) */
|
||||
if ((ptr = strchr(tmp, '/')) != NULL)
|
||||
@ -501,7 +524,10 @@ network_show(PG_FUNCTION_ARGS)
|
||||
|
||||
if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
|
||||
tmp, sizeof(tmp)) == NULL)
|
||||
elog(ERROR, "unable to print host (%s)", strerror(errno));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("could not format inet value: %m")));
|
||||
|
||||
/* Add /n if not present (which it won't be) */
|
||||
if (strchr(tmp, '/') == NULL)
|
||||
{
|
||||
@ -534,8 +560,9 @@ network_abbrev(PG_FUNCTION_ARGS)
|
||||
ip_bits(ip), tmp, sizeof(tmp));
|
||||
|
||||
if (dst == NULL)
|
||||
elog(ERROR, "unable to print address (%s)",
|
||||
strerror(errno));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("could not format inet value: %m")));
|
||||
|
||||
/* Return string as a text datum */
|
||||
len = strlen(tmp);
|
||||
@ -818,7 +845,7 @@ convert_network_to_scalar(Datum value, Oid typid)
|
||||
* Can't get here unless someone tries to use scalarltsel/scalargtsel
|
||||
* on an operator with one network and one non-network operand.
|
||||
*/
|
||||
elog(ERROR, "convert_network_to_scalar: unsupported type %u", typid);
|
||||
elog(ERROR, "unsupported type: %u", typid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.32 2002/09/04 20:31:28 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.33 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -59,7 +59,10 @@ int4notin(PG_FUNCTION_ARGS)
|
||||
names = textToQualifiedNameList(relation_and_attr, "int4notin");
|
||||
nnames = length(names);
|
||||
if (nnames < 2)
|
||||
elog(ERROR, "int4notin: must provide relationname.attributename");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_NAME),
|
||||
errmsg("invalid name syntax"),
|
||||
errhint("Must provide \"relationname.attributename\".")));
|
||||
attribute = strVal(nth(nnames - 1, names));
|
||||
names = ltruncate(nnames - 1, names);
|
||||
relrv = makeRangeVarFromNameList(names);
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Copyright (c) 1998-2003, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.62 2003/07/03 19:41:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.63 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -390,7 +390,9 @@ numeric_recv(PG_FUNCTION_ARGS)
|
||||
|
||||
len = (uint16) pq_getmsgint(buf, sizeof(uint16));
|
||||
if (len < 0 || len > NUMERIC_MAX_PRECISION + NUMERIC_MAX_RESULT_SCALE)
|
||||
elog(ERROR, "Invalid length in external numeric");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid length in external numeric")));
|
||||
|
||||
alloc_var(&value, len);
|
||||
|
||||
@ -399,14 +401,19 @@ numeric_recv(PG_FUNCTION_ARGS)
|
||||
if (!(value.sign == NUMERIC_POS ||
|
||||
value.sign == NUMERIC_NEG ||
|
||||
value.sign == NUMERIC_NAN))
|
||||
elog(ERROR, "Invalid sign in external numeric");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid sign in external numeric")));
|
||||
|
||||
value.dscale = (uint16) pq_getmsgint(buf, sizeof(uint16));
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
NumericDigit d = pq_getmsgint(buf, sizeof(NumericDigit));
|
||||
|
||||
if (d < 0 || d >= NBASE)
|
||||
elog(ERROR, "Invalid digit in external numeric");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid digit in external numeric")));
|
||||
value.digits[i] = d;
|
||||
}
|
||||
|
||||
@ -1610,14 +1617,18 @@ numeric_int4(PG_FUNCTION_ARGS)
|
||||
|
||||
/* XXX would it be better to return NULL? */
|
||||
if (NUMERIC_IS_NAN(num))
|
||||
elog(ERROR, "Cannot convert NaN to int4");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert NaN to integer")));
|
||||
|
||||
/* Convert to variable format and thence to int8 */
|
||||
init_var(&x);
|
||||
set_var_from_num(num, &x);
|
||||
|
||||
if (!numericvar_to_int8(&x, &val))
|
||||
elog(ERROR, "numeric conversion to int4 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
free_var(&x);
|
||||
|
||||
@ -1626,7 +1637,9 @@ numeric_int4(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Test for overflow by reverse-conversion. */
|
||||
if ((int64) result != val)
|
||||
elog(ERROR, "numeric conversion to int4 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT32(result);
|
||||
}
|
||||
@ -1660,14 +1673,18 @@ numeric_int8(PG_FUNCTION_ARGS)
|
||||
|
||||
/* XXX would it be better to return NULL? */
|
||||
if (NUMERIC_IS_NAN(num))
|
||||
elog(ERROR, "Cannot convert NaN to int8");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert NaN to integer")));
|
||||
|
||||
/* Convert to variable format and thence to int8 */
|
||||
init_var(&x);
|
||||
set_var_from_num(num, &x);
|
||||
|
||||
if (!numericvar_to_int8(&x, &result))
|
||||
elog(ERROR, "numeric conversion to int8 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
free_var(&x);
|
||||
|
||||
@ -1704,14 +1721,18 @@ numeric_int2(PG_FUNCTION_ARGS)
|
||||
|
||||
/* XXX would it be better to return NULL? */
|
||||
if (NUMERIC_IS_NAN(num))
|
||||
elog(ERROR, "Cannot convert NaN to int2");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot convert NaN to integer")));
|
||||
|
||||
/* Convert to variable format and thence to int8 */
|
||||
init_var(&x);
|
||||
set_var_from_num(num, &x);
|
||||
|
||||
if (!numericvar_to_int8(&x, &val))
|
||||
elog(ERROR, "numeric conversion to int2 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
free_var(&x);
|
||||
|
||||
@ -1720,7 +1741,9 @@ numeric_int2(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Test for overflow by reverse-conversion. */
|
||||
if ((int64) result != val)
|
||||
elog(ERROR, "numeric conversion to int2 is out of range");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
PG_RETURN_INT16(result);
|
||||
}
|
||||
@ -1903,7 +1926,7 @@ do_numeric_accum(ArrayType *transarray, Numeric newval)
|
||||
NUMERICOID, -1, false, 'i',
|
||||
&transdatums, &ndatums);
|
||||
if (ndatums != 3)
|
||||
elog(ERROR, "do_numeric_accum: expected 3-element numeric array");
|
||||
elog(ERROR, "expected 3-element numeric array");
|
||||
N = transdatums[0];
|
||||
sumX = transdatums[1];
|
||||
sumX2 = transdatums[2];
|
||||
@ -1994,7 +2017,7 @@ numeric_avg(PG_FUNCTION_ARGS)
|
||||
NUMERICOID, -1, false, 'i',
|
||||
&transdatums, &ndatums);
|
||||
if (ndatums != 3)
|
||||
elog(ERROR, "numeric_avg: expected 3-element numeric array");
|
||||
elog(ERROR, "expected 3-element numeric array");
|
||||
N = DatumGetNumeric(transdatums[0]);
|
||||
sumX = DatumGetNumeric(transdatums[1]);
|
||||
/* ignore sumX2 */
|
||||
@ -2030,7 +2053,7 @@ numeric_variance(PG_FUNCTION_ARGS)
|
||||
NUMERICOID, -1, false, 'i',
|
||||
&transdatums, &ndatums);
|
||||
if (ndatums != 3)
|
||||
elog(ERROR, "numeric_variance: expected 3-element numeric array");
|
||||
elog(ERROR, "expected 3-element numeric array");
|
||||
N = DatumGetNumeric(transdatums[0]);
|
||||
sumX = DatumGetNumeric(transdatums[1]);
|
||||
sumX2 = DatumGetNumeric(transdatums[2]);
|
||||
@ -2106,7 +2129,7 @@ numeric_stddev(PG_FUNCTION_ARGS)
|
||||
NUMERICOID, -1, false, 'i',
|
||||
&transdatums, &ndatums);
|
||||
if (ndatums != 3)
|
||||
elog(ERROR, "numeric_stddev: expected 3-element numeric array");
|
||||
elog(ERROR, "expected 3-element numeric array");
|
||||
N = DatumGetNumeric(transdatums[0]);
|
||||
sumX = DatumGetNumeric(transdatums[1]);
|
||||
sumX2 = DatumGetNumeric(transdatums[2]);
|
||||
@ -2296,7 +2319,7 @@ int2_avg_accum(PG_FUNCTION_ARGS)
|
||||
* We copied the input array, so it's okay to scribble on it directly.
|
||||
*/
|
||||
if (ARR_SIZE(transarray) != ARR_OVERHEAD(1) + sizeof(Int8TransTypeData))
|
||||
elog(ERROR, "int2_avg_accum: expected 2-element int8 array");
|
||||
elog(ERROR, "expected 2-element int8 array");
|
||||
transdata = (Int8TransTypeData *) ARR_DATA_PTR(transarray);
|
||||
|
||||
transdata->count++;
|
||||
@ -2316,7 +2339,7 @@ int4_avg_accum(PG_FUNCTION_ARGS)
|
||||
* We copied the input array, so it's okay to scribble on it directly.
|
||||
*/
|
||||
if (ARR_SIZE(transarray) != ARR_OVERHEAD(1) + sizeof(Int8TransTypeData))
|
||||
elog(ERROR, "int4_avg_accum: expected 2-element int8 array");
|
||||
elog(ERROR, "expected 2-element int8 array");
|
||||
transdata = (Int8TransTypeData *) ARR_DATA_PTR(transarray);
|
||||
|
||||
transdata->count++;
|
||||
@ -2334,7 +2357,7 @@ int8_avg(PG_FUNCTION_ARGS)
|
||||
sumd;
|
||||
|
||||
if (ARR_SIZE(transarray) != ARR_OVERHEAD(1) + sizeof(Int8TransTypeData))
|
||||
elog(ERROR, "int8_avg: expected 2-element int8 array");
|
||||
elog(ERROR, "expected 2-element int8 array");
|
||||
transdata = (Int8TransTypeData *) ARR_DATA_PTR(transarray);
|
||||
|
||||
/* SQL92 defines AVG of no values to be NULL */
|
||||
@ -2542,7 +2565,9 @@ set_var_from_str(const char *str, NumericVar *dest)
|
||||
}
|
||||
|
||||
if (!isdigit((unsigned char) *cp))
|
||||
elog(ERROR, "Bad numeric input format '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for numeric: \"%s\"", str)));
|
||||
|
||||
decdigits = (unsigned char *) palloc(strlen(cp) + DEC_DIGITS*2);
|
||||
|
||||
@ -2563,7 +2588,10 @@ set_var_from_str(const char *str, NumericVar *dest)
|
||||
else if (*cp == '.')
|
||||
{
|
||||
if (have_dp)
|
||||
elog(ERROR, "Bad numeric input format '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for numeric: \"%s\"",
|
||||
str)));
|
||||
have_dp = TRUE;
|
||||
cp++;
|
||||
}
|
||||
@ -2584,11 +2612,17 @@ set_var_from_str(const char *str, NumericVar *dest)
|
||||
cp++;
|
||||
exponent = strtol(cp, &endptr, 10);
|
||||
if (endptr == cp)
|
||||
elog(ERROR, "Bad numeric input format '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for numeric: \"%s\"",
|
||||
str)));
|
||||
cp = endptr;
|
||||
if (exponent > NUMERIC_MAX_PRECISION ||
|
||||
exponent < -NUMERIC_MAX_PRECISION)
|
||||
elog(ERROR, "Bad numeric input format '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for numeric: \"%s\"",
|
||||
str)));
|
||||
dweight += (int) exponent;
|
||||
dscale -= (int) exponent;
|
||||
if (dscale < 0)
|
||||
@ -2599,7 +2633,10 @@ set_var_from_str(const char *str, NumericVar *dest)
|
||||
while (*cp)
|
||||
{
|
||||
if (!isspace((unsigned char) *cp))
|
||||
elog(ERROR, "Bad numeric input format '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for numeric: \"%s\"",
|
||||
str)));
|
||||
cp++;
|
||||
}
|
||||
|
||||
@ -2893,7 +2930,9 @@ make_result(NumericVar *var)
|
||||
/* Check for overflow of int16 fields */
|
||||
if (result->n_weight != weight ||
|
||||
NUMERIC_DSCALE(result) != var->dscale)
|
||||
elog(ERROR, "Value overflows numeric format");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("value overflows numeric format")));
|
||||
|
||||
dump_numeric("make_result()", result);
|
||||
return result;
|
||||
@ -2961,9 +3000,11 @@ apply_typmod(NumericVar *var, int32 typmod)
|
||||
#error unsupported NBASE
|
||||
#endif
|
||||
if (ddigits > maxdigits)
|
||||
elog(ERROR, "overflow on numeric "
|
||||
"ABS(value) >= 10^%d for field with precision %d scale %d",
|
||||
ddigits-1, precision, scale);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("numeric field overflow"),
|
||||
errdetail("ABS(value) >= 10^%d for field with precision %d, scale %d.",
|
||||
ddigits-1, precision, scale)));
|
||||
break;
|
||||
}
|
||||
ddigits -= DEC_DIGITS;
|
||||
@ -3098,7 +3139,10 @@ numeric_to_double_no_overflow(Numeric num)
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
/* shouldn't happen ... */
|
||||
elog(ERROR, "Bad float8 input format '%s'", tmp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for float8: \"%s\"",
|
||||
tmp)));
|
||||
}
|
||||
|
||||
pfree(tmp);
|
||||
@ -3121,7 +3165,10 @@ numericvar_to_double_no_overflow(NumericVar *var)
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
/* shouldn't happen ... */
|
||||
elog(ERROR, "Bad float8 input format '%s'", tmp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for float8: \"%s\"",
|
||||
tmp)));
|
||||
}
|
||||
|
||||
pfree(tmp);
|
||||
@ -3613,7 +3660,9 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result,
|
||||
* unnormalized divisor.
|
||||
*/
|
||||
if (var2ndigits == 0 || var2digits[0] == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
/*
|
||||
* Now result zero check
|
||||
@ -4006,7 +4055,9 @@ sqrt_var(NumericVar *arg, NumericVar *result, int rscale)
|
||||
}
|
||||
|
||||
if (stat < 0)
|
||||
elog(ERROR, "math error on numeric - cannot compute SQRT of negative value");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take square root of a negative number")));
|
||||
|
||||
init_var(&tmp_arg);
|
||||
init_var(&tmp_val);
|
||||
@ -4094,7 +4145,9 @@ exp_var(NumericVar *arg, NumericVar *result, int rscale)
|
||||
x.weight--;
|
||||
/* Guard against overflow */
|
||||
if (xintval >= NUMERIC_MAX_RESULT_SCALE * 3)
|
||||
elog(ERROR, "argument for EXP() too big");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("argument for EXP() too big")));
|
||||
}
|
||||
|
||||
/* Select an appropriate scale for internal calculation */
|
||||
@ -4218,7 +4271,9 @@ ln_var(NumericVar *arg, NumericVar *result, int rscale)
|
||||
int local_rscale;
|
||||
|
||||
if (cmp_var(arg, &const_zero) <= 0)
|
||||
elog(ERROR, "math error on numeric - cannot compute LN of value <= zero");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("cannot take log of a negative number")));
|
||||
|
||||
local_rscale = rscale + 8;
|
||||
|
||||
@ -4462,7 +4517,9 @@ power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale)
|
||||
{
|
||||
case 0:
|
||||
if (base->ndigits == 0)
|
||||
elog(ERROR, "zero raised to zero is undefined");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("zero raised to zero is undefined")));
|
||||
set_var_from_var(&const_one, result);
|
||||
result->dscale = rscale; /* no need to round */
|
||||
return;
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.54 2002/09/04 20:31:28 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.55 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -51,82 +51,73 @@
|
||||
* c, if not 0, is the terminator character that may appear after the
|
||||
* integer. If 0, the string must end after the integer.
|
||||
*
|
||||
* Unlike plain atoi(), this will throw elog() upon bad input format or
|
||||
* Unlike plain atoi(), this will throw ereport() upon bad input format or
|
||||
* overflow.
|
||||
*/
|
||||
int32
|
||||
pg_atoi(char *s, int size, int c)
|
||||
{
|
||||
long l = 0;
|
||||
long l;
|
||||
char *badp = NULL;
|
||||
|
||||
errno = 0;
|
||||
|
||||
/*
|
||||
* Some versions of strtol treat the empty string as an error, but
|
||||
* some seem not to. Make an explicit test to be sure we catch it.
|
||||
*/
|
||||
|
||||
if (s == (char *) NULL)
|
||||
elog(ERROR, "pg_atoi: NULL pointer");
|
||||
else if (*s == 0)
|
||||
elog(ERROR, "pg_atoi: zero-length string");
|
||||
else
|
||||
l = strtol(s, &badp, 10);
|
||||
elog(ERROR, "NULL pointer");
|
||||
if (*s == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
s)));
|
||||
|
||||
errno = 0;
|
||||
l = strtol(s, &badp, 10);
|
||||
|
||||
/*
|
||||
* strtol() normally only sets ERANGE. On some systems it also may
|
||||
* set EINVAL, which simply means it couldn't parse the input string.
|
||||
* This is handled by the second "if" consistent across platforms.
|
||||
*/
|
||||
if (errno && errno != EINVAL)
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
if (errno && errno != ERANGE && errno != EINVAL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
s)));
|
||||
if (badp && *badp && *badp != c)
|
||||
elog(ERROR, "pg_atoi: error in \"%s\": can\'t parse \"%s\"", s, badp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
s)));
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case sizeof(int32):
|
||||
if (errno == ERANGE
|
||||
#if defined(HAVE_LONG_INT_64)
|
||||
/* won't get ERANGE on these with 64-bit longs... */
|
||||
if (l < INT_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
}
|
||||
if (l > INT_MAX)
|
||||
{
|
||||
errno = ERANGE;
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
}
|
||||
#endif /* HAVE_LONG_INT_64 */
|
||||
/* won't get ERANGE on these with 64-bit longs... */
|
||||
|| l < INT_MIN || l > INT_MAX
|
||||
#endif
|
||||
)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("%s is out of range for int4", s)));
|
||||
break;
|
||||
case sizeof(int16):
|
||||
if (l < SHRT_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
}
|
||||
if (l > SHRT_MAX)
|
||||
{
|
||||
errno = ERANGE;
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
}
|
||||
if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("%s is out of range for int2", s)));
|
||||
break;
|
||||
case sizeof(int8):
|
||||
if (l < SCHAR_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
}
|
||||
if (l > SCHAR_MAX)
|
||||
{
|
||||
errno = ERANGE;
|
||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||
}
|
||||
if (errno == ERANGE || l < SCHAR_MIN || l > SCHAR_MAX)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("%s is out of range for int1", s)));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_atoi: invalid result size: %d", size);
|
||||
elog(ERROR, "unsupported result size: %d", size);
|
||||
}
|
||||
return (int32) l;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.48 2003/05/09 15:44:40 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.49 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -34,7 +34,6 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
|
||||
Oid result;
|
||||
|
||||
errno = 0;
|
||||
|
||||
cvt = strtoul(s, &endptr, 10);
|
||||
|
||||
/*
|
||||
@ -44,12 +43,21 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
|
||||
* Note that for historical reasons we accept an empty string as
|
||||
* meaning 0.
|
||||
*/
|
||||
if (errno && errno != EINVAL)
|
||||
elog(ERROR, "%s: error reading \"%s\": %m",
|
||||
funcname, s);
|
||||
if (errno && errno != ERANGE && errno != EINVAL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for OID: \"%s\"",
|
||||
s)));
|
||||
if (endptr == s && *endptr)
|
||||
elog(ERROR, "%s: error in \"%s\": can't parse \"%s\"",
|
||||
funcname, s, endptr);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for OID: \"%s\"",
|
||||
s)));
|
||||
|
||||
if (errno == ERANGE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("%s is out of range for OID", s)));
|
||||
|
||||
if (endloc)
|
||||
{
|
||||
@ -62,8 +70,10 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
|
||||
while (*endptr && isspace((unsigned char) *endptr))
|
||||
endptr++;
|
||||
if (*endptr)
|
||||
elog(ERROR, "%s: error in \"%s\": can't parse \"%s\"",
|
||||
funcname, s, endptr);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for OID: \"%s\"",
|
||||
s)));
|
||||
}
|
||||
|
||||
result = (Oid) cvt;
|
||||
@ -83,8 +93,9 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
|
||||
#if OID_MAX != ULONG_MAX
|
||||
if (cvt != (unsigned long) result &&
|
||||
cvt != (unsigned long) ((int) result))
|
||||
elog(ERROR, "%s: error reading \"%s\": %s",
|
||||
funcname, s, strerror(ERANGE));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("%s is out of range for OID", s)));
|
||||
#endif
|
||||
|
||||
return result;
|
||||
@ -160,7 +171,9 @@ oidvectorin(PG_FUNCTION_ARGS)
|
||||
while (*oidString && isspace((unsigned char) *oidString))
|
||||
oidString++;
|
||||
if (*oidString)
|
||||
elog(ERROR, "oidvector value has too many values");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("oidvector has too many elements")));
|
||||
while (slot < INDEX_MAX_KEYS)
|
||||
result[slot++] = InvalidOid;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.45 2003/07/27 03:16:20 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.46 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -201,7 +201,9 @@ lpad(PG_FUNCTION_ARGS)
|
||||
|
||||
/* check for integer overflow */
|
||||
if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
|
||||
elog(ERROR, "Requested length too large");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("requested length too large")));
|
||||
|
||||
ret = (text *) palloc(VARHDRSZ + bytelen);
|
||||
|
||||
@ -296,7 +298,9 @@ rpad(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Check for integer overflow */
|
||||
if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
|
||||
elog(ERROR, "Requested length too large");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("requested length too large")));
|
||||
|
||||
ret = (text *) palloc(VARHDRSZ + bytelen);
|
||||
m = len - s1len;
|
||||
@ -917,7 +921,9 @@ repeat(PG_FUNCTION_ARGS)
|
||||
int check2 = check + VARHDRSZ;
|
||||
|
||||
if ((check / slen) != count || check2 <= check)
|
||||
elog(ERROR, "Requested buffer is too large.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("requested length too large")));
|
||||
}
|
||||
|
||||
result = (text *) palloc(tlen);
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.20 2002/10/18 20:44:02 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.21 2003/07/27 04:53:07 tgl Exp $
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
@ -157,7 +157,7 @@ lc_collate_is_c(void)
|
||||
return (bool) result;
|
||||
localeptr = setlocale(LC_COLLATE, NULL);
|
||||
if (!localeptr)
|
||||
elog(PANIC, "Invalid LC_COLLATE setting");
|
||||
elog(ERROR, "invalid LC_COLLATE setting");
|
||||
|
||||
if (strcmp(localeptr, "C") == 0)
|
||||
result = true;
|
||||
|
@ -186,12 +186,16 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
|
||||
|
||||
if (fcinfo->resultinfo == NULL ||
|
||||
!IsA(fcinfo->resultinfo, ReturnSetInfo))
|
||||
elog(ERROR, "pg_stat_get_backend_idset: called in context that does not accept a set result");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("set-valued function called in context that "
|
||||
"cannot accept a set")));
|
||||
|
||||
if (fmgr_info->fn_extra == NULL)
|
||||
{
|
||||
if (fmgr_info->fn_mcxt == NULL)
|
||||
elog(ERROR, "No function memory context in set-function");
|
||||
elog(ERROR, "no function memory context in set-function");
|
||||
|
||||
fmgr_info->fn_extra = MemoryContextAlloc(fmgr_info->fn_mcxt,
|
||||
2 * sizeof(int));
|
||||
((int *) (fmgr_info->fn_extra))[0] = 0;
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.7 2003/05/13 18:03:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.8 2003/07/27 04:53:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,7 +33,9 @@
|
||||
Datum
|
||||
record_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "RECORD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type record")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -44,7 +46,9 @@ record_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
record_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "RECORD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type record")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -55,7 +59,9 @@ record_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
record_recv(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a value of type %s", "RECORD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a value of type record")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -66,7 +72,9 @@ record_recv(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
record_send(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "RECORD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type record")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -134,7 +142,9 @@ cstring_send(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
any_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "ANY");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type any")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -145,7 +155,9 @@ any_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
any_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "ANY");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type any")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -157,7 +169,9 @@ any_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
anyarray_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "ANYARRAY");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type anyarray")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -183,7 +197,9 @@ anyarray_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
anyarray_recv(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a value of type %s", "ANYARRAY");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a value of type anyarray")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -231,7 +247,9 @@ void_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
trigger_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "TRIGGER");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type trigger")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -242,7 +260,9 @@ trigger_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
trigger_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "TRIGGER");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type trigger")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -254,7 +274,9 @@ trigger_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
language_handler_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "LANGUAGE_HANDLER");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type language_handler")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -265,7 +287,9 @@ language_handler_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
language_handler_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "LANGUAGE_HANDLER");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type language_handler")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -277,7 +301,9 @@ language_handler_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
internal_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "INTERNAL");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type internal")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -288,7 +314,9 @@ internal_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
internal_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "INTERNAL");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type internal")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -300,7 +328,9 @@ internal_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
opaque_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "OPAQUE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type opaque")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -311,7 +341,9 @@ opaque_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
opaque_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "OPAQUE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type opaque")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -323,7 +355,9 @@ opaque_out(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
anyelement_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot accept a constant of type %s", "ANYELEMENT");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot accept a constant of type anyelement")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
@ -334,7 +368,9 @@ anyelement_in(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
anyelement_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
elog(ERROR, "Cannot display a value of type %s", "ANYELEMENT");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot display a value of type anyelement")));
|
||||
|
||||
PG_RETURN_VOID(); /* keep compiler quiet */
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.45 2003/02/06 20:25:33 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.46 2003/07/27 04:53:08 tgl Exp $
|
||||
*
|
||||
* Alistair Crooks added the code for the regex caching
|
||||
* agc - cached the regular expressions used - there's a good chance
|
||||
@ -171,7 +171,9 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
|
||||
|
||||
pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg));
|
||||
/* XXX should we pg_regfree here? */
|
||||
elog(ERROR, "Invalid regular expression: %s", errMsg);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
|
||||
errmsg("invalid regular expression: %s", errMsg)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -182,7 +184,9 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
|
||||
if (re_temp.cre_pat == NULL)
|
||||
{
|
||||
pg_regfree(&re_temp.cre_re);
|
||||
elog(ERROR, "Out of memory");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
}
|
||||
memcpy(re_temp.cre_pat, text_re, text_re_len);
|
||||
re_temp.cre_flags = cflags;
|
||||
@ -450,7 +454,10 @@ similar_escape(PG_FUNCTION_ARGS)
|
||||
if (elen == 0)
|
||||
e = NULL; /* no escape character */
|
||||
else if (elen != 1)
|
||||
elog(ERROR, "ESCAPE string must be empty or one character");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
|
||||
errmsg("invalid escape string"),
|
||||
errhint("Escape string must be empty or one character.")));
|
||||
}
|
||||
|
||||
/* We need room for ^, $, and up to 2 output bytes per input byte */
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.77 2003/05/12 23:08:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.78 2003/07/27 04:53:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -112,10 +112,16 @@ regprocin(PG_FUNCTION_ARGS)
|
||||
heap_close(hdesc, AccessShareLock);
|
||||
|
||||
if (matches == 0)
|
||||
elog(ERROR, "No procedure with name %s", pro_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no procedure with name %s", pro_name_or_oid)));
|
||||
|
||||
else if (matches > 1)
|
||||
elog(ERROR, "There is more than one procedure named %s",
|
||||
pro_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
|
||||
errmsg("more than one procedure named %s",
|
||||
pro_name_or_oid)));
|
||||
|
||||
PG_RETURN_OID(result);
|
||||
}
|
||||
|
||||
@ -127,10 +133,14 @@ regprocin(PG_FUNCTION_ARGS)
|
||||
clist = FuncnameGetCandidates(names, -1);
|
||||
|
||||
if (clist == NULL)
|
||||
elog(ERROR, "No procedure with name %s", pro_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no procedure with name %s", pro_name_or_oid)));
|
||||
else if (clist->next != NULL)
|
||||
elog(ERROR, "There is more than one procedure named %s",
|
||||
pro_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
|
||||
errmsg("more than one procedure named %s",
|
||||
pro_name_or_oid)));
|
||||
|
||||
result = clist->oid;
|
||||
|
||||
@ -275,7 +285,9 @@ regprocedurein(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
if (clist == NULL)
|
||||
elog(ERROR, "No procedure with name %s", pro_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no procedure with name %s", pro_name_or_oid)));
|
||||
|
||||
result = clist->oid;
|
||||
|
||||
@ -450,10 +462,15 @@ regoperin(PG_FUNCTION_ARGS)
|
||||
heap_close(hdesc, AccessShareLock);
|
||||
|
||||
if (matches == 0)
|
||||
elog(ERROR, "No operator with name %s", opr_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no operator with name %s", opr_name_or_oid)));
|
||||
else if (matches > 1)
|
||||
elog(ERROR, "There is more than one operator named %s",
|
||||
opr_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
|
||||
errmsg("more than one operator named %s",
|
||||
opr_name_or_oid)));
|
||||
|
||||
PG_RETURN_OID(result);
|
||||
}
|
||||
|
||||
@ -465,10 +482,14 @@ regoperin(PG_FUNCTION_ARGS)
|
||||
clist = OpernameGetCandidates(names, '\0');
|
||||
|
||||
if (clist == NULL)
|
||||
elog(ERROR, "No operator with name %s", opr_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no operator with name %s", opr_name_or_oid)));
|
||||
else if (clist->next != NULL)
|
||||
elog(ERROR, "There is more than one operator named %s",
|
||||
opr_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
|
||||
errmsg("more than one operator named %s",
|
||||
opr_name_or_oid)));
|
||||
|
||||
result = clist->oid;
|
||||
|
||||
@ -613,9 +634,15 @@ regoperatorin(PG_FUNCTION_ARGS)
|
||||
parseNameAndArgTypes(opr_name_or_oid, "regoperatorin", true,
|
||||
&names, &nargs, argtypes);
|
||||
if (nargs == 1)
|
||||
elog(ERROR, "regoperatorin: use NONE to denote the missing argument of a unary operator");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_PARAMETER),
|
||||
errmsg("missing argument"),
|
||||
errhint("Use NONE to denote the missing argument of a unary operator.")));
|
||||
if (nargs != 2)
|
||||
elog(ERROR, "regoperatorin: provide two argument types for operator");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
|
||||
errmsg("too many arguments"),
|
||||
errhint("Provide two argument types for operator.")));
|
||||
|
||||
if (argtypes[0] == InvalidOid)
|
||||
oprkind = 'l';
|
||||
@ -633,7 +660,9 @@ regoperatorin(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
if (clist == NULL)
|
||||
elog(ERROR, "No operator with name %s", opr_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("no operator with name %s", opr_name_or_oid)));
|
||||
|
||||
result = clist->oid;
|
||||
|
||||
@ -803,7 +832,9 @@ regclassin(PG_FUNCTION_ARGS)
|
||||
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
||||
result = HeapTupleGetOid(tuple);
|
||||
else
|
||||
elog(ERROR, "No class with name %s", class_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("no class with name %s", class_name_or_oid)));
|
||||
|
||||
/* We assume there can be only one match */
|
||||
|
||||
@ -967,7 +998,9 @@ regtypein(PG_FUNCTION_ARGS)
|
||||
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
||||
result = HeapTupleGetOid(tuple);
|
||||
else
|
||||
elog(ERROR, "No type with name %s", typ_name_or_oid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("no type with name %s", typ_name_or_oid)));
|
||||
|
||||
/* We assume there can be only one match */
|
||||
|
||||
@ -1072,10 +1105,14 @@ stringToQualifiedNameList(const char *string, const char *caller)
|
||||
rawname = pstrdup(string);
|
||||
|
||||
if (!SplitIdentifierString(rawname, '.', &namelist))
|
||||
elog(ERROR, "%s: invalid name syntax", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_NAME),
|
||||
errmsg("invalid name syntax")));
|
||||
|
||||
if (namelist == NIL)
|
||||
elog(ERROR, "%s: invalid name syntax", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_NAME),
|
||||
errmsg("invalid name syntax")));
|
||||
|
||||
foreach(l, namelist)
|
||||
{
|
||||
@ -1132,7 +1169,9 @@ parseNameAndArgTypes(const char *string, const char *caller,
|
||||
break;
|
||||
}
|
||||
if (*ptr == '\0')
|
||||
elog(ERROR, "%s: expected a left parenthesis", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("expected a left parenthesis")));
|
||||
|
||||
/* Separate the name and parse it into a list */
|
||||
*ptr++ = '\0';
|
||||
@ -1146,7 +1185,10 @@ parseNameAndArgTypes(const char *string, const char *caller,
|
||||
break;
|
||||
}
|
||||
if (*ptr2 != ')')
|
||||
elog(ERROR, "%s: expected a right parenthesis", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("expected a right parenthesis")));
|
||||
|
||||
*ptr2 = '\0';
|
||||
|
||||
/* Separate the remaining string into comma-separated type names */
|
||||
@ -1162,7 +1204,9 @@ parseNameAndArgTypes(const char *string, const char *caller,
|
||||
{
|
||||
/* End of string. Okay unless we had a comma before. */
|
||||
if (had_comma)
|
||||
elog(ERROR, "%s: expected a type name", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("expected a type name")));
|
||||
break;
|
||||
}
|
||||
typename = ptr;
|
||||
@ -1192,7 +1236,10 @@ parseNameAndArgTypes(const char *string, const char *caller,
|
||||
}
|
||||
}
|
||||
if (in_quote || paren_count != 0)
|
||||
elog(ERROR, "%s: improper type name", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("improper type name")));
|
||||
|
||||
ptr2 = ptr;
|
||||
if (*ptr == ',')
|
||||
{
|
||||
@ -1224,7 +1271,10 @@ parseNameAndArgTypes(const char *string, const char *caller,
|
||||
parseTypeString(typename, &typeid, &typmod);
|
||||
}
|
||||
if (*nargs >= FUNC_MAX_ARGS)
|
||||
elog(ERROR, "%s: too many argument datatypes", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
|
||||
errmsg("too many argument datatypes")));
|
||||
|
||||
argtypes[*nargs] = typeid;
|
||||
(*nargs)++;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* back to source text
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.145 2003/07/04 02:51:34 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.146 2003/07/27 04:53:09 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@ -197,7 +197,7 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
|
||||
* Connect to SPI manager
|
||||
*/
|
||||
if (SPI_connect() != SPI_OK_CONNECT)
|
||||
elog(ERROR, "get_ruledef: cannot connect to SPI manager");
|
||||
elog(ERROR, "SPI_connect failed");
|
||||
|
||||
/*
|
||||
* On the first call prepare the plan to lookup pg_rewrite. We read
|
||||
@ -212,7 +212,7 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
|
||||
argtypes[0] = OIDOID;
|
||||
plan = SPI_prepare(query_getrulebyoid, 1, argtypes);
|
||||
if (plan == NULL)
|
||||
elog(ERROR, "SPI_prepare() failed for \"%s\"", query_getrulebyoid);
|
||||
elog(ERROR, "SPI_prepare failed for \"%s\"", query_getrulebyoid);
|
||||
plan_getrulebyoid = SPI_saveplan(plan);
|
||||
}
|
||||
|
||||
@ -223,11 +223,11 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
|
||||
nulls[0] = ' ';
|
||||
spirc = SPI_execp(plan_getrulebyoid, args, nulls, 1);
|
||||
if (spirc != SPI_OK_SELECT)
|
||||
elog(ERROR, "failed to get pg_rewrite tuple for %u", ruleoid);
|
||||
elog(ERROR, "failed to get pg_rewrite tuple for rule %u", ruleoid);
|
||||
if (SPI_processed != 1)
|
||||
{
|
||||
if (SPI_finish() != SPI_OK_FINISH)
|
||||
elog(ERROR, "get_ruledef: SPI_finish() failed");
|
||||
elog(ERROR, "SPI_finish failed");
|
||||
ruledef = palloc(VARHDRSZ + 1);
|
||||
VARATT_SIZEP(ruledef) = VARHDRSZ + 1;
|
||||
VARDATA(ruledef)[0] = '-';
|
||||
@ -252,7 +252,7 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
|
||||
* Disconnect from SPI manager
|
||||
*/
|
||||
if (SPI_finish() != SPI_OK_FINISH)
|
||||
elog(ERROR, "get_ruledef: SPI_finish() failed");
|
||||
elog(ERROR, "SPI_finish failed");
|
||||
|
||||
/*
|
||||
* Easy - isn't it?
|
||||
@ -313,7 +313,7 @@ pg_do_getviewdef(Oid viewoid)
|
||||
* Connect to SPI manager
|
||||
*/
|
||||
if (SPI_connect() != SPI_OK_CONNECT)
|
||||
elog(ERROR, "get_viewdef: cannot connect to SPI manager");
|
||||
elog(ERROR, "SPI_connect failed");
|
||||
|
||||
/*
|
||||
* On the first call prepare the plan to lookup pg_rewrite. We read
|
||||
@ -329,7 +329,7 @@ pg_do_getviewdef(Oid viewoid)
|
||||
argtypes[1] = NAMEOID;
|
||||
plan = SPI_prepare(query_getviewrule, 2, argtypes);
|
||||
if (plan == NULL)
|
||||
elog(ERROR, "SPI_prepare() failed for \"%s\"", query_getviewrule);
|
||||
elog(ERROR, "SPI_prepare failed for \"%s\"", query_getviewrule);
|
||||
plan_getviewrule = SPI_saveplan(plan);
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ pg_do_getviewdef(Oid viewoid)
|
||||
* Disconnect from SPI manager
|
||||
*/
|
||||
if (SPI_finish() != SPI_OK_FINISH)
|
||||
elog(ERROR, "get_viewdef: SPI_finish() failed");
|
||||
elog(ERROR, "SPI_finish failed");
|
||||
|
||||
return ruledef;
|
||||
}
|
||||
@ -404,8 +404,7 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
|
||||
ht_trig = systable_getnext(tgscan);
|
||||
|
||||
if (!HeapTupleIsValid(ht_trig))
|
||||
elog(ERROR, "pg_get_triggerdef: there is no trigger with oid %u",
|
||||
trigid);
|
||||
elog(ERROR, "could not find tuple for trigger %u", trigid);
|
||||
|
||||
trigrec = (Form_pg_trigger) GETSTRUCT(ht_trig);
|
||||
|
||||
@ -552,7 +551,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
|
||||
ObjectIdGetDatum(indexrelid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(ht_idx))
|
||||
elog(ERROR, "syscache lookup for index %u failed", indexrelid);
|
||||
elog(ERROR, "cache lookup failed for index %u", indexrelid);
|
||||
idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
|
||||
|
||||
indrelid = idxrec->indrelid;
|
||||
@ -565,7 +564,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
|
||||
ObjectIdGetDatum(indexrelid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(ht_idxrel))
|
||||
elog(ERROR, "syscache lookup for relid %u failed", indexrelid);
|
||||
elog(ERROR, "cache lookup failed for relation %u", indexrelid);
|
||||
idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
|
||||
|
||||
/*
|
||||
@ -575,7 +574,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
|
||||
ObjectIdGetDatum(idxrelrec->relam),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(ht_am))
|
||||
elog(ERROR, "syscache lookup for AM %u failed", idxrelrec->relam);
|
||||
elog(ERROR, "cache lookup failed for access method %u",
|
||||
idxrelrec->relam);
|
||||
amrec = (Form_pg_am) GETSTRUCT(ht_am);
|
||||
|
||||
/*
|
||||
@ -745,7 +745,7 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
|
||||
tup = systable_getnext(conscan);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "Failed to find constraint with OID %u", constraintId);
|
||||
elog(ERROR, "could not find tuple for constraint %u", constraintId);
|
||||
conForm = (Form_pg_constraint) GETSTRUCT(tup);
|
||||
|
||||
initStringInfo(&buf);
|
||||
@ -765,7 +765,7 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
val = heap_getattr(tup, Anum_pg_constraint_conkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u",
|
||||
elog(ERROR, "null conkey for constraint %u",
|
||||
constraintId);
|
||||
|
||||
decompile_column_index_array(val, conForm->conrelid, &buf);
|
||||
@ -778,7 +778,7 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
val = heap_getattr(tup, Anum_pg_constraint_confkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u",
|
||||
elog(ERROR, "null confkey for constraint %u",
|
||||
constraintId);
|
||||
|
||||
decompile_column_index_array(val, conForm->confrelid, &buf);
|
||||
@ -798,8 +798,8 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
string = "";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u",
|
||||
conForm->confmatchtype, constraintId);
|
||||
elog(ERROR, "unrecognized confmatchtype: %d",
|
||||
conForm->confmatchtype);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -824,8 +824,8 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
string = "SET DEFAULT";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u",
|
||||
conForm->confupdtype, constraintId);
|
||||
elog(ERROR, "unrecognized confupdtype: %d",
|
||||
conForm->confupdtype);
|
||||
string = NULL; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -850,8 +850,8 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
string = "SET DEFAULT";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u",
|
||||
conForm->confdeltype, constraintId);
|
||||
elog(ERROR, "unrecognized confdeltype: %d",
|
||||
conForm->confdeltype);
|
||||
string = NULL; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -881,7 +881,7 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
val = heap_getattr(tup, Anum_pg_constraint_conkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u",
|
||||
elog(ERROR, "null conkey for constraint %u",
|
||||
constraintId);
|
||||
|
||||
decompile_column_index_array(val, conForm->conrelid, &buf);
|
||||
@ -908,7 +908,7 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
val = heap_getattr(tup, Anum_pg_constraint_conbin,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null consrc for constraint %u",
|
||||
elog(ERROR, "null consrc for constraint %u",
|
||||
constraintId);
|
||||
|
||||
conbin = DatumGetCString(DirectFunctionCall1(textout, val));
|
||||
@ -942,8 +942,10 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: unsupported constraint type '%c'",
|
||||
conForm->contype);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("unsupported constraint type \"%c\"",
|
||||
conForm->contype)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1344,8 +1346,10 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "get_ruledef: rule %s has unsupported event type %d",
|
||||
rulename, ev_type);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("rule \"%s\" has unsupported event type %d",
|
||||
rulename, ev_type)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1546,7 +1550,7 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "get_query_def: unknown query command type %d",
|
||||
elog(ERROR, "unrecognized query command type: %d",
|
||||
query->commandType);
|
||||
break;
|
||||
}
|
||||
@ -1781,7 +1785,7 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
||||
appendStringInfo(buf, ") EXCEPT ");
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_setop_query: unexpected set op %d",
|
||||
elog(ERROR, "unrecognized set op: %d",
|
||||
(int) op->op);
|
||||
}
|
||||
if (op->all)
|
||||
@ -1793,7 +1797,7 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "get_setop_query: unexpected node %d",
|
||||
elog(ERROR, "unrecognized node type: %d",
|
||||
(int) nodeTag(setOp));
|
||||
}
|
||||
}
|
||||
@ -1853,7 +1857,7 @@ get_insert_query_def(Query *query, deparse_context *context)
|
||||
if (rte->rtekind != RTE_SUBQUERY)
|
||||
continue;
|
||||
if (select_rte)
|
||||
elog(ERROR, "get_insert_query_def: too many RTEs in INSERT!");
|
||||
elog(ERROR, "too many RTEs in INSERT");
|
||||
select_rte = rte;
|
||||
}
|
||||
|
||||
@ -2005,7 +2009,10 @@ get_utility_query_def(Query *query, deparse_context *context)
|
||||
stmt->relation->relname));
|
||||
}
|
||||
else
|
||||
elog(ERROR, "get_utility_query_def: unexpected statement type");
|
||||
{
|
||||
/* Currently only NOTIFY utility commands can appear in rules */
|
||||
elog(ERROR, "unexpected utility statement type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2036,8 +2043,7 @@ get_names_for_var(Var *var, deparse_context *context,
|
||||
while (sup-- > 0 && nslist != NIL)
|
||||
nslist = lnext(nslist);
|
||||
if (nslist == NIL)
|
||||
elog(ERROR, "get_names_for_var: bogus varlevelsup %d",
|
||||
var->varlevelsup);
|
||||
elog(ERROR, "bogus varlevelsup: %d", var->varlevelsup);
|
||||
dpns = (deparse_namespace *) lfirst(nslist);
|
||||
|
||||
/* Find the relevant RTE */
|
||||
@ -2050,8 +2056,7 @@ get_names_for_var(Var *var, deparse_context *context,
|
||||
else
|
||||
rte = NULL;
|
||||
if (rte == NULL)
|
||||
elog(ERROR, "get_names_for_var: bogus varno %d",
|
||||
var->varno);
|
||||
elog(ERROR, "bogus varno: %d", var->varno);
|
||||
|
||||
/* Emit results */
|
||||
*schemaname = NULL; /* default assumptions */
|
||||
@ -2360,7 +2365,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "get_rule_expr: unknown boolop %d",
|
||||
elog(ERROR, "unrecognized boolop: %d",
|
||||
(int) expr->boolop);
|
||||
}
|
||||
}
|
||||
@ -2394,7 +2399,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
/* lookup arg type and get the field name */
|
||||
typrelid = get_typ_typrelid(argType);
|
||||
if (!OidIsValid(typrelid))
|
||||
elog(ERROR, "Argument type %s of FieldSelect is not a tuple type",
|
||||
elog(ERROR, "argument type %s of FieldSelect is not a tuple type",
|
||||
format_type_be(argType));
|
||||
fieldname = get_relid_attribute_name(typrelid,
|
||||
fselect->fieldnum);
|
||||
@ -2536,7 +2541,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
appendStringInfo(buf, " IS NOT NULL)");
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_rule_expr: unexpected nulltesttype %d",
|
||||
elog(ERROR, "unrecognized nulltesttype: %d",
|
||||
(int) ntest->nulltesttype);
|
||||
}
|
||||
}
|
||||
@ -2569,7 +2574,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
appendStringInfo(buf, " IS NOT UNKNOWN)");
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_rule_expr: unexpected booltesttype %d",
|
||||
elog(ERROR, "unrecognized booltesttype: %d",
|
||||
(int) btest->booltesttype);
|
||||
}
|
||||
}
|
||||
@ -2611,7 +2616,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "get_rule_expr: unknown node type %d", nodeTag(node));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2652,7 +2657,7 @@ get_oper_expr(OpExpr *expr, deparse_context *context)
|
||||
ObjectIdGetDatum(opno),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup for operator %u failed", opno);
|
||||
elog(ERROR, "cache lookup failed for operator %u", opno);
|
||||
optup = (Form_pg_operator) GETSTRUCT(tp);
|
||||
switch (optup->oprkind)
|
||||
{
|
||||
@ -2671,7 +2676,7 @@ get_oper_expr(OpExpr *expr, deparse_context *context)
|
||||
InvalidOid));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_rule_expr: bogus oprkind");
|
||||
elog(ERROR, "bogus oprkind: %d", optup->oprkind);
|
||||
}
|
||||
ReleaseSysCache(tp);
|
||||
}
|
||||
@ -2849,7 +2854,7 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
ObjectIdGetDatum(constval->consttype),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(typetup))
|
||||
elog(ERROR, "cache lookup of type %u failed", constval->consttype);
|
||||
elog(ERROR, "cache lookup failed for type %u", constval->consttype);
|
||||
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typetup);
|
||||
|
||||
@ -3039,8 +3044,8 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "get_sublink_expr: unsupported sublink type %d",
|
||||
sublink->subLinkType);
|
||||
elog(ERROR, "unrecognized sublink type: %d",
|
||||
(int) sublink->subLinkType);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3132,7 +3137,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
|
||||
coldeflist = rte->coldeflist;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unexpected rte kind %d", (int) rte->rtekind);
|
||||
elog(ERROR, "unrecognized RTE kind: %d", (int) rte->rtekind);
|
||||
break;
|
||||
}
|
||||
if (rte->alias != NULL)
|
||||
@ -3204,7 +3209,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
|
||||
appendStringInfo(buf, " UNION JOIN ");
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_from_clause_item: unknown join type %d",
|
||||
elog(ERROR, "unrecognized join type: %d",
|
||||
(int) j->jointype);
|
||||
}
|
||||
get_from_clause_item(j->rarg, query, context);
|
||||
@ -3254,8 +3259,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
|
||||
}
|
||||
}
|
||||
else
|
||||
elog(ERROR, "get_from_clause_item: unexpected node type %d",
|
||||
nodeTag(jtnode));
|
||||
elog(ERROR, "unrecognized node type: %d",
|
||||
(int) nodeTag(jtnode));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3361,7 +3366,8 @@ tleIsArrayAssign(TargetEntry *tle)
|
||||
*/
|
||||
if (aref->refexpr == NULL || !IsA(aref->refexpr, Var) ||
|
||||
((Var *) aref->refexpr)->varattno != tle->resdom->resno)
|
||||
elog(WARNING, "tleIsArrayAssign: I'm confused ...");
|
||||
elog(ERROR, "unrecognized situation in array assignment");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3483,7 +3489,7 @@ generate_relation_name(Oid relid)
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "cache lookup of relation %u failed", relid);
|
||||
elog(ERROR, "cache lookup failed for relation %u", relid);
|
||||
reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
|
||||
/* Qualify the name if not visible in search path */
|
||||
@ -3525,7 +3531,7 @@ generate_function_name(Oid funcid, int nargs, Oid *argtypes)
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(proctup))
|
||||
elog(ERROR, "cache lookup of function %u failed", funcid);
|
||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||
procform = (Form_pg_proc) GETSTRUCT(proctup);
|
||||
proname = NameStr(procform->proname);
|
||||
Assert(nargs == procform->pronargs);
|
||||
@ -3579,7 +3585,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
|
||||
ObjectIdGetDatum(operid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(opertup))
|
||||
elog(ERROR, "cache lookup of operator %u failed", operid);
|
||||
elog(ERROR, "cache lookup failed for operator %u", operid);
|
||||
operform = (Form_pg_operator) GETSTRUCT(opertup);
|
||||
oprname = NameStr(operform->oprname);
|
||||
|
||||
@ -3600,8 +3606,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
|
||||
p_result = right_oper(makeList1(makeString(oprname)), arg1, true);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unexpected oprkind %c for operator %u",
|
||||
operform->oprkind, operid);
|
||||
elog(ERROR, "unrecognized oprkind: %d", operform->oprkind);
|
||||
p_result = NULL; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -3664,7 +3669,7 @@ get_relid_attribute_name(Oid relid, AttrNumber attnum)
|
||||
|
||||
attname = get_attname(relid, attnum);
|
||||
if (attname == NULL)
|
||||
elog(ERROR, "cache lookup of attribute %d in relation %u failed",
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, relid);
|
||||
return attname;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.141 2003/07/17 22:20:14 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.142 2003/07/27 04:53:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -939,7 +939,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
|
||||
prefix->constvalue));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "patternsel: unexpected consttype %u",
|
||||
elog(ERROR, "unrecognized consttype: %u",
|
||||
prefix->consttype);
|
||||
return DEFAULT_MATCH_SEL;
|
||||
}
|
||||
@ -956,7 +956,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
|
||||
List *eqargs;
|
||||
|
||||
if (eqopr == InvalidOid)
|
||||
elog(ERROR, "patternsel: no = operator for opclass %u", opclass);
|
||||
elog(ERROR, "no = operator for opclass %u", opclass);
|
||||
eqargs = makeList2(var, prefix);
|
||||
result = DatumGetFloat8(DirectFunctionCall4(eqsel,
|
||||
PointerGetDatum(root),
|
||||
@ -1136,7 +1136,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
|
||||
varRelid, jointype);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "booltestsel: unexpected booltesttype %d",
|
||||
elog(ERROR, "unrecognized booltesttype: %d",
|
||||
(int) booltesttype);
|
||||
selec = 0.0; /* Keep compiler quiet */
|
||||
break;
|
||||
@ -1213,7 +1213,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
|
||||
selec = 1.0 - freq_false;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "booltestsel: unexpected booltesttype %d",
|
||||
elog(ERROR, "unrecognized booltesttype: %d",
|
||||
(int) booltesttype);
|
||||
selec = 0.0; /* Keep compiler quiet */
|
||||
break;
|
||||
@ -1254,7 +1254,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
|
||||
selec = (1.0 - freq_null) / 2.0;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "booltestsel: unexpected booltesttype %d",
|
||||
elog(ERROR, "unrecognized booltesttype: %d",
|
||||
(int) booltesttype);
|
||||
selec = 0.0; /* Keep compiler quiet */
|
||||
break;
|
||||
@ -1284,7 +1284,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
|
||||
selec = DEFAULT_BOOL_SEL;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "booltestsel: unexpected booltesttype %d",
|
||||
elog(ERROR, "unrecognized booltesttype: %d",
|
||||
(int) booltesttype);
|
||||
selec = 0.0; /* Keep compiler quiet */
|
||||
break;
|
||||
@ -1319,7 +1319,7 @@ nulltestsel(Query *root, NullTestType nulltesttype, Node *arg, int varRelid)
|
||||
defselec = DEFAULT_NOT_UNK_SEL;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
|
||||
elog(ERROR, "unrecognized nulltesttype: %d",
|
||||
(int) nulltesttype);
|
||||
return (Selectivity) 0; /* keep compiler quiet */
|
||||
}
|
||||
@ -1373,7 +1373,7 @@ nulltestsel(Query *root, NullTestType nulltesttype, Node *arg, int varRelid)
|
||||
selec = 1.0 - freq_null;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
|
||||
elog(ERROR, "unrecognized nulltesttype: %d",
|
||||
(int) nulltesttype);
|
||||
return (Selectivity) 0; /* keep compiler quiet */
|
||||
}
|
||||
@ -2500,7 +2500,7 @@ convert_numeric_to_scalar(Datum value, Oid typid)
|
||||
* Can't get here unless someone tries to use scalarltsel/scalargtsel
|
||||
* on an operator with one numeric and one non-numeric operand.
|
||||
*/
|
||||
elog(ERROR, "convert_numeric_to_scalar: unsupported type %u", typid);
|
||||
elog(ERROR, "unsupported type: %u", typid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2684,7 +2684,7 @@ convert_string_datum(Datum value, Oid typid)
|
||||
* Can't get here unless someone tries to use scalarltsel on
|
||||
* an operator with one string and one non-string operand.
|
||||
*/
|
||||
elog(ERROR, "convert_string_datum: unsupported type %u", typid);
|
||||
elog(ERROR, "unsupported type: %u", typid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2882,7 +2882,7 @@ convert_timevalue_to_scalar(Datum value, Oid typid)
|
||||
* Can't get here unless someone tries to use scalarltsel/scalargtsel
|
||||
* on an operator with one timevalue and one non-timevalue operand.
|
||||
*/
|
||||
elog(ERROR, "convert_timevalue_to_scalar: unsupported type %u", typid);
|
||||
elog(ERROR, "unsupported type: %u", typid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3111,7 +3111,9 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
Assert(typeid == BYTEAOID || typeid == TEXTOID);
|
||||
|
||||
if (typeid == BYTEAOID && case_insensitive)
|
||||
elog(ERROR, "Cannot perform case insensitive matching on type BYTEA");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("case insensitive matching not supported on type bytea")));
|
||||
|
||||
if (typeid != BYTEAOID)
|
||||
{
|
||||
@ -3194,7 +3196,9 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
* been made safe for binary (possibly NULL containing) strings.
|
||||
*/
|
||||
if (typeid == BYTEAOID)
|
||||
elog(ERROR, "Regex matching not supported on type BYTEA");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("regex matching not supported on type bytea")));
|
||||
|
||||
/* the right-hand const is type text for all of these */
|
||||
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
|
||||
@ -3337,7 +3341,7 @@ pattern_fixed_prefix(Const *patt, Pattern_Type ptype,
|
||||
result = regex_fixed_prefix(patt, true, prefix, rest);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pattern_fixed_prefix: bogus ptype");
|
||||
elog(ERROR, "unrecognized ptype: %d", (int) ptype);
|
||||
result = Pattern_Prefix_None; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -3368,8 +3372,7 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon)
|
||||
|
||||
cmpopr = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
|
||||
if (cmpopr == InvalidOid)
|
||||
elog(ERROR, "prefix_selectivity: no >= operator for opclass %u",
|
||||
opclass);
|
||||
elog(ERROR, "no >= operator for opclass %u", opclass);
|
||||
cmpargs = makeList2(var, prefixcon);
|
||||
/* Assume scalargtsel is appropriate for all supported types */
|
||||
prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel,
|
||||
@ -3390,8 +3393,7 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon)
|
||||
|
||||
cmpopr = get_opclass_member(opclass, BTLessStrategyNumber);
|
||||
if (cmpopr == InvalidOid)
|
||||
elog(ERROR, "prefix_selectivity: no < operator for opclass %u",
|
||||
opclass);
|
||||
elog(ERROR, "no < operator for opclass %u", opclass);
|
||||
cmpargs = makeList2(var, greaterstrcon);
|
||||
/* Assume scalarltsel is appropriate for all supported types */
|
||||
topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel,
|
||||
@ -3472,7 +3474,9 @@ like_selectivity(Const *patt_const, bool case_insensitive)
|
||||
Assert(typeid == BYTEAOID || typeid == TEXTOID);
|
||||
|
||||
if (typeid == BYTEAOID && case_insensitive)
|
||||
elog(ERROR, "Cannot perform case insensitive matching on type BYTEA");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("case insensitive matching not supported on type bytea")));
|
||||
|
||||
if (typeid != BYTEAOID)
|
||||
{
|
||||
@ -3618,7 +3622,9 @@ regex_selectivity(Const *patt_const, bool case_insensitive)
|
||||
* been made safe for binary (possibly NULL containing) strings.
|
||||
*/
|
||||
if (typeid == BYTEAOID)
|
||||
elog(ERROR, "Regex matching not supported on type BYTEA");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("regex matching not supported on type bytea")));
|
||||
|
||||
/* the right-hand const is type text for all of these */
|
||||
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
|
||||
@ -3662,7 +3668,7 @@ pattern_selectivity(Const *patt, Pattern_Type ptype)
|
||||
result = regex_selectivity(patt, true);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pattern_selectivity: bogus ptype");
|
||||
elog(ERROR, "unrecognized ptype: %d", (int) ptype);
|
||||
result = 1.0; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.55 2002/12/13 19:45:56 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.56 2003/07/27 04:53:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -83,7 +83,7 @@ SetDefine(char *querystr, Oid elemType)
|
||||
ObjectIdGetDatum(setoid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "SetDefine: unable to define set %s", querystr);
|
||||
elog(ERROR, "cache lookup failed for function %u", setoid);
|
||||
|
||||
/*
|
||||
* We can tell whether the set was already defined by checking the
|
||||
@ -201,7 +201,10 @@ seteval(PG_FUNCTION_ARGS)
|
||||
if (rsi && IsA(rsi, ReturnSetInfo))
|
||||
rsi->isDone = isDone;
|
||||
else
|
||||
elog(ERROR, "Set-valued function called in context that cannot accept a set");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("set-valued function called in context that "
|
||||
"cannot accept a set")));
|
||||
}
|
||||
|
||||
PG_RETURN_DATUM(result);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.37 2003/05/12 23:08:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.38 2003/07/27 04:53:10 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* input routine largely stolen from boxin().
|
||||
@ -61,17 +61,27 @@ tidin(PG_FUNCTION_ARGS)
|
||||
coord[i++] = p + 1;
|
||||
|
||||
if (i < NTIDARGS)
|
||||
elog(ERROR, "invalid tid format: '%s'", str);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for tid: \"%s\"",
|
||||
str)));
|
||||
|
||||
errno = 0;
|
||||
blockNumber = strtoul(coord[0], &badp, 10);
|
||||
if (errno || *badp != DELIM)
|
||||
elog(ERROR, "tidin: invalid value.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for tid: \"%s\"",
|
||||
str)));
|
||||
|
||||
hold_offset = strtol(coord[1], &badp, 10);
|
||||
if (errno || *badp != RDELIM ||
|
||||
hold_offset > USHRT_MAX || hold_offset < 0)
|
||||
elog(ERROR, "tidin: invalid value.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for tid: \"%s\"",
|
||||
str)));
|
||||
|
||||
offsetNumber = hold_offset;
|
||||
|
||||
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||
@ -216,8 +226,9 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
}
|
||||
}
|
||||
if (tididx < 0)
|
||||
elog(ERROR, "currtid can't handle views with no CTID");
|
||||
if (rulelock = viewrel->rd_rules, !rulelock)
|
||||
elog(ERROR, "currtid cannot handle views with no CTID");
|
||||
rulelock = viewrel->rd_rules;
|
||||
if (!rulelock)
|
||||
elog(ERROR, "the view has no rules");
|
||||
for (i = 0; i < rulelock->numLocks; i++)
|
||||
{
|
||||
@ -231,12 +242,13 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
elog(ERROR, "only one select rule is allowed in views");
|
||||
query = (Query *) lfirst(rewrite->actions);
|
||||
tle = (TargetEntry *) nth(tididx, query->targetList);
|
||||
if (tle && tle->expr && nodeTag(tle->expr) == T_Var)
|
||||
if (tle && tle->expr && IsA(tle->expr, Var))
|
||||
{
|
||||
Var *var = (Var *) tle->expr;
|
||||
RangeTblEntry *rte;
|
||||
|
||||
if (var->varno > 0 && var->varno < INNER && var->varattno == SelfItemPointerAttributeNumber)
|
||||
if (var->varno > 0 && var->varno < INNER &&
|
||||
var->varattno == SelfItemPointerAttributeNumber)
|
||||
{
|
||||
rte = (RangeTblEntry *) nth(var->varno - 1, query->rtable);
|
||||
if (rte)
|
||||
@ -249,7 +261,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
elog(ERROR, "currtid can't handle this view");
|
||||
elog(ERROR, "currtid cannot handle this view");
|
||||
return (Datum) 0;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.31 2003/05/27 17:49:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.32 2003/07/27 04:53:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -104,8 +104,10 @@ bit_in(PG_FUNCTION_ARGS)
|
||||
if (atttypmod <= 0)
|
||||
atttypmod = bitlen;
|
||||
else if (bitlen != atttypmod)
|
||||
elog(ERROR, "Bit string length %d does not match type BIT(%d)",
|
||||
bitlen, atttypmod);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("bit string length %d does not match type bit(%d)",
|
||||
bitlen, atttypmod)));
|
||||
|
||||
len = VARBITTOTALLEN(atttypmod);
|
||||
/* set to 0 so that *r is always initialised and string is zero-padded */
|
||||
@ -124,7 +126,11 @@ bit_in(PG_FUNCTION_ARGS)
|
||||
if (*sp == '1')
|
||||
*r |= x;
|
||||
else if (*sp != '0')
|
||||
elog(ERROR, "Cannot parse '%c' as a binary digit", *sp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("\"%c\" is not a valid binary digit",
|
||||
*sp)));
|
||||
|
||||
x >>= 1;
|
||||
if (x == 0)
|
||||
{
|
||||
@ -145,7 +151,11 @@ bit_in(PG_FUNCTION_ARGS)
|
||||
else if (*sp >= 'a' && *sp <= 'f')
|
||||
x = (bits8) (*sp - 'a') + 10;
|
||||
else
|
||||
elog(ERROR, "Cannot parse '%c' as a hex digit", *sp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("\"%c\" is not a valid hex digit",
|
||||
*sp)));
|
||||
|
||||
if (bc)
|
||||
{
|
||||
*r++ |= x;
|
||||
@ -248,8 +258,10 @@ bit(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_VARBIT_P(arg);
|
||||
|
||||
if (!isExplicit)
|
||||
elog(ERROR, "Bit string length %d does not match type BIT(%d)",
|
||||
VARBITLEN(arg), len);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("bit string length %d does not match type bit(%d)",
|
||||
VARBITLEN(arg), len)));
|
||||
|
||||
rlen = VARBITTOTALLEN(len);
|
||||
/* set to 0 so that string is zero-padded */
|
||||
@ -331,8 +343,10 @@ varbit_in(PG_FUNCTION_ARGS)
|
||||
if (atttypmod <= 0)
|
||||
atttypmod = bitlen;
|
||||
else if (bitlen > atttypmod)
|
||||
elog(ERROR, "Bit string too long for type BIT VARYING(%d)",
|
||||
atttypmod);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("bit string too long for type bit varying(%d)",
|
||||
atttypmod)));
|
||||
|
||||
len = VARBITTOTALLEN(bitlen);
|
||||
/* set to 0 so that *r is always initialised and string is zero-padded */
|
||||
@ -351,7 +365,11 @@ varbit_in(PG_FUNCTION_ARGS)
|
||||
if (*sp == '1')
|
||||
*r |= x;
|
||||
else if (*sp != '0')
|
||||
elog(ERROR, "Cannot parse '%c' as a binary digit", *sp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("\"%c\" is not a valid binary digit",
|
||||
*sp)));
|
||||
|
||||
x >>= 1;
|
||||
if (x == 0)
|
||||
{
|
||||
@ -372,7 +390,11 @@ varbit_in(PG_FUNCTION_ARGS)
|
||||
else if (*sp >= 'a' && *sp <= 'f')
|
||||
x = (bits8) (*sp - 'a') + 10;
|
||||
else
|
||||
elog(ERROR, "Cannot parse '%c' as a hex digit", *sp);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("\"%c\" is not a valid hex digit",
|
||||
*sp)));
|
||||
|
||||
if (bc)
|
||||
{
|
||||
*r++ |= x;
|
||||
@ -445,7 +467,9 @@ varbit_recv(PG_FUNCTION_ARGS)
|
||||
|
||||
bitlen = pq_getmsgint(buf, sizeof(int32));
|
||||
if (bitlen < 0)
|
||||
elog(ERROR, "Invalid length in external bit string");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid length in external bit string")));
|
||||
|
||||
len = VARBITTOTALLEN(bitlen);
|
||||
result = (VarBit *) palloc(len);
|
||||
@ -503,7 +527,10 @@ varbit(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_VARBIT_P(arg);
|
||||
|
||||
if (!isExplicit)
|
||||
elog(ERROR, "Bit string too long for type BIT VARYING(%d)", len);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("bit string too long for type bit varying(%d)",
|
||||
len)));
|
||||
|
||||
rlen = VARBITTOTALLEN(len);
|
||||
result = (VarBit *) palloc(rlen);
|
||||
@ -873,7 +900,10 @@ bitand(PG_FUNCTION_ARGS)
|
||||
bitlen1 = VARBITLEN(arg1);
|
||||
bitlen2 = VARBITLEN(arg2);
|
||||
if (bitlen1 != bitlen2)
|
||||
elog(ERROR, "Cannot AND bit strings of different sizes");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot AND bit strings of different sizes")));
|
||||
|
||||
len = VARSIZE(arg1);
|
||||
result = (VarBit *) palloc(len);
|
||||
VARATT_SIZEP(result) = len;
|
||||
@ -911,7 +941,9 @@ bitor(PG_FUNCTION_ARGS)
|
||||
bitlen1 = VARBITLEN(arg1);
|
||||
bitlen2 = VARBITLEN(arg2);
|
||||
if (bitlen1 != bitlen2)
|
||||
elog(ERROR, "Cannot OR bit strings of different sizes");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot OR bit strings of different sizes")));
|
||||
len = VARSIZE(arg1);
|
||||
result = (VarBit *) palloc(len);
|
||||
VARATT_SIZEP(result) = len;
|
||||
@ -955,7 +987,10 @@ bitxor(PG_FUNCTION_ARGS)
|
||||
bitlen1 = VARBITLEN(arg1);
|
||||
bitlen2 = VARBITLEN(arg2);
|
||||
if (bitlen1 != bitlen2)
|
||||
elog(ERROR, "Cannot XOR bit strings of different sizes");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot XOR bit strings of different sizes")));
|
||||
|
||||
len = VARSIZE(arg1);
|
||||
result = (VarBit *) palloc(len);
|
||||
VARATT_SIZEP(result) = len;
|
||||
@ -1170,7 +1205,10 @@ bittoint4(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Check that the bit string is not too long */
|
||||
if (VARBITLEN(arg) > sizeof(int4) * BITS_PER_BYTE)
|
||||
elog(ERROR, "Bit string is too large to fit in type integer");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
result = 0;
|
||||
for (r = VARBITS(arg); r < VARBITEND(arg); r++)
|
||||
{
|
||||
@ -1214,7 +1252,10 @@ bitfromint8(PG_FUNCTION_ARGS)
|
||||
|
||||
PG_RETURN_VARBIT_P(result);
|
||||
#else
|
||||
elog(ERROR, "INT64 is not supported on this platform");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("int64 is not supported on this platform")));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
#endif
|
||||
}
|
||||
@ -1229,7 +1270,10 @@ bittoint8(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Check that the bit string is not too long */
|
||||
if (VARBITLEN(arg) > sizeof(result) * BITS_PER_BYTE)
|
||||
elog(ERROR, "Bit string is too large to fit in type int64");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("integer out of range")));
|
||||
|
||||
result = 0;
|
||||
for (r = VARBITS(arg); r < VARBITEND(arg); r++)
|
||||
{
|
||||
@ -1241,7 +1285,10 @@ bittoint8(PG_FUNCTION_ARGS)
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
#else
|
||||
elog(ERROR, "INT64 is not supported on this platform");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("int64 is not supported on this platform")));
|
||||
|
||||
PG_RETURN_NULL();
|
||||
#endif
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.98 2003/06/22 22:04:54 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.99 2003/07/27 04:53:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -73,18 +73,14 @@ bpcharin(PG_FUNCTION_ARGS)
|
||||
size_t len,
|
||||
maxlen;
|
||||
int i;
|
||||
|
||||
int charlen; /* number of charcters in the input string */
|
||||
char *ermsg;
|
||||
|
||||
/* verify encoding */
|
||||
len = strlen(s);
|
||||
|
||||
if ((ermsg = pg_verifymbstr(s, len)))
|
||||
elog(ERROR, "%s", ermsg);
|
||||
pg_verifymbstr(s, len, false);
|
||||
|
||||
charlen = pg_mbstrlen(s);
|
||||
|
||||
|
||||
/* If typmod is -1 (or invalid), use the actual string length */
|
||||
if (atttypmod < (int32) VARHDRSZ)
|
||||
maxlen = charlen;
|
||||
@ -104,8 +100,10 @@ bpcharin(PG_FUNCTION_ARGS)
|
||||
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
|
||||
len = mbmaxlen;
|
||||
else
|
||||
elog(ERROR, "value too long for type character(%d)",
|
||||
(int) maxlen);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("value too long for type character(%d)",
|
||||
(int) maxlen)));
|
||||
|
||||
/*
|
||||
* XXX: at this point, maxlen is the necessary byte length, not
|
||||
@ -230,8 +228,10 @@ bpchar(PG_FUNCTION_ARGS)
|
||||
{
|
||||
for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++)
|
||||
if (*(VARDATA(source) + i) != ' ')
|
||||
elog(ERROR, "value too long for type character(%d)",
|
||||
maxlen - VARHDRSZ);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("value too long for type character(%d)",
|
||||
maxlen - VARHDRSZ)));
|
||||
}
|
||||
|
||||
len = maxmblen;
|
||||
@ -372,12 +372,9 @@ varcharin(PG_FUNCTION_ARGS)
|
||||
size_t len,
|
||||
maxlen;
|
||||
|
||||
char *ermsg;
|
||||
|
||||
/* verify encoding */
|
||||
len = strlen(s);
|
||||
|
||||
if ((ermsg = pg_verifymbstr(s, len)))
|
||||
elog(ERROR, "%s", ermsg);
|
||||
pg_verifymbstr(s, len, false);
|
||||
|
||||
maxlen = atttypmod - VARHDRSZ;
|
||||
|
||||
@ -389,8 +386,10 @@ varcharin(PG_FUNCTION_ARGS)
|
||||
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
|
||||
len = mbmaxlen;
|
||||
else
|
||||
elog(ERROR, "value too long for type character varying(%d)",
|
||||
(int) maxlen);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("value too long for type character varying(%d)",
|
||||
(int) maxlen)));
|
||||
}
|
||||
|
||||
result = palloc(len + VARHDRSZ);
|
||||
@ -487,8 +486,10 @@ varchar(PG_FUNCTION_ARGS)
|
||||
{
|
||||
for (i = maxmblen; i < len - VARHDRSZ; i++)
|
||||
if (*(VARDATA(source) + i) != ' ')
|
||||
elog(ERROR, "value too long for type character varying(%d)",
|
||||
maxlen - VARHDRSZ);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
|
||||
errmsg("value too long for type character varying(%d)",
|
||||
maxlen - VARHDRSZ)));
|
||||
}
|
||||
|
||||
len = maxmblen + VARHDRSZ;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.101 2003/06/27 00:33:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.102 2003/07/27 04:53:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -80,7 +80,7 @@ static text *text_substring(Datum str,
|
||||
*
|
||||
* Non-printable characters must be passed as '\nnn' (octal) and are
|
||||
* converted to internal form. '\' must be passed as '\\'.
|
||||
* elog(ERROR, ...) if bad form.
|
||||
* ereport(ERROR, ...) if bad form.
|
||||
*
|
||||
* BUGS:
|
||||
* The input is scaned twice.
|
||||
@ -112,7 +112,9 @@ byteain(PG_FUNCTION_ARGS)
|
||||
/*
|
||||
* one backslash, not followed by 0 or ### valid octal
|
||||
*/
|
||||
elog(ERROR, "Bad input string for type bytea");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for bytea")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +152,9 @@ byteain(PG_FUNCTION_ARGS)
|
||||
* We should never get here. The first pass should not allow
|
||||
* it.
|
||||
*/
|
||||
elog(ERROR, "Bad input string for type bytea");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for bytea")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,20 +259,17 @@ textin(PG_FUNCTION_ARGS)
|
||||
text *result;
|
||||
int len;
|
||||
|
||||
char *ermsg;
|
||||
/* verify encoding */
|
||||
len = strlen(inputText);
|
||||
pg_verifymbstr(inputText, len, false);
|
||||
|
||||
len = strlen(inputText) + VARHDRSZ;
|
||||
result = (text *) palloc(len + VARHDRSZ);
|
||||
VARATT_SIZEP(result) = len + VARHDRSZ;
|
||||
|
||||
if ((ermsg = pg_verifymbstr(inputText, len - VARHDRSZ)))
|
||||
elog(ERROR, "%s", ermsg);
|
||||
|
||||
result = (text *) palloc(len);
|
||||
VARATT_SIZEP(result) = len;
|
||||
|
||||
memcpy(VARDATA(result), inputText, len - VARHDRSZ);
|
||||
memcpy(VARDATA(result), inputText, len);
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(VARDATA(result), len - VARHDRSZ, 0);
|
||||
convertstr(VARDATA(result), len, 0);
|
||||
#endif
|
||||
|
||||
PG_RETURN_TEXT_P(result);
|
||||
@ -435,8 +436,7 @@ text_length(Datum str)
|
||||
}
|
||||
|
||||
/* should never get here */
|
||||
elog(ERROR, "Invalid backend encoding; encoding max length "
|
||||
"is less than one.");
|
||||
elog(ERROR, "invalid backend encoding: encoding max length < 1");
|
||||
|
||||
/* not reached: suppress compiler warning */
|
||||
return 0;
|
||||
@ -582,7 +582,9 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
* to be before the start. SQL99 says to throw an error.
|
||||
*/
|
||||
if (E < S)
|
||||
elog(ERROR, "negative substring length not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SUBSTRING_ERROR),
|
||||
errmsg("negative substring length not allowed")));
|
||||
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if
|
||||
@ -644,7 +646,9 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
* to be before the start. SQL99 says to throw an error.
|
||||
*/
|
||||
if (E < S)
|
||||
elog(ERROR, "negative substring length not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SUBSTRING_ERROR),
|
||||
errmsg("negative substring length not allowed")));
|
||||
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if
|
||||
@ -718,8 +722,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid backend encoding; encoding max length "
|
||||
"is less than one.");
|
||||
elog(ERROR, "invalid backend encoding: encoding max length < 1");
|
||||
|
||||
/* not reached: suppress compiler warning */
|
||||
return PG_STR_GET_TEXT("");
|
||||
@ -821,8 +824,7 @@ text_position(Datum str, Datum search_str, int matchnum)
|
||||
pfree(ps2);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid backend encoding; encoding max length "
|
||||
"is less than one.");
|
||||
elog(ERROR, "invalid backend encoding: encoding max length < 1");
|
||||
|
||||
PG_RETURN_INT32(pos);
|
||||
}
|
||||
@ -1295,7 +1297,9 @@ bytea_substr(PG_FUNCTION_ARGS)
|
||||
* be before the start. SQL99 says to throw an error.
|
||||
*/
|
||||
if (E < S)
|
||||
elog(ERROR, "negative substring length not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SUBSTRING_ERROR),
|
||||
errmsg("negative substring length not allowed")));
|
||||
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if the
|
||||
@ -1388,8 +1392,10 @@ byteaGetByte(PG_FUNCTION_ARGS)
|
||||
len = VARSIZE(v) - VARHDRSZ;
|
||||
|
||||
if (n < 0 || n >= len)
|
||||
elog(ERROR, "byteaGetByte: index %d out of range [0..%d]",
|
||||
n, len - 1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("index %d out of valid range, 0..%d",
|
||||
n, len - 1)));
|
||||
|
||||
byte = ((unsigned char *) VARDATA(v))[n];
|
||||
|
||||
@ -1417,8 +1423,10 @@ byteaGetBit(PG_FUNCTION_ARGS)
|
||||
len = VARSIZE(v) - VARHDRSZ;
|
||||
|
||||
if (n < 0 || n >= len * 8)
|
||||
elog(ERROR, "byteaGetBit: index %d out of range [0..%d]",
|
||||
n, len * 8 - 1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("index %d out of valid range, 0..%d",
|
||||
n, len * 8 - 1)));
|
||||
|
||||
byteNo = n / 8;
|
||||
bitNo = n % 8;
|
||||
@ -1451,8 +1459,10 @@ byteaSetByte(PG_FUNCTION_ARGS)
|
||||
len = VARSIZE(v) - VARHDRSZ;
|
||||
|
||||
if (n < 0 || n >= len)
|
||||
elog(ERROR, "byteaSetByte: index %d out of range [0..%d]",
|
||||
n, len - 1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("index %d out of valid range, 0..%d",
|
||||
n, len - 1)));
|
||||
|
||||
/*
|
||||
* Make a copy of the original varlena.
|
||||
@ -1492,8 +1502,10 @@ byteaSetBit(PG_FUNCTION_ARGS)
|
||||
len = VARSIZE(v) - VARHDRSZ;
|
||||
|
||||
if (n < 0 || n >= len * 8)
|
||||
elog(ERROR, "byteaSetBit: index %d out of range [0..%d]",
|
||||
n, len * 8 - 1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("index %d out of valid range, 0..%d",
|
||||
n, len * 8 - 1)));
|
||||
|
||||
byteNo = n / 8;
|
||||
bitNo = n % 8;
|
||||
@ -1502,7 +1514,9 @@ byteaSetBit(PG_FUNCTION_ARGS)
|
||||
* sanity check!
|
||||
*/
|
||||
if (newBit != 0 && newBit != 1)
|
||||
elog(ERROR, "byteaSetBit: new bit must be 0 or 1");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("new bit must be 0 or 1")));
|
||||
|
||||
/*
|
||||
* Make a copy of the original varlena.
|
||||
@ -1607,10 +1621,14 @@ textToQualifiedNameList(text *textval, const char *caller)
|
||||
PointerGetDatum(textval)));
|
||||
|
||||
if (!SplitIdentifierString(rawname, '.', &namelist))
|
||||
elog(ERROR, "%s: invalid name syntax", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_NAME),
|
||||
errmsg("invalid name syntax")));
|
||||
|
||||
if (namelist == NIL)
|
||||
elog(ERROR, "%s: invalid name syntax", caller);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_NAME),
|
||||
errmsg("invalid name syntax")));
|
||||
|
||||
foreach(l, namelist)
|
||||
{
|
||||
@ -1992,7 +2010,9 @@ split_text(PG_FUNCTION_ARGS)
|
||||
|
||||
/* field number is 1 based */
|
||||
if (fldnum < 1)
|
||||
elog(ERROR, "field position must be > 0");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("field position must be greater than zero")));
|
||||
|
||||
start_posn = text_position(PointerGetDatum(inputstring),
|
||||
PointerGetDatum(fldsep),
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* conversion functions between pg_wchar and multibyte streams.
|
||||
* Tatsuo Ishii
|
||||
* $Id: wchar.c,v 1.31 2003/01/11 06:55:11 ishii Exp $
|
||||
* $Id: wchar.c,v 1.32 2003/07/27 04:53:11 tgl Exp $
|
||||
*
|
||||
* WIN1250 client encoding updated by Pavel Behal
|
||||
*
|
||||
@ -606,78 +606,78 @@ pg_encoding_max_length(int encoding)
|
||||
}
|
||||
|
||||
#ifndef FRONTEND
|
||||
|
||||
/*
|
||||
* Verify mbstr to make sure that it has a valid character sequence.
|
||||
* mbstr is not necessarily NULL terminated. length of mbstr is
|
||||
* specified by len. If an error was found, returns an error message.
|
||||
* Note that the message is kept in a static buffer, the next invocation
|
||||
* might break the message.
|
||||
* If no error was found, this function returns NULL.
|
||||
* mbstr is not necessarily NULL terminated; length of mbstr is
|
||||
* specified by len.
|
||||
*
|
||||
* If OK, return TRUE. If a problem is found, return FALSE when noError is
|
||||
* true; when noError is false, ereport() a descriptive message.
|
||||
*/
|
||||
char *
|
||||
pg_verifymbstr(const unsigned char *mbstr, int len)
|
||||
bool
|
||||
pg_verifymbstr(const unsigned char *mbstr, int len, bool noError)
|
||||
{
|
||||
int l;
|
||||
int i,
|
||||
j;
|
||||
static char buf[256];
|
||||
int slen = 0;
|
||||
int i;
|
||||
int encoding;
|
||||
|
||||
/* we do not check single byte encodings */
|
||||
/* we do not need any check in single-byte encodings */
|
||||
if (pg_database_encoding_max_length() <= 1)
|
||||
return NULL;
|
||||
return true;
|
||||
|
||||
encoding = GetDatabaseEncoding();
|
||||
|
||||
while (len > 0 && *mbstr)
|
||||
{
|
||||
/* special UTF-8 check */
|
||||
if (GetDatabaseEncoding() == PG_UTF8 &&
|
||||
(*mbstr & 0xf8) == 0xf0)
|
||||
if (encoding == PG_UTF8 && (*mbstr & 0xf8) == 0xf0)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supported");
|
||||
return (buf);
|
||||
if (noError)
|
||||
return false;
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
|
||||
errmsg("UNICODE characters >= 0x10000 are not supported")));
|
||||
}
|
||||
|
||||
l = pg_mblen(mbstr);
|
||||
|
||||
/* multibyte letter? */
|
||||
if (l > 1)
|
||||
for (i = 1; i < l; i++)
|
||||
{
|
||||
for (i = 1; i < l; i++)
|
||||
/*
|
||||
* we expect that every multibyte char consists of bytes
|
||||
* having the 8th bit set
|
||||
*/
|
||||
if (i >= len || (mbstr[i] & 0x80) == 0)
|
||||
{
|
||||
if (i > len || *(mbstr + i) == '\0' ||
|
||||
char buf[8 * 2 + 1];
|
||||
char *p = buf;
|
||||
int j,
|
||||
jlimit;
|
||||
|
||||
/*
|
||||
* we assume that every multibyte letter consists of bytes
|
||||
* being the 8th bit set
|
||||
*/
|
||||
((*(mbstr + i) & 0x80) == 0))
|
||||
if (noError)
|
||||
return false;
|
||||
|
||||
jlimit = Min(l, len);
|
||||
jlimit = Min(jlimit, 8); /* prevent buffer overrun */
|
||||
|
||||
for (j = 0; j < jlimit; j++)
|
||||
{
|
||||
int remains = sizeof(buf);
|
||||
char *p = buf;
|
||||
|
||||
slen = snprintf(p, remains, "Invalid %s character sequence found (0x",
|
||||
GetDatabaseEncodingName());
|
||||
p += slen;
|
||||
remains -= slen;
|
||||
|
||||
i = ((*(mbstr + i) & 0x80) == 0) ? l : i;
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
slen = snprintf(p, remains, "%02x",
|
||||
*(mbstr + j));
|
||||
p += slen;
|
||||
remains -= slen;
|
||||
}
|
||||
snprintf(p, remains, ")");
|
||||
return (buf);
|
||||
p += sprintf(p, "%02x", mbstr[j]);
|
||||
}
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
|
||||
errmsg("invalid %s character sequence: 0x%s",
|
||||
GetDatabaseEncodingName(), buf)));
|
||||
}
|
||||
}
|
||||
|
||||
len -= l;
|
||||
mbstr += l;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: pg_wchar.h,v 1.46 2003/06/02 18:59:25 momjian Exp $ */
|
||||
/* $Id: pg_wchar.h,v 1.47 2003/07/27 04:53:11 tgl Exp $ */
|
||||
|
||||
#ifndef PG_WCHAR_H
|
||||
#define PG_WCHAR_H
|
||||
@ -323,7 +323,7 @@ extern void LocalToUtf(unsigned char *iso, unsigned char *utf,
|
||||
extern void UtfToLocal(unsigned char *utf, unsigned char *iso,
|
||||
pg_utf_to_local *map, int size, int len);
|
||||
|
||||
extern char *pg_verifymbstr(const unsigned char *mbstr, int len);
|
||||
extern bool pg_verifymbstr(const unsigned char *mbstr, int len, bool noError);
|
||||
|
||||
extern void pg_ascii2mic(unsigned char *src, unsigned char *dest, int len);
|
||||
extern void pg_mic2ascii(unsigned char *src, unsigned char *dest, int len);
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: elog.h,v 1.58 2003/07/25 20:18:00 tgl Exp $
|
||||
* $Id: elog.h,v 1.59 2003/07/27 04:53:11 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -131,6 +131,7 @@
|
||||
#define ERRCODE_ARRAY_SUBSCRIPT_ERROR ERRCODE_ARRAY_ELEMENT_ERROR
|
||||
#define ERRCODE_CHARACTER_NOT_IN_REPERTOIRE MAKE_SQLSTATE('2','2', '0','2','1')
|
||||
#define ERRCODE_DATETIME_FIELD_OVERFLOW MAKE_SQLSTATE('2','2', '0','0','8')
|
||||
#define ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ERRCODE_DATETIME_FIELD_OVERFLOW
|
||||
#define ERRCODE_DIVISION_BY_ZERO MAKE_SQLSTATE('2','2', '0','1','2')
|
||||
#define ERRCODE_ERROR_IN_ASSIGNMENT MAKE_SQLSTATE('2','2', '0','0','5')
|
||||
#define ERRCODE_ESCAPE_CHARACTER_CONFLICT MAKE_SQLSTATE('2','2', '0','0','B')
|
||||
@ -157,10 +158,11 @@
|
||||
#define ERRCODE_TRIM_ERROR MAKE_SQLSTATE('2','2', '0','2','7')
|
||||
#define ERRCODE_UNTERMINATED_C_STRING MAKE_SQLSTATE('2','2', '0','2','4')
|
||||
#define ERRCODE_ZERO_LENGTH_CHARACTER_STRING MAKE_SQLSTATE('2','2', '0','0','F')
|
||||
#define ERRCODE_BAD_COPY_FILE_FORMAT MAKE_SQLSTATE('2','2', 'P','0','1')
|
||||
#define ERRCODE_INVALID_BINARY_REPRESENTATION MAKE_SQLSTATE('2','2', 'P','0','2')
|
||||
#define ERRCODE_FLOATING_POINT_EXCEPTION MAKE_SQLSTATE('2','2', 'P','0','3')
|
||||
#define ERRCODE_UNTRANSLATABLE_CHARACTER MAKE_SQLSTATE('2','2', 'P','0','4')
|
||||
#define ERRCODE_FLOATING_POINT_EXCEPTION MAKE_SQLSTATE('2','2', 'P','0','1')
|
||||
#define ERRCODE_INVALID_TEXT_REPRESENTATION MAKE_SQLSTATE('2','2', 'P','0','2')
|
||||
#define ERRCODE_INVALID_BINARY_REPRESENTATION MAKE_SQLSTATE('2','2', 'P','0','3')
|
||||
#define ERRCODE_BAD_COPY_FILE_FORMAT MAKE_SQLSTATE('2','2', 'P','0','4')
|
||||
#define ERRCODE_UNTRANSLATABLE_CHARACTER MAKE_SQLSTATE('2','2', 'P','0','5')
|
||||
|
||||
/* Class 23 - Integrity Constraint Violation */
|
||||
#define ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('2','3', '0','0','0')
|
||||
|
@ -28,12 +28,12 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
||||
-- what happens if we specify slightly misformatted abstime?
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
||||
ERROR: Bad abstime external representation 'Feb 35, 1946 10:00:00'
|
||||
ERROR: invalid input syntax for abstime: "Feb 35, 1946 10:00:00"
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
||||
ERROR: Bad abstime external representation 'Feb 28, 1984 25:08:10'
|
||||
ERROR: invalid input syntax for abstime: "Feb 28, 1984 25:08:10"
|
||||
-- badly formatted abstimes: these should result in invalid abstimes
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
||||
ERROR: Bad abstime external representation 'bad date format'
|
||||
ERROR: invalid input syntax for abstime: "bad date format"
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
|
||||
-- test abstime operators
|
||||
SELECT '' AS eight, ABSTIME_TBL.*;
|
||||
|
@ -28,12 +28,12 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
||||
-- what happens if we specify slightly misformatted abstime?
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
||||
ERROR: Bad abstime external representation 'Feb 35, 1946 10:00:00'
|
||||
ERROR: invalid input syntax for abstime: "Feb 35, 1946 10:00:00"
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
||||
ERROR: Bad abstime external representation 'Feb 28, 1984 25:08:10'
|
||||
ERROR: invalid input syntax for abstime: "Feb 28, 1984 25:08:10"
|
||||
-- badly formatted abstimes: these should result in invalid abstimes
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
||||
ERROR: Bad abstime external representation 'bad date format'
|
||||
ERROR: invalid input syntax for abstime: "bad date format"
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
|
||||
-- test abstime operators
|
||||
SELECT '' AS eight, ABSTIME_TBL.*;
|
||||
|
@ -709,7 +709,7 @@ select * from def_test;
|
||||
|
||||
-- set defaults to an incorrect type: this should fail
|
||||
alter table def_test alter column c1 set default 'wrong_datatype';
|
||||
ERROR: pg_atoi: error in "wrong_datatype": can't parse "wrong_datatype"
|
||||
ERROR: invalid input syntax for integer: "wrong_datatype"
|
||||
alter table def_test alter column c2 set default 20;
|
||||
-- set defaults on a non-existent column: this should fail
|
||||
alter table def_test alter column c3 set default 30;
|
||||
|
@ -6,12 +6,12 @@
|
||||
--
|
||||
CREATE TABLE BIT_TABLE(b BIT(11));
|
||||
INSERT INTO BIT_TABLE VALUES (B'10'); -- too short
|
||||
ERROR: Bit string length 2 does not match type BIT(11)
|
||||
ERROR: bit string length 2 does not match type bit(11)
|
||||
INSERT INTO BIT_TABLE VALUES (B'00000000000');
|
||||
INSERT INTO BIT_TABLE VALUES (B'11011000000');
|
||||
INSERT INTO BIT_TABLE VALUES (B'01010101010');
|
||||
INSERT INTO BIT_TABLE VALUES (B'101011111010'); -- too long
|
||||
ERROR: Bit string length 12 does not match type BIT(11)
|
||||
ERROR: bit string length 12 does not match type bit(11)
|
||||
--INSERT INTO BIT_TABLE VALUES ('X554');
|
||||
--INSERT INTO BIT_TABLE VALUES ('X555');
|
||||
SELECT * FROM BIT_TABLE;
|
||||
@ -28,7 +28,7 @@ INSERT INTO VARBIT_TABLE VALUES (B'0');
|
||||
INSERT INTO VARBIT_TABLE VALUES (B'010101');
|
||||
INSERT INTO VARBIT_TABLE VALUES (B'01010101010');
|
||||
INSERT INTO VARBIT_TABLE VALUES (B'101011111010'); -- too long
|
||||
ERROR: Bit string too long for type BIT VARYING(11)
|
||||
ERROR: bit string too long for type bit varying(11)
|
||||
--INSERT INTO VARBIT_TABLE VALUES ('X554');
|
||||
--INSERT INTO VARBIT_TABLE VALUES ('X555');
|
||||
SELECT * FROM VARBIT_TABLE;
|
||||
@ -212,11 +212,11 @@ SELECT a,a<<4 AS "a<<4",b,b>>2 AS "b>>2" FROM bit_table;
|
||||
DROP TABLE bit_table;
|
||||
-- The following should fail
|
||||
select B'001' & B'10';
|
||||
ERROR: Cannot AND bit strings of different sizes
|
||||
ERROR: cannot AND bit strings of different sizes
|
||||
select B'0111' | B'011';
|
||||
ERROR: Cannot OR bit strings of different sizes
|
||||
ERROR: cannot OR bit strings of different sizes
|
||||
select B'0010' # B'011101';
|
||||
ERROR: Cannot XOR bit strings of different sizes
|
||||
ERROR: cannot XOR bit strings of different sizes
|
||||
-- More position tests, checking all the boundary cases
|
||||
SELECT POSITION(B'1010' IN B'0000101'); -- 0
|
||||
position
|
||||
|
@ -112,7 +112,7 @@ INSERT INTO BOOLTBL2 (f1) VALUES (bool 'FALSE');
|
||||
-- For pre-v6.3 this evaluated to false - thomas 1997-10-23
|
||||
INSERT INTO BOOLTBL2 (f1)
|
||||
VALUES (bool 'XXX');
|
||||
ERROR: Bad boolean external representation 'XXX'
|
||||
ERROR: invalid input syntax for boolean: "XXX"
|
||||
-- BOOLTBL2 should be full of false's at this point
|
||||
SELECT '' AS f_4, BOOLTBL2.*;
|
||||
f_4 | f1
|
||||
|
@ -24,9 +24,9 @@ INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
|
||||
INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)');
|
||||
-- badly formatted box inputs
|
||||
INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
|
||||
ERROR: Bad box external representation '(2.3, 4.5)'
|
||||
ERROR: invalid input syntax for box: "(2.3, 4.5)"
|
||||
INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
|
||||
ERROR: Bad box external representation 'asdfasdf(ad'
|
||||
ERROR: invalid input syntax for box: "asdfasdf(ad"
|
||||
SELECT '' AS four, BOX_TBL.*;
|
||||
four | f1
|
||||
------+---------------------
|
||||
|
@ -10,11 +10,11 @@ INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
|
||||
INSERT INTO CIRCLE_TBL VALUES ('<(100,1),115>');
|
||||
-- bad values
|
||||
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
|
||||
ERROR: Bad circle external representation '<(-100,0),-100>'
|
||||
ERROR: invalid input syntax for circle: "<(-100,0),-100>"
|
||||
INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
|
||||
ERROR: Bad circle external representation '1abc,3,5'
|
||||
ERROR: invalid input syntax for circle: "1abc,3,5"
|
||||
INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)');
|
||||
ERROR: Bad circle external representation '(3,(1,2),3)'
|
||||
ERROR: invalid input syntax for circle: "(3,(1,2),3)"
|
||||
SELECT * FROM CIRCLE_TBL;
|
||||
f1
|
||||
----------------
|
||||
|
@ -34,7 +34,7 @@ COPY x (a, b, c, d, e, d, c) from stdin;
|
||||
ERROR: attribute "d" specified more than once
|
||||
-- missing data: should fail
|
||||
COPY x from stdin;
|
||||
ERROR: pg_atoi: zero-length string
|
||||
ERROR: invalid input syntax for integer: ""
|
||||
CONTEXT: COPY FROM, line 1
|
||||
COPY x from stdin;
|
||||
ERROR: missing data for column "e"
|
||||
|
@ -10,7 +10,7 @@ INSERT INTO DATE_TBL VALUES ('1996-03-01');
|
||||
INSERT INTO DATE_TBL VALUES ('1996-03-02');
|
||||
INSERT INTO DATE_TBL VALUES ('1997-02-28');
|
||||
INSERT INTO DATE_TBL VALUES ('1997-02-29');
|
||||
ERROR: Bad date external representation '1997-02-29'
|
||||
ERROR: invalid input syntax for date: "1997-02-29"
|
||||
INSERT INTO DATE_TBL VALUES ('1997-03-01');
|
||||
INSERT INTO DATE_TBL VALUES ('1997-03-02');
|
||||
INSERT INTO DATE_TBL VALUES ('2000-04-01');
|
||||
|
@ -9,13 +9,13 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e+20');
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20');
|
||||
-- test for over and under flow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e40');
|
||||
ERROR: Bad float4 input format -- overflow
|
||||
ERROR: float4 value out of range: overflow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e40');
|
||||
ERROR: Bad float4 input format -- overflow
|
||||
ERROR: float4 value out of range: overflow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-40');
|
||||
ERROR: Bad float4 input format -- underflow
|
||||
ERROR: float4 value out of range: underflow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-40');
|
||||
ERROR: Bad float4 input format -- underflow
|
||||
ERROR: float4 value out of range: underflow
|
||||
SELECT '' AS five, FLOAT4_TBL.*;
|
||||
five | f1
|
||||
------+--------------
|
||||
|
@ -9,13 +9,13 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e+20');
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20');
|
||||
-- test for over and under flow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e40');
|
||||
ERROR: Bad float4 input format -- overflow
|
||||
ERROR: float4 value out of range: overflow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e40');
|
||||
ERROR: Bad float4 input format -- overflow
|
||||
ERROR: float4 value out of range: overflow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-40');
|
||||
ERROR: Bad float4 input format -- underflow
|
||||
ERROR: float4 value out of range: underflow
|
||||
INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-40');
|
||||
ERROR: Bad float4 input format -- underflow
|
||||
ERROR: float4 value out of range: underflow
|
||||
SELECT '' AS five, FLOAT4_TBL.*;
|
||||
five | f1
|
||||
------+-------------
|
||||
|
@ -247,15 +247,15 @@ UPDATE FLOAT8_TBL
|
||||
SET f1 = FLOAT8_TBL.f1 * '-1'
|
||||
WHERE FLOAT8_TBL.f1 > '0.0';
|
||||
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
|
||||
ERROR: Bad float8 input format -- overflow
|
||||
ERROR: float8 value out of range: overflow
|
||||
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
|
||||
ERROR: pow() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
|
||||
ERROR: can't take log of zero
|
||||
ERROR: cannot take log of zero
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
|
||||
ERROR: can't take log of a negative number
|
||||
ERROR: cannot take log of a negative number
|
||||
SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
|
||||
ERROR: exp() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
|
||||
ERROR: division by zero
|
||||
SELECT '' AS five, FLOAT8_TBL.*;
|
||||
@ -270,13 +270,13 @@ SELECT '' AS five, FLOAT8_TBL.*;
|
||||
|
||||
-- test for over- and underflow
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
|
||||
ERROR: Input '10e400' is out of range for float8
|
||||
ERROR: "10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
|
||||
ERROR: Input '-10e400' is out of range for float8
|
||||
ERROR: "-10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
|
||||
ERROR: Input '10e-400' is out of range for float8
|
||||
ERROR: "10e-400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
|
||||
ERROR: Input '-10e-400' is out of range for float8
|
||||
ERROR: "-10e-400" is out of range for float8
|
||||
-- maintain external table consistency across platforms
|
||||
-- delete all values and reinsert well-behaved ones
|
||||
DELETE FROM FLOAT8_TBL;
|
||||
|
@ -247,15 +247,16 @@ UPDATE FLOAT8_TBL
|
||||
SET f1 = FLOAT8_TBL.f1 * '-1'
|
||||
WHERE FLOAT8_TBL.f1 > '0.0';
|
||||
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
|
||||
ERROR: floating point exception! The last floating point operation either exceeded legal ranges or was a divide by zero
|
||||
ERROR: floating-point exception
|
||||
DETAIL: An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.
|
||||
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
|
||||
ERROR: pow() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
|
||||
ERROR: can't take log of zero
|
||||
ERROR: cannot take log of zero
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
|
||||
ERROR: can't take log of a negative number
|
||||
ERROR: cannot take log of a negative number
|
||||
SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
|
||||
ERROR: exp() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
|
||||
ERROR: division by zero
|
||||
SELECT '' AS five, FLOAT8_TBL.*;
|
||||
@ -270,13 +271,13 @@ SELECT '' AS five, FLOAT8_TBL.*;
|
||||
|
||||
-- test for over- and underflow
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
|
||||
ERROR: Input '10e400' is out of range for float8
|
||||
ERROR: "10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
|
||||
ERROR: Input '-10e400' is out of range for float8
|
||||
ERROR: "-10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
|
||||
ERROR: Input '10e-400' is out of range for float8
|
||||
ERROR: "10e-400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
|
||||
ERROR: Input '-10e-400' is out of range for float8
|
||||
ERROR: "-10e-400" is out of range for float8
|
||||
-- maintain external table consistency across platforms
|
||||
-- delete all values and reinsert well-behaved ones
|
||||
DELETE FROM FLOAT8_TBL;
|
||||
|
@ -247,15 +247,15 @@ UPDATE FLOAT8_TBL
|
||||
SET f1 = FLOAT8_TBL.f1 * '-1'
|
||||
WHERE FLOAT8_TBL.f1 > '0.0';
|
||||
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
|
||||
ERROR: Bad float8 input format -- overflow
|
||||
ERROR: float8 value out of range: overflow
|
||||
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
|
||||
ERROR: pow() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
|
||||
ERROR: can't take log of zero
|
||||
ERROR: cannot take log of zero
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
|
||||
ERROR: can't take log of a negative number
|
||||
ERROR: cannot take log of a negative number
|
||||
SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
|
||||
ERROR: exp() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
|
||||
ERROR: division by zero
|
||||
SELECT '' AS five, FLOAT8_TBL.*;
|
||||
@ -270,9 +270,9 @@ SELECT '' AS five, FLOAT8_TBL.*;
|
||||
|
||||
-- test for over- and underflow
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
|
||||
ERROR: Input '10e400' is out of range for float8
|
||||
ERROR: "10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
|
||||
ERROR: Input '-10e400' is out of range for float8
|
||||
ERROR: "-10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
|
||||
-- maintain external table consistency across platforms
|
||||
|
@ -247,15 +247,15 @@ UPDATE FLOAT8_TBL
|
||||
SET f1 = FLOAT8_TBL.f1 * '-1'
|
||||
WHERE FLOAT8_TBL.f1 > '0.0';
|
||||
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
|
||||
ERROR: Bad float8 input format -- overflow
|
||||
ERROR: float8 value out of range: overflow
|
||||
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
|
||||
ERROR: pow() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
|
||||
ERROR: can't take log of zero
|
||||
ERROR: cannot take log of zero
|
||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
|
||||
ERROR: can't take log of a negative number
|
||||
ERROR: cannot take log of a negative number
|
||||
SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
|
||||
ERROR: exp() result is out of range
|
||||
ERROR: result is out of range
|
||||
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
|
||||
ERROR: division by zero
|
||||
SELECT '' AS five, FLOAT8_TBL.*;
|
||||
@ -270,13 +270,13 @@ SELECT '' AS five, FLOAT8_TBL.*;
|
||||
|
||||
-- test for over- and underflow
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
|
||||
ERROR: Input '10e400' is out of range for float8
|
||||
ERROR: "10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
|
||||
ERROR: Input '-10e400' is out of range for float8
|
||||
ERROR: "-10e400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
|
||||
ERROR: Input '10e-400' is out of range for float8
|
||||
ERROR: "10e-400" is out of range for float8
|
||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
|
||||
ERROR: Input '-10e-400' is out of range for float8
|
||||
ERROR: "-10e-400" is out of range for float8
|
||||
-- maintain external table consistency across platforms
|
||||
-- delete all values and reinsert well-behaved ones
|
||||
DELETE FROM FLOAT8_TBL;
|
||||
|
@ -2350,7 +2350,7 @@ SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
|
||||
|
||||
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
|
||||
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
|
||||
ERROR: Unable to convert abstime 'invalid' to timestamp
|
||||
ERROR: cannot convert "invalid" abstime to timestamp
|
||||
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
|
||||
FROM INTERVAL_TBL;
|
||||
ten | interval | reltime
|
||||
|
@ -2350,7 +2350,7 @@ SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
|
||||
|
||||
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
|
||||
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
|
||||
ERROR: Unable to convert abstime 'invalid' to timestamp
|
||||
ERROR: cannot convert "invalid" abstime to timestamp
|
||||
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
|
||||
FROM INTERVAL_TBL;
|
||||
ten | interval | reltime
|
||||
|
@ -2350,7 +2350,7 @@ SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
|
||||
|
||||
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
|
||||
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
|
||||
ERROR: Unable to convert abstime 'invalid' to timestamp
|
||||
ERROR: cannot convert "invalid" abstime to timestamp
|
||||
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
|
||||
FROM INTERVAL_TBL;
|
||||
ten | interval | reltime
|
||||
|
@ -24,16 +24,19 @@ INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff');
|
||||
INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24');
|
||||
-- check that CIDR rejects invalid input:
|
||||
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/24', '192.168.1.226');
|
||||
ERROR: invalid CIDR value '192.168.1.2/24': has bits set to right of mask
|
||||
ERROR: invalid cidr value: "192.168.1.2/24"
|
||||
DETAIL: Value has bits set to right of mask.
|
||||
INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4');
|
||||
ERROR: invalid CIDR value '1234::1234::1234'
|
||||
ERROR: invalid input syntax for cidr: "1234::1234::1234"
|
||||
-- check that CIDR rejects invalid input when converting from text:
|
||||
INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/24'), '192.168.1.226');
|
||||
ERROR: invalid CIDR value '192.168.1.2/24': has bits set to right of mask
|
||||
ERROR: invalid cidr value: "192.168.1.2/24"
|
||||
DETAIL: Value has bits set to right of mask.
|
||||
INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226');
|
||||
ERROR: invalid CIDR value 'ffff:ffff:ffff:ffff::/24': has bits set to right of mask
|
||||
ERROR: invalid cidr value: "ffff:ffff:ffff:ffff::/24"
|
||||
DETAIL: Value has bits set to right of mask.
|
||||
SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL;
|
||||
ten | cidr | inet
|
||||
ten | cidr | inet
|
||||
-----+--------------------+------------------
|
||||
| 192.168.1.0/24 | 192.168.1.226/24
|
||||
| 192.168.1.0/24 | 192.168.1.226
|
||||
@ -56,7 +59,7 @@ SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL;
|
||||
|
||||
-- now test some support functions
|
||||
SELECT '' AS ten, i AS inet, host(i), text(i), family(i) FROM INET_TBL;
|
||||
ten | inet | host | text | family
|
||||
ten | inet | host | text | family
|
||||
-----+------------------+---------------+------------------+--------
|
||||
| 192.168.1.226/24 | 192.168.1.226 | 192.168.1.226/24 | 4
|
||||
| 192.168.1.226 | 192.168.1.226 | 192.168.1.226/32 | 4
|
||||
@ -79,7 +82,7 @@ SELECT '' AS ten, i AS inet, host(i), text(i), family(i) FROM INET_TBL;
|
||||
|
||||
SELECT '' AS ten, c AS cidr, broadcast(c),
|
||||
i AS inet, broadcast(i) FROM INET_TBL;
|
||||
ten | cidr | broadcast | inet | broadcast
|
||||
ten | cidr | broadcast | inet | broadcast
|
||||
-----+--------------------+------------------+------------------+---------------------------------------
|
||||
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226/24 | 192.168.1.255/24
|
||||
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226 | 192.168.1.226
|
||||
@ -102,7 +105,7 @@ SELECT '' AS ten, c AS cidr, broadcast(c),
|
||||
|
||||
SELECT '' AS ten, c AS cidr, network(c) AS "network(cidr)",
|
||||
i AS inet, network(i) AS "network(inet)" FROM INET_TBL;
|
||||
ten | cidr | network(cidr) | inet | network(inet)
|
||||
ten | cidr | network(cidr) | inet | network(inet)
|
||||
-----+--------------------+--------------------+------------------+------------------
|
||||
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226/24 | 192.168.1.0/24
|
||||
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226 | 192.168.1.226/32
|
||||
@ -171,7 +174,7 @@ SELECT '' AS ten, i, c,
|
||||
i << c AS sb, i <<= c AS sbe,
|
||||
i >> c AS sup, i >>= c AS spe
|
||||
FROM INET_TBL;
|
||||
ten | i | c | lt | le | eq | ge | gt | ne | sb | sbe | sup | spe
|
||||
ten | i | c | lt | le | eq | ge | gt | ne | sb | sbe | sup | spe
|
||||
-----+------------------+--------------------+----+----+----+----+----+----+----+-----+-----+-----
|
||||
| 192.168.1.226/24 | 192.168.1.0/24 | f | f | f | t | t | t | f | t | f | t
|
||||
| 192.168.1.226 | 192.168.1.0/24 | f | f | f | t | t | t | t | t | f | f
|
||||
|
@ -8,15 +8,15 @@ INSERT INTO INT2_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
ERROR: invalid input syntax for integer: "34.5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('32767');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
ERROR: pg_atoi: error reading "100000": Numerical result out of range
|
||||
ERROR: 100000 is out of range for int2
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
ERROR: invalid input syntax for integer: "asdf"
|
||||
SELECT '' AS five, INT2_TBL.*;
|
||||
five | f1
|
||||
------+--------
|
||||
|
@ -8,15 +8,15 @@ INSERT INTO INT4_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
ERROR: invalid input syntax for integer: "34.5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
|
||||
ERROR: pg_atoi: error reading "1000000000000": Numerical result out of range
|
||||
ERROR: 1000000000000 is out of range for int4
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
ERROR: invalid input syntax for integer: "asdf"
|
||||
SELECT '' AS five, INT4_TBL.*;
|
||||
five | f1
|
||||
------+-------------
|
||||
|
@ -58,9 +58,9 @@ INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months');
|
||||
INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months 12 hours');
|
||||
-- badly formatted interval
|
||||
INSERT INTO INTERVAL_TBL (f1) VALUES ('badly formatted interval');
|
||||
ERROR: Bad interval external representation 'badly formatted interval'
|
||||
ERROR: invalid input syntax for interval: "badly formatted interval"
|
||||
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago');
|
||||
ERROR: Bad interval external representation '@ 30 eons ago'
|
||||
ERROR: invalid input syntax for interval: "@ 30 eons ago"
|
||||
-- test interval operators
|
||||
SELECT '' AS ten, INTERVAL_TBL.*;
|
||||
ten | f1
|
||||
|
@ -11,13 +11,13 @@ INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]');
|
||||
INSERT INTO LSEG_TBL VALUES ('(11,22,33,44)');
|
||||
-- bad values for parser testing
|
||||
INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)');
|
||||
ERROR: Bad lseg external representation '(3asdf,2 ,3,4r2)'
|
||||
ERROR: invalid input syntax for lseg: "(3asdf,2 ,3,4r2)"
|
||||
INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4');
|
||||
ERROR: Bad lseg external representation '[1,2,3, 4'
|
||||
ERROR: invalid input syntax for lseg: "[1,2,3, 4"
|
||||
INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');
|
||||
ERROR: Bad lseg external representation '[(,2),(3,4)]'
|
||||
ERROR: invalid input syntax for lseg: "[(,2),(3,4)]"
|
||||
INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');
|
||||
ERROR: Bad lseg external representation '[(1,2),(3,4)'
|
||||
ERROR: invalid input syntax for lseg: "[(1,2),(3,4)"
|
||||
select * from LSEG_TBL;
|
||||
s
|
||||
-------------------------------
|
||||
|
@ -675,11 +675,13 @@ CREATE TABLE fract_only (id int, val numeric(4,4));
|
||||
INSERT INTO fract_only VALUES (1, '0.0');
|
||||
INSERT INTO fract_only VALUES (2, '0.1');
|
||||
INSERT INTO fract_only VALUES (3, '1.0'); -- should fail
|
||||
ERROR: overflow on numeric ABS(value) >= 10^0 for field with precision 4 scale 4
|
||||
ERROR: numeric field overflow
|
||||
DETAIL: ABS(value) >= 10^0 for field with precision 4, scale 4.
|
||||
INSERT INTO fract_only VALUES (4, '-0.9999');
|
||||
INSERT INTO fract_only VALUES (5, '0.99994');
|
||||
INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail
|
||||
ERROR: overflow on numeric ABS(value) >= 10^0 for field with precision 4 scale 4
|
||||
ERROR: numeric field overflow
|
||||
DETAIL: ABS(value) >= 10^0 for field with precision 4, scale 4.
|
||||
INSERT INTO fract_only VALUES (7, '0.00001');
|
||||
INSERT INTO fract_only VALUES (8, '0.00017');
|
||||
SELECT * FROM fract_only;
|
||||
|
@ -10,9 +10,9 @@ INSERT INTO OID_TBL(f1) VALUES ('99999999');
|
||||
INSERT INTO OID_TBL(f1) VALUES ('');
|
||||
-- bad inputs
|
||||
INSERT INTO OID_TBL(f1) VALUES ('asdfasd');
|
||||
ERROR: oidin: error in "asdfasd": can't parse "asdfasd"
|
||||
ERROR: invalid input syntax for OID: "asdfasd"
|
||||
INSERT INTO OID_TBL(f1) VALUES ('99asdfasd');
|
||||
ERROR: oidin: error in "99asdfasd": can't parse "asdfasd"
|
||||
ERROR: invalid input syntax for OID: "99asdfasd"
|
||||
SELECT '' AS six, OID_TBL.*;
|
||||
six | f1
|
||||
-----+------------
|
||||
|
@ -13,9 +13,9 @@ INSERT INTO PATH_TBL VALUES ('[11,12,13,14]');
|
||||
INSERT INTO PATH_TBL VALUES ('(11,12,13,14)');
|
||||
-- bad values for parser testing
|
||||
INSERT INTO PATH_TBL VALUES ('[(,2),(3,4)]');
|
||||
ERROR: Bad path external representation '[(,2),(3,4)]'
|
||||
ERROR: invalid input syntax for path: "[(,2),(3,4)]"
|
||||
INSERT INTO PATH_TBL VALUES ('[(1,2),(3,4)');
|
||||
ERROR: Bad path external representation '[(1,2),(3,4)'
|
||||
ERROR: invalid input syntax for path: "[(1,2),(3,4)"
|
||||
SELECT f1 FROM PATH_TBL;
|
||||
f1
|
||||
---------------------------
|
||||
|
@ -9,12 +9,12 @@ INSERT INTO POINT_TBL(f1) VALUES ('(5.1, 34.5)');
|
||||
INSERT INTO POINT_TBL(f1) VALUES ('(-5.0,-12.0)');
|
||||
-- bad format points
|
||||
INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf');
|
||||
ERROR: Bad point external representation 'asdfasdf'
|
||||
ERROR: invalid input syntax for point: "asdfasdf"
|
||||
INSERT INTO POINT_TBL(f1) VALUES ('10.0,10.0');
|
||||
INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)');
|
||||
ERROR: Bad point external representation '(10.0 10.0)'
|
||||
ERROR: invalid input syntax for point: "(10.0 10.0)"
|
||||
INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0');
|
||||
ERROR: Bad point external representation '(10.0,10.0'
|
||||
ERROR: invalid input syntax for point: "(10.0,10.0"
|
||||
SELECT '' AS six, POINT_TBL.*;
|
||||
six | f1
|
||||
-----+------------
|
||||
|
@ -21,15 +21,15 @@ INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,0.0)');
|
||||
INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,1.0),(0.0,1.0)');
|
||||
-- bad polygon input strings
|
||||
INSERT INTO POLYGON_TBL(f1) VALUES ('0.0');
|
||||
ERROR: Bad polygon external representation '0.0'
|
||||
ERROR: invalid input syntax for polygon: "0.0"
|
||||
INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0 0.0');
|
||||
ERROR: Bad polygon external representation '(0.0 0.0'
|
||||
ERROR: invalid input syntax for polygon: "(0.0 0.0"
|
||||
INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2)');
|
||||
ERROR: Bad polygon external representation '(0,1,2)'
|
||||
ERROR: invalid input syntax for polygon: "(0,1,2)"
|
||||
INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3');
|
||||
ERROR: Bad polygon external representation '(0,1,2,3'
|
||||
ERROR: invalid input syntax for polygon: "(0,1,2,3"
|
||||
INSERT INTO POLYGON_TBL(f1) VALUES ('asdf');
|
||||
ERROR: Bad polygon external representation 'asdf'
|
||||
ERROR: invalid input syntax for polygon: "asdf"
|
||||
SELECT '' AS four, POLYGON_TBL.*;
|
||||
four | f1
|
||||
------+---------------------
|
||||
|
@ -286,7 +286,7 @@ ERROR: relation "pg_shad" does not exist
|
||||
select has_table_privilege('nosuchuser','pg_shadow','select');
|
||||
ERROR: user "nosuchuser" does not exist
|
||||
select has_table_privilege('pg_shadow','sel');
|
||||
ERROR: has_table_privilege: invalid privilege type sel
|
||||
ERROR: unrecognized privilege type: "sel"
|
||||
select has_table_privilege(-999999,'pg_shadow','update');
|
||||
ERROR: user with ID 4293967297 does not exist
|
||||
select has_table_privilege(1,'rule');
|
||||
@ -561,7 +561,8 @@ SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- true
|
||||
(1 row)
|
||||
|
||||
REVOKE SELECT ON atest4 FROM regressuser2; -- fail
|
||||
ERROR: dependent privileges exist (use CASCADE to revoke them too)
|
||||
ERROR: dependent privileges exist
|
||||
HINT: Use CASCADE to revoke them too.
|
||||
REVOKE GRANT OPTION FOR SELECT ON atest4 FROM regressuser2 CASCADE; -- ok
|
||||
SELECT has_table_privilege('regressuser2', 'atest4', 'SELECT'); -- true
|
||||
has_table_privilege
|
||||
|
@ -10,9 +10,9 @@ INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months');
|
||||
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago');
|
||||
-- badly formatted reltimes
|
||||
INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime');
|
||||
ERROR: Bad reltime external representation 'badly formatted reltime'
|
||||
ERROR: invalid input syntax for reltime: "badly formatted reltime"
|
||||
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
|
||||
ERROR: Bad reltime external representation '@ 30 eons ago'
|
||||
ERROR: invalid input syntax for reltime: "@ 30 eons ago"
|
||||
-- test reltime operators
|
||||
SELECT '' AS six, RELTIME_TBL.*;
|
||||
six | f1
|
||||
|
@ -737,7 +737,7 @@ SELECT replace('yabadoo', 'bad', '') AS "yaoo";
|
||||
-- test split_part
|
||||
--
|
||||
select split_part('joeuser@mydatabase','@',0) AS "an error";
|
||||
ERROR: field position must be > 0
|
||||
ERROR: field position must be greater than zero
|
||||
select split_part('joeuser@mydatabase','@',1) AS "joeuser";
|
||||
joeuser
|
||||
---------
|
||||
|
@ -11,7 +11,7 @@ CREATE TABLE TIMESTAMP_TBL ( d1 timestamp(2) without time zone);
|
||||
-- statements.
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('now');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('current');
|
||||
ERROR: 'CURRENT' is no longer supported
|
||||
ERROR: "current" is no longer supported
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('today');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('yesterday');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow');
|
||||
@ -60,13 +60,13 @@ INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
|
||||
-- Obsolete special values
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
|
||||
ERROR: TIMESTAMP 'invalid' no longer supported
|
||||
ERROR: "invalid" is no longer supported
|
||||
-- Postgres v6.0 standard output format
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Invalid Abstime');
|
||||
ERROR: TIMESTAMP 'Invalid Abstime' no longer supported
|
||||
ERROR: "Invalid Abstime" is no longer supported
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Undefined Abstime');
|
||||
ERROR: TIMESTAMP 'Undefined Abstime' no longer supported
|
||||
ERROR: "Undefined Abstime" is no longer supported
|
||||
-- Variations on Postgres v6.1 standard output format
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
|
||||
@ -126,7 +126,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
|
||||
ERROR: Bad timestamp external representation 'Feb 29 17:32:01 1997'
|
||||
ERROR: invalid input syntax for timestamp: "Feb 29 17:32:01 1997"
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997');
|
||||
@ -136,9 +136,9 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
|
||||
-- Currently unsupported syntax and ranges
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
|
||||
ERROR: Bad timestamp external representation 'Feb 16 17:32:01 -0097'
|
||||
ERROR: invalid input syntax for timestamp: "Feb 16 17:32:01 -0097"
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
||||
ERROR: TIMESTAMP out of range 'Feb 16 17:32:01 5097 BC'
|
||||
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
||||
SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
|
||||
64 | d1
|
||||
----+-----------------------------
|
||||
@ -1370,7 +1370,7 @@ SELECT '' AS to_timestamp_8, to_timestamp('2000January09Sunday', 'YYYYFMMonthDDF
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS to_timestamp_9, to_timestamp('97/Feb/16', 'YYMonDD');
|
||||
ERROR: to_timestamp(): bad value for MON/Mon/mon
|
||||
ERROR: invalid value for MON/Mon/mon
|
||||
SELECT '' AS to_timestamp_10, to_timestamp('19971116', 'YYYYMMDD');
|
||||
to_timestamp_10 | to_timestamp
|
||||
-----------------+------------------------------
|
||||
|
@ -6,7 +6,7 @@ SET australian_timezones = 'off';
|
||||
CREATE TABLE TIMESTAMPTZ_TBL ( d1 timestamp(2) with time zone);
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
|
||||
ERROR: 'CURRENT' is no longer supported
|
||||
ERROR: "current" is no longer supported
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('today');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow');
|
||||
@ -55,13 +55,13 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
|
||||
-- Obsolete special values
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('invalid');
|
||||
ERROR: TIMESTAMP WITH TIME ZONE 'invalid' no longer supported
|
||||
ERROR: "invalid" is no longer supported
|
||||
-- Postgres v6.0 standard output format
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Invalid Abstime');
|
||||
ERROR: TIMESTAMP WITH TIME ZONE 'Invalid Abstime' no longer supported
|
||||
ERROR: "Invalid Abstime" is no longer supported
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Undefined Abstime');
|
||||
ERROR: TIMESTAMP WITH TIME ZONE 'Undefined Abstime' no longer supported
|
||||
ERROR: "Undefined Abstime" is no longer supported
|
||||
-- Variations on Postgres v6.1 standard output format
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
|
||||
@ -121,7 +121,7 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997');
|
||||
ERROR: Bad timestamp external representation 'Feb 29 17:32:01 1997'
|
||||
ERROR: invalid input syntax for timestamp with time zone: "Feb 29 17:32:01 1997"
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997');
|
||||
@ -131,9 +131,9 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001');
|
||||
-- Currently unsupported syntax and ranges
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097');
|
||||
ERROR: Bad timestamp external representation 'Feb 16 17:32:01 -0097'
|
||||
ERROR: invalid input syntax for timestamp with time zone: "Feb 16 17:32:01 -0097"
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
||||
ERROR: TIMESTAMP WITH TIME ZONE out of range 'Feb 16 17:32:01 5097 BC'
|
||||
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
||||
SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
|
||||
64 | d1
|
||||
----+---------------------------------
|
||||
@ -1369,7 +1369,7 @@ SELECT '' AS to_timestamp_8, to_timestamp('2000January09Sunday', 'YYYYFMMonthDDF
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS to_timestamp_9, to_timestamp('97/Feb/16', 'YYMonDD');
|
||||
ERROR: to_timestamp(): bad value for MON/Mon/mon
|
||||
ERROR: invalid value for MON/Mon/mon
|
||||
SELECT '' AS to_timestamp_10, to_timestamp('19971116', 'YYYYMMDD');
|
||||
to_timestamp_10 | to_timestamp
|
||||
-----------------+------------------------------
|
||||
|
@ -17,10 +17,10 @@ INSERT INTO TINTERVAL_TBL (f1)
|
||||
-- badly formatted tintervals
|
||||
INSERT INTO TINTERVAL_TBL (f1)
|
||||
VALUES ('["bad time specifications" ""]');
|
||||
ERROR: Bad abstime external representation 'bad time specifications'
|
||||
ERROR: invalid input syntax for abstime: "bad time specifications"
|
||||
INSERT INTO TINTERVAL_TBL (f1)
|
||||
VALUES ('["" "infinity"]');
|
||||
ERROR: Bad abstime external representation ''
|
||||
ERROR: invalid input syntax for abstime: ""
|
||||
-- test tinterval operators
|
||||
SELECT '' AS five, TINTERVAL_TBL.*;
|
||||
five | f1
|
||||
|
@ -17,10 +17,10 @@ INSERT INTO TINTERVAL_TBL (f1)
|
||||
-- badly formatted tintervals
|
||||
INSERT INTO TINTERVAL_TBL (f1)
|
||||
VALUES ('["bad time specifications" ""]');
|
||||
ERROR: Bad abstime external representation 'bad time specifications'
|
||||
ERROR: invalid input syntax for abstime: "bad time specifications"
|
||||
INSERT INTO TINTERVAL_TBL (f1)
|
||||
VALUES ('["" "infinity"]');
|
||||
ERROR: Bad abstime external representation ''
|
||||
ERROR: invalid input syntax for abstime: ""
|
||||
-- test tinterval operators
|
||||
SELECT '' AS five, TINTERVAL_TBL.*;
|
||||
five | f1
|
||||
|
Loading…
x
Reference in New Issue
Block a user