Commit b6a1d25b authored by Tom Lane's avatar Tom Lane

Error message editing in utils/adt. Again thanks to Joe Conway for doing

the bulk of the heavy lifting ...
parent 524cfad2
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -90,8 +90,12 @@ getid(const char *s, char *n)
else else
{ {
if (len >= NAMEDATALEN-1) if (len >= NAMEDATALEN-1)
elog(ERROR, "identifier must be less than %d characters", ereport(ERROR,
NAMEDATALEN); (errcode(ERRCODE_NAME_TOO_LONG),
errmsg("identifier too long"),
errdetail("Identifier must be less than %d characters.",
NAMEDATALEN)));
n[len++] = *s; n[len++] = *s;
} }
} }
...@@ -157,26 +161,34 @@ aclparse(const char *s, AclItem *aip) ...@@ -157,26 +161,34 @@ aclparse(const char *s, AclItem *aip)
Assert(s && aip); Assert(s && aip);
#ifdef ACLDEBUG #ifdef ACLDEBUG
elog(LOG, "aclparse: input = '%s'", s); elog(LOG, "aclparse: input = \"%s\"", s);
#endif #endif
idtype = ACL_IDTYPE_UID; idtype = ACL_IDTYPE_UID;
s = getid(s, name); s = getid(s, name);
if (*s != '=') if (*s != '=')
{ {
/* we just read a keyword, not a name */ /* 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; idtype = ACL_IDTYPE_GID;
else if (strncmp(name, ACL_IDTYPE_UID_KEYWORD, sizeof(name)) != 0) else if (strcmp(name, ACL_IDTYPE_UID_KEYWORD) != 0)
elog(ERROR, "aclparse: bad keyword, must be [group|user]"); 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 */ s = getid(s, name); /* move s to the name beyond the keyword */
if (name[0] == '\0') 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') if (name[0] == '\0')
idtype = ACL_IDTYPE_WORLD; idtype = ACL_IDTYPE_WORLD;
if (*s != '=') if (*s != '=')
elog(ERROR, "aclparse: expecting \"=\" sign"); ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("missing \"=\" sign")));
privs = goption = ACL_NO_RIGHTS; privs = goption = ACL_NO_RIGHTS;
...@@ -221,8 +233,10 @@ aclparse(const char *s, AclItem *aip) ...@@ -221,8 +233,10 @@ aclparse(const char *s, AclItem *aip)
read = ACL_CREATE_TEMP; read = ACL_CREATE_TEMP;
break; break;
default: default:
elog(ERROR, "aclparse: mode flags must use \"%s\"", ereport(ERROR,
ACL_ALL_RIGHTS_STR); (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid mode character: must be one of \"%s\"",
ACL_ALL_RIGHTS_STR)));
} }
privs |= read; privs |= read;
...@@ -247,14 +261,18 @@ aclparse(const char *s, AclItem *aip) ...@@ -247,14 +261,18 @@ aclparse(const char *s, AclItem *aip)
{ {
s = getid(s + 1, name2); s = getid(s + 1, name2);
if (name2[0] == '\0') 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); aip->ai_grantor = get_usesysid(name2);
} }
else else
{ {
aip->ai_grantor = BOOTSTRAP_USESYSID; 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); ACLITEM_SET_PRIVS_IDTYPE(*aip, privs, goption, idtype);
...@@ -280,7 +298,7 @@ allocacl(int n) ...@@ -280,7 +298,7 @@ allocacl(int n)
Size size; Size size;
if (n < 0) if (n < 0)
elog(ERROR, "allocacl: invalid size: %d", n); elog(ERROR, "invalid size: %d", n);
size = ACL_N_SIZE(n); size = ACL_N_SIZE(n);
new_acl = (Acl *) palloc0(size); new_acl = (Acl *) palloc0(size);
new_acl->size = size; new_acl->size = size;
...@@ -311,7 +329,10 @@ aclitemin(PG_FUNCTION_ARGS) ...@@ -311,7 +329,10 @@ aclitemin(PG_FUNCTION_ARGS)
while (isspace((unsigned char) *s)) while (isspace((unsigned char) *s))
++s; ++s;
if (*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); PG_RETURN_ACLITEM_P(aip);
} }
...@@ -373,8 +394,8 @@ aclitemout(PG_FUNCTION_ARGS) ...@@ -373,8 +394,8 @@ aclitemout(PG_FUNCTION_ARGS)
case ACL_IDTYPE_WORLD: case ACL_IDTYPE_WORLD:
break; break;
default: default:
elog(ERROR, "aclitemout: bad idtype: %d", elog(ERROR, "unrecognized idtype: %d",
ACLITEM_GET_IDTYPE(*aip)); (int) ACLITEM_GET_IDTYPE(*aip));
break; break;
} }
while (*p) while (*p)
...@@ -482,7 +503,7 @@ acldefault(GrantObjectType objtype, AclId ownerid) ...@@ -482,7 +503,7 @@ acldefault(GrantObjectType objtype, AclId ownerid)
owner_default = ACL_ALL_RIGHTS_NAMESPACE; owner_default = ACL_ALL_RIGHTS_NAMESPACE;
break; break;
default: default:
elog(ERROR, "acldefault: bogus objtype %d", (int) objtype); elog(ERROR, "unrecognized objtype: %d", (int) objtype);
world_default = ACL_NO_RIGHTS; /* keep compiler quiet */ world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
owner_default = ACL_NO_RIGHTS; owner_default = ACL_NO_RIGHTS;
break; break;
...@@ -644,7 +665,10 @@ restart: ...@@ -644,7 +665,10 @@ restart:
AclItem mod_acl; AclItem mod_acl;
if (behavior == DROP_RESTRICT) 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_grantor = grantee;
mod_acl.ai_grantee = aip[i].ai_grantee; mod_acl.ai_grantee = aip[i].ai_grantee;
...@@ -718,7 +742,9 @@ aclremove(PG_FUNCTION_ARGS) ...@@ -718,7 +742,9 @@ aclremove(PG_FUNCTION_ARGS)
new_aip = ACL_DAT(new_acl); new_aip = ACL_DAT(new_acl);
if (dst == 0) if (dst == 0)
{ /* start */ { /* 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) else if (dst == old_num - 1)
{ /* end */ { /* end */
...@@ -784,7 +810,9 @@ makeaclitem(PG_FUNCTION_ARGS) ...@@ -784,7 +810,9 @@ makeaclitem(PG_FUNCTION_ARGS)
} }
else if (u_grantee != 0 && g_grantee != 0) 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) else if (u_grantee != 0)
{ {
...@@ -840,7 +868,9 @@ convert_priv_string(text *priv_type_text) ...@@ -840,7 +868,9 @@ convert_priv_string(text *priv_type_text)
if (strcasecmp(priv_type, "TEMPORARY") == 0) if (strcasecmp(priv_type, "TEMPORARY") == 0)
return ACL_CREATE_TEMP; 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 */ return ACL_NO_RIGHTS; /* keep compiler quiet */
} }
...@@ -1063,8 +1093,9 @@ convert_table_priv_string(text *priv_type_text) ...@@ -1063,8 +1093,9 @@ convert_table_priv_string(text *priv_type_text)
if (strcasecmp(priv_type, "TRIGGER WITH GRANT OPTION") == 0) if (strcasecmp(priv_type, "TRIGGER WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_TRIGGER); return ACL_GRANT_OPTION_FOR(ACL_TRIGGER);
elog(ERROR, "has_table_privilege: invalid privilege type %s", ereport(ERROR,
priv_type); (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
return ACL_NO_RIGHTS; /* keep compiler quiet */ return ACL_NO_RIGHTS; /* keep compiler quiet */
} }
...@@ -1237,7 +1268,9 @@ convert_database_name(text *databasename) ...@@ -1237,7 +1268,9 @@ convert_database_name(text *databasename)
oid = get_database_oid(dbname); oid = get_database_oid(dbname);
if (!OidIsValid(oid)) 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; return oid;
} }
...@@ -1272,8 +1305,9 @@ convert_database_priv_string(text *priv_type_text) ...@@ -1272,8 +1305,9 @@ convert_database_priv_string(text *priv_type_text)
if (strcasecmp(priv_type, "TEMP WITH GRANT OPTION") == 0) if (strcasecmp(priv_type, "TEMP WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP); return ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP);
elog(ERROR, "has_database_privilege: invalid privilege type %s", ereport(ERROR,
priv_type); (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
return ACL_NO_RIGHTS; /* keep compiler quiet */ return ACL_NO_RIGHTS; /* keep compiler quiet */
} }
...@@ -1448,7 +1482,9 @@ convert_function_name(text *functionname) ...@@ -1448,7 +1482,9 @@ convert_function_name(text *functionname)
CStringGetDatum(funcname))); CStringGetDatum(funcname)));
if (!OidIsValid(oid)) 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; return oid;
} }
...@@ -1473,8 +1509,9 @@ convert_function_priv_string(text *priv_type_text) ...@@ -1473,8 +1509,9 @@ convert_function_priv_string(text *priv_type_text)
if (strcasecmp(priv_type, "EXECUTE WITH GRANT OPTION") == 0) if (strcasecmp(priv_type, "EXECUTE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_EXECUTE); return ACL_GRANT_OPTION_FOR(ACL_EXECUTE);
elog(ERROR, "has_function_privilege: invalid privilege type %s", ereport(ERROR,
priv_type); (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
return ACL_NO_RIGHTS; /* keep compiler quiet */ return ACL_NO_RIGHTS; /* keep compiler quiet */
} }
...@@ -1649,7 +1686,9 @@ convert_language_name(text *languagename) ...@@ -1649,7 +1686,9 @@ convert_language_name(text *languagename)
CStringGetDatum(langname), CStringGetDatum(langname),
0, 0, 0); 0, 0, 0);
if (!OidIsValid(oid)) 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; return oid;
} }
...@@ -1674,8 +1713,9 @@ convert_language_priv_string(text *priv_type_text) ...@@ -1674,8 +1713,9 @@ convert_language_priv_string(text *priv_type_text)
if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0) if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_USAGE); return ACL_GRANT_OPTION_FOR(ACL_USAGE);
elog(ERROR, "has_language_privilege: invalid privilege type %s", ereport(ERROR,
priv_type); (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
return ACL_NO_RIGHTS; /* keep compiler quiet */ return ACL_NO_RIGHTS; /* keep compiler quiet */
} }
...@@ -1850,7 +1890,9 @@ convert_schema_name(text *schemaname) ...@@ -1850,7 +1890,9 @@ convert_schema_name(text *schemaname)
CStringGetDatum(nspname), CStringGetDatum(nspname),
0, 0, 0); 0, 0, 0);
if (!OidIsValid(oid)) 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; return oid;
} }
...@@ -1880,7 +1922,8 @@ convert_schema_priv_string(text *priv_type_text) ...@@ -1880,7 +1922,8 @@ convert_schema_priv_string(text *priv_type_text)
if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0) if (strcasecmp(priv_type, "USAGE WITH GRANT OPTION") == 0)
return ACL_GRANT_OPTION_FOR(ACL_USAGE); return ACL_GRANT_OPTION_FOR(ACL_USAGE);
elog(ERROR, "has_schema_privilege: invalid privilege type %s", ereport(ERROR,
priv_type); (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized privilege type: \"%s\"", priv_type)));
return ACL_NO_RIGHTS; /* keep compiler quiet */ return ACL_NO_RIGHTS; /* keep compiler quiet */
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 @@ ...@@ -15,6 +15,7 @@
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "utils/array.h" #include "utils/array.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
...@@ -44,7 +45,10 @@ array_push(PG_FUNCTION_ARGS) ...@@ -44,7 +45,10 @@ array_push(PG_FUNCTION_ARGS)
ArrayMetaState *my_extra; ArrayMetaState *my_extra;
if (arg0_typeid == InvalidOid || arg1_typeid == InvalidOid) 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); arg0_elemid = get_element_type(arg0_typeid);
arg1_elemid = get_element_type(arg1_typeid); arg1_elemid = get_element_type(arg1_typeid);
...@@ -63,7 +67,9 @@ array_push(PG_FUNCTION_ARGS) ...@@ -63,7 +67,9 @@ array_push(PG_FUNCTION_ARGS)
else else
{ {
/* Shouldn't get here given proper type checking in parser */ /* 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 */ PG_RETURN_NULL(); /* keep compiler quiet */
} }
...@@ -87,8 +93,9 @@ array_push(PG_FUNCTION_ARGS) ...@@ -87,8 +93,9 @@ array_push(PG_FUNCTION_ARGS)
else if (ARR_NDIM(v) == 0) else if (ARR_NDIM(v) == 0)
indx = 1; indx = 1;
else 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 * We arrange to look up info about element type only once per series
...@@ -169,16 +176,25 @@ array_cat(PG_FUNCTION_ARGS) ...@@ -169,16 +176,25 @@ array_cat(PG_FUNCTION_ARGS)
/* the rest fall into combo 2, 3, or 4 */ /* the rest fall into combo 2, 3, or 4 */
if (ndims1 != ndims2 && ndims1 != ndims2 - 1 && ndims1 != ndims2 + 1) if (ndims1 != ndims2 && ndims1 != ndims2 - 1 && ndims1 != ndims2 + 1)
elog(ERROR, "Cannot concatenate incompatible arrays of %d and " ereport(ERROR,
"%d dimensions", ndims1, ndims2); (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_type1 = ARR_ELEMTYPE(v1);
element_type2 = ARR_ELEMTYPE(v2); element_type2 = ARR_ELEMTYPE(v2);
/* Do we have a matching element types */ /* Do we have a matching element types */
if (element_type1 != element_type2) if (element_type1 != element_type2)
elog(ERROR, "Cannot concatenate incompatible arrays with element " ereport(ERROR,
"type %u and %u", element_type1, element_type2); (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 */ /* OK, use it */
element_type = element_type1; element_type = element_type1;
...@@ -211,7 +227,11 @@ array_cat(PG_FUNCTION_ARGS) ...@@ -211,7 +227,11 @@ array_cat(PG_FUNCTION_ARGS)
for (i = 0; i < ndims1; i++) for (i = 0; i < ndims1; i++)
{ {
if (dims1[i] != dims2[i] || lbs1[i] != lbs2[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]; dims[i + 1] = dims1[i];
lbs[i + 1] = lbs1[i]; lbs[i + 1] = lbs1[i];
...@@ -237,7 +257,11 @@ array_cat(PG_FUNCTION_ARGS) ...@@ -237,7 +257,11 @@ array_cat(PG_FUNCTION_ARGS)
for (i = 0; i < ndims1; i++) for (i = 0; i < ndims1; i++)
{ {
if (dims1[i] != dims[i + 1] || lbs1[i] != lbs[i + 1]) 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) */ else /* (ndims1 == ndims2 + 1) */
...@@ -260,7 +284,11 @@ array_cat(PG_FUNCTION_ARGS) ...@@ -260,7 +284,11 @@ array_cat(PG_FUNCTION_ARGS)
for (i = 0; i < ndims2; i++) for (i = 0; i < ndims2; i++)
{ {
if (dims2[i] != dims[i + 1] || lbs2[i] != lbs[i + 1]) 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, ...@@ -302,9 +330,18 @@ create_singleton_array(FunctionCallInfo fcinfo,
ArrayMetaState *my_extra; ArrayMetaState *my_extra;
if (element_type == 0) if (element_type == 0)
elog(ERROR, "Invalid array element type: %u", element_type); ereport(ERROR,
if (ndims < 1 || ndims > MAXDIM) (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
elog(ERROR, "Invalid number of dimensions %d", ndims); 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; dvalues[0] = element;
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1999-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1999-2002, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -63,8 +63,10 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *dest, int
} }
else else
{ {
elog(ERROR, "unsupported encoding conversion from %s to ASCII", ereport(ERROR,
pg_encoding_to_char(enc)); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("unsupported encoding conversion from %s to ASCII",
pg_encoding_to_char(enc))));
return; /* keep compiler quiet */ return; /* keep compiler quiet */
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -75,7 +75,9 @@ boolin(PG_FUNCTION_ARGS)
break; 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 */ /* not reached */
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* workings can be found in the book "Software Solutions in C" by * workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * 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" #include "postgres.h"
...@@ -193,7 +193,9 @@ cash_in(PG_FUNCTION_ARGS) ...@@ -193,7 +193,9 @@ cash_in(PG_FUNCTION_ARGS)
s++; s++;
if (*s != '\0') 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); result = (value * sgn);
...@@ -290,7 +292,9 @@ cash_out(PG_FUNCTION_ARGS) ...@@ -290,7 +292,9 @@ cash_out(PG_FUNCTION_ARGS)
if (minus) if (minus)
{ {
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol)))) 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 */ /* Position code of 0 means use parens */
if (convention == 0) if (convention == 0)
...@@ -303,7 +307,9 @@ cash_out(PG_FUNCTION_ARGS) ...@@ -303,7 +307,9 @@ cash_out(PG_FUNCTION_ARGS)
else else
{ {
if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count))) 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); strcpy(result, buf + count);
} }
...@@ -468,7 +474,9 @@ cash_div_flt8(PG_FUNCTION_ARGS) ...@@ -468,7 +474,9 @@ cash_div_flt8(PG_FUNCTION_ARGS)
Cash result; Cash result;
if (f == 0.0) if (f == 0.0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = rint(c / f); result = rint(c / f);
PG_RETURN_CASH(result); PG_RETURN_CASH(result);
...@@ -518,7 +526,9 @@ cash_div_flt4(PG_FUNCTION_ARGS) ...@@ -518,7 +526,9 @@ cash_div_flt4(PG_FUNCTION_ARGS)
Cash result; Cash result;
if (f == 0.0) if (f == 0.0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = rint(c / f); result = rint(c / f);
PG_RETURN_CASH(result); PG_RETURN_CASH(result);
...@@ -569,7 +579,9 @@ cash_div_int4(PG_FUNCTION_ARGS) ...@@ -569,7 +579,9 @@ cash_div_int4(PG_FUNCTION_ARGS)
Cash result; Cash result;
if (i == 0) if (i == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = rint(c / i); result = rint(c / i);
...@@ -619,7 +631,9 @@ cash_div_int2(PG_FUNCTION_ARGS) ...@@ -619,7 +631,9 @@ cash_div_int2(PG_FUNCTION_ARGS)
Cash result; Cash result;
if (s == 0) if (s == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = rint(c / s); result = rint(c / s);
PG_RETURN_CASH(result); PG_RETURN_CASH(result);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -181,7 +181,9 @@ chardiv(PG_FUNCTION_ARGS)
char arg2 = PG_GETARG_CHAR(1); char arg2 = PG_GETARG_CHAR(1);
if (arg2 == 0) 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); PG_RETURN_CHAR((int8) arg1 / (int8) arg2);
} }
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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, ...@@ -1251,7 +1251,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
switch (val) switch (val)
{ {
case DTK_CURRENT: 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; return -1;
break; break;
...@@ -1428,7 +1431,10 @@ DecodeDateTime(char **field, int *ftype, int nf, ...@@ -1428,7 +1431,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
if (tm->tm_year > 0) if (tm->tm_year > 0)
tm->tm_year = -(tm->tm_year - 1); tm->tm_year = -(tm->tm_year - 1);
else 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) else if (is2digits)
{ {
...@@ -1965,7 +1971,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf, ...@@ -1965,7 +1971,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
switch (val) switch (val)
{ {
case DTK_CURRENT: 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; return -1;
break; break;
...@@ -2238,7 +2246,10 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm) ...@@ -2238,7 +2246,10 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm)
if (tm->tm_year > 0) if (tm->tm_year > 0)
tm->tm_year = -(tm->tm_year - 1); tm->tm_year = -(tm->tm_year - 1);
else 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) else if (is2digits)
{ {
...@@ -2554,7 +2565,7 @@ DecodeNumberField(int len, char *str, int fmask, ...@@ -2554,7 +2565,7 @@ DecodeNumberField(int len, char *str, int fmask,
* *
* Return 0 if okay (and set *tzp), nonzero if not okay. * 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 * Note: we allow timezone offsets up to 13:59. There are places that
* use +1300 summer time. * use +1300 summer time.
...@@ -2611,7 +2622,7 @@ DecodeTimezone(char *str, int *tzp) ...@@ -2611,7 +2622,7 @@ DecodeTimezone(char *str, int *tzp)
* *
* Return 0 if okay (and set *tzp), nonzero if not okay. * 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 int
DecodePosixTimezone(char *str, int *tzp) DecodePosixTimezone(char *str, int *tzp)
...@@ -2663,7 +2674,7 @@ DecodePosixTimezone(char *str, int *tzp) ...@@ -2663,7 +2674,7 @@ DecodePosixTimezone(char *str, int *tzp)
* Implement a cache lookup since it is likely that dates * Implement a cache lookup since it is likely that dates
* will be related in format. * will be related in format.
* *
* NB: this must *not* elog on failure; * NB: this must *not* ereport on failure;
* see commands/variable.c. * see commands/variable.c.
*/ */
int int
...@@ -3715,7 +3726,7 @@ CheckDateTokenTable(const char *tablename, datetkn *base, unsigned int nel) ...@@ -3715,7 +3726,7 @@ CheckDateTokenTable(const char *tablename, datetkn *base, unsigned int nel)
{ {
if (strncmp(base[i-1].token, base[i].token, TOKMAXLEN) >= 0) 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, tablename,
TOKMAXLEN, base[i-1].token, TOKMAXLEN, base[i-1].token,
TOKMAXLEN, base[i].token); TOKMAXLEN, base[i].token);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -75,7 +75,10 @@ datumGetSize(Datum value, bool typByVal, int typLen)
struct varlena *s = (struct varlena *) DatumGetPointer(value); struct varlena *s = (struct varlena *) DatumGetPointer(value);
if (!PointerIsValid(s)) if (!PointerIsValid(s))
elog(ERROR, "datumGetSize: Invalid Datum Pointer"); ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid Datum pointer")));
size = (Size) VARATT_SIZE(s); size = (Size) VARATT_SIZE(s);
} }
else if (typLen == -2) else if (typLen == -2)
...@@ -84,12 +87,15 @@ datumGetSize(Datum value, bool typByVal, int typLen) ...@@ -84,12 +87,15 @@ datumGetSize(Datum value, bool typByVal, int typLen)
char *s = (char *) DatumGetPointer(value); char *s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s)) if (!PointerIsValid(s))
elog(ERROR, "datumGetSize: Invalid Datum Pointer"); ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid Datum pointer")));
size = (Size) (strlen(s) + 1); size = (Size) (strlen(s) + 1);
} }
else else
{ {
elog(ERROR, "datumGetSize: Invalid typLen %d", typLen); elog(ERROR, "invalid typLen: %d", typLen);
size = 0; /* keep compiler quiet */ size = 0; /* keep compiler quiet */
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -50,7 +50,9 @@ binary_encode(PG_FUNCTION_ARGS)
enc = pg_find_encoding(namebuf); enc = pg_find_encoding(namebuf);
if (enc == NULL) 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); resultlen = enc->encode_len(VARDATA(data), datalen);
result = palloc(VARHDRSZ + resultlen); result = palloc(VARHDRSZ + resultlen);
...@@ -59,7 +61,7 @@ binary_encode(PG_FUNCTION_ARGS) ...@@ -59,7 +61,7 @@ binary_encode(PG_FUNCTION_ARGS)
/* Make this FATAL 'cause we've trodden on memory ... */ /* Make this FATAL 'cause we've trodden on memory ... */
if (res > resultlen) if (res > resultlen)
elog(FATAL, "Overflow - encode estimate too small"); elog(FATAL, "overflow - encode estimate too small");
VARATT_SIZEP(result) = VARHDRSZ + res; VARATT_SIZEP(result) = VARHDRSZ + res;
...@@ -84,7 +86,9 @@ binary_decode(PG_FUNCTION_ARGS) ...@@ -84,7 +86,9 @@ binary_decode(PG_FUNCTION_ARGS)
enc = pg_find_encoding(namebuf); enc = pg_find_encoding(namebuf);
if (enc == NULL) 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); resultlen = enc->decode_len(VARDATA(data), datalen);
result = palloc(VARHDRSZ + resultlen); result = palloc(VARHDRSZ + resultlen);
...@@ -93,7 +97,7 @@ binary_decode(PG_FUNCTION_ARGS) ...@@ -93,7 +97,7 @@ binary_decode(PG_FUNCTION_ARGS)
/* Make this FATAL 'cause we've trodden on memory ... */ /* Make this FATAL 'cause we've trodden on memory ... */
if (res > resultlen) if (res > resultlen)
elog(FATAL, "Overflow - decode estimate too small"); elog(FATAL, "overflow - decode estimate too small");
VARATT_SIZEP(result) = VARHDRSZ + res; VARATT_SIZEP(result) = VARHDRSZ + res;
...@@ -141,7 +145,9 @@ get_hex(unsigned c) ...@@ -141,7 +145,9 @@ get_hex(unsigned c)
res = hexlookup[c]; res = hexlookup[c];
if (res < 0) 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; return (uint8) res;
} }
...@@ -167,7 +173,10 @@ hex_decode(const uint8 *src, unsigned len, uint8 *dst) ...@@ -167,7 +173,10 @@ hex_decode(const uint8 *src, unsigned len, uint8 *dst)
} }
v1 = get_hex(*s++) << 4; v1 = get_hex(*s++) << 4;
if (s >= srcend) 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++); v2 = get_hex(*s++);
*p++ = v1 | v2; *p++ = v1 | v2;
} }
...@@ -281,7 +290,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst) ...@@ -281,7 +290,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
else if (pos == 3) else if (pos == 3)
end = 2; end = 2;
else else
elog(ERROR, "base64: unexpected '='"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unexpected \"=\"")));
} }
b = 0; b = 0;
} }
...@@ -291,7 +302,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst) ...@@ -291,7 +302,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
if (c > 0 && c < 127) if (c > 0 && c < 127)
b = b64lookup[c]; b = b64lookup[c];
if (b < 0) if (b < 0)
elog(ERROR, "base64: Invalid symbol"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid symbol")));
} }
/* add it to buffer */ /* add it to buffer */
buf = (buf << 6) + b; buf = (buf << 6) + b;
...@@ -309,7 +322,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst) ...@@ -309,7 +322,9 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
} }
if (pos != 0) if (pos != 0)
elog(ERROR, "base64: invalid end sequence"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid end sequence")));
return p - dst; return p - dst;
} }
...@@ -416,7 +431,9 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst) ...@@ -416,7 +431,9 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
* One backslash, not followed by ### valid octal. Should * One backslash, not followed by ### valid octal. Should
* never get here, since esc_dec_len does same check. * 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++; len++;
...@@ -479,7 +496,9 @@ esc_dec_len(const uint8 *src, unsigned srclen) ...@@ -479,7 +496,9 @@ esc_dec_len(const uint8 *src, unsigned srclen)
/* /*
* one backslash, not followed by ### valid octal * 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++; len++;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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); ...@@ -115,7 +115,7 @@ static void CheckFloat8Val(double val);
* check to see if a float4 val is outside of * check to see if a float4 val is outside of
* the FLOAT4_MIN, FLOAT4_MAX bounds. * the FLOAT4_MIN, FLOAT4_MAX bounds.
* *
* raise an elog warning if it is * raise an ereport warning if it is
*/ */
static void static void
CheckFloat4Val(double val) CheckFloat4Val(double val)
...@@ -128,9 +128,14 @@ CheckFloat4Val(double val) ...@@ -128,9 +128,14 @@ CheckFloat4Val(double val)
return; return;
#else #else
if (fabs(val) > FLOAT4_MAX) 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) 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; return;
#endif /* UNSAFE_FLOATS */ #endif /* UNSAFE_FLOATS */
} }
...@@ -139,7 +144,7 @@ CheckFloat4Val(double val) ...@@ -139,7 +144,7 @@ CheckFloat4Val(double val)
* check to see if a float8 val is outside of * check to see if a float8 val is outside of
* the FLOAT8_MIN, FLOAT8_MAX bounds. * the FLOAT8_MIN, FLOAT8_MAX bounds.
* *
* raise an elog error if it is * raise an ereport error if it is
*/ */
static void static void
CheckFloat8Val(double val) CheckFloat8Val(double val)
...@@ -152,9 +157,13 @@ CheckFloat8Val(double val) ...@@ -152,9 +157,13 @@ CheckFloat8Val(double val)
return; return;
#else #else
if (fabs(val) > FLOAT8_MAX) 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) 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 */ #endif /* UNSAFE_FLOATS */
} }
...@@ -184,12 +193,17 @@ float4in(PG_FUNCTION_ARGS) ...@@ -184,12 +193,17 @@ float4in(PG_FUNCTION_ARGS)
if (strcasecmp(num, "NaN") == 0) if (strcasecmp(num, "NaN") == 0)
val = NAN; val = NAN;
else 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 else
{ {
if (errno == ERANGE) 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) ...@@ -280,12 +294,17 @@ float8in(PG_FUNCTION_ARGS)
else if (strcasecmp(num, "-Infinity") == 0) else if (strcasecmp(num, "-Infinity") == 0)
val = -HUGE_VAL; val = -HUGE_VAL;
else 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 else
{ {
if (errno == ERANGE) 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); CheckFloat8Val(val);
...@@ -535,7 +554,9 @@ float4div(PG_FUNCTION_ARGS) ...@@ -535,7 +554,9 @@ float4div(PG_FUNCTION_ARGS)
double result; double result;
if (arg2 == 0.0) 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 */ /* Do division in float8, then check for overflow */
result = (float8) arg1 / (float8) arg2; result = (float8) arg1 / (float8) arg2;
...@@ -597,7 +618,9 @@ float8div(PG_FUNCTION_ARGS) ...@@ -597,7 +618,9 @@ float8div(PG_FUNCTION_ARGS)
float8 result; float8 result;
if (arg2 == 0.0) if (arg2 == 0.0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = arg1 / arg2; result = arg1 / arg2;
...@@ -847,7 +870,9 @@ dtoi4(PG_FUNCTION_ARGS) ...@@ -847,7 +870,9 @@ dtoi4(PG_FUNCTION_ARGS)
int32 result; int32 result;
if ((num < INT_MIN) || (num > INT_MAX)) 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); result = (int32) rint(num);
PG_RETURN_INT32(result); PG_RETURN_INT32(result);
...@@ -864,7 +889,9 @@ dtoi2(PG_FUNCTION_ARGS) ...@@ -864,7 +889,9 @@ dtoi2(PG_FUNCTION_ARGS)
int16 result; int16 result;
if ((num < SHRT_MIN) || (num > SHRT_MAX)) 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); result = (int16) rint(num);
PG_RETURN_INT16(result); PG_RETURN_INT16(result);
...@@ -909,7 +936,9 @@ ftoi4(PG_FUNCTION_ARGS) ...@@ -909,7 +936,9 @@ ftoi4(PG_FUNCTION_ARGS)
int32 result; int32 result;
if ((num < INT_MIN) || (num > INT_MAX)) 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); result = (int32) rint(num);
PG_RETURN_INT32(result); PG_RETURN_INT32(result);
...@@ -926,7 +955,9 @@ ftoi2(PG_FUNCTION_ARGS) ...@@ -926,7 +955,9 @@ ftoi2(PG_FUNCTION_ARGS)
int16 result; int16 result;
if ((num < SHRT_MIN) || (num > SHRT_MAX)) 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); result = (int16) rint(num);
PG_RETURN_INT16(result); PG_RETURN_INT16(result);
...@@ -1160,7 +1191,9 @@ dsqrt(PG_FUNCTION_ARGS) ...@@ -1160,7 +1191,9 @@ dsqrt(PG_FUNCTION_ARGS)
float8 result; float8 result;
if (arg1 < 0) 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); result = sqrt(arg1);
...@@ -1204,7 +1237,9 @@ dpow(PG_FUNCTION_ARGS) ...@@ -1204,7 +1237,9 @@ dpow(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1232,7 +1267,9 @@ dexp(PG_FUNCTION_ARGS) ...@@ -1232,7 +1267,9 @@ dexp(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1250,9 +1287,14 @@ dlog1(PG_FUNCTION_ARGS) ...@@ -1250,9 +1287,14 @@ dlog1(PG_FUNCTION_ARGS)
float8 result; float8 result;
if (arg1 == 0.0) 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) 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); result = log(arg1);
...@@ -1271,9 +1313,14 @@ dlog10(PG_FUNCTION_ARGS) ...@@ -1271,9 +1313,14 @@ dlog10(PG_FUNCTION_ARGS)
float8 result; float8 result;
if (arg1 == 0.0) 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) 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); result = log10(arg1);
...@@ -1298,7 +1345,9 @@ dacos(PG_FUNCTION_ARGS) ...@@ -1298,7 +1345,9 @@ dacos(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1321,7 +1370,9 @@ dasin(PG_FUNCTION_ARGS) ...@@ -1321,7 +1370,9 @@ dasin(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1344,7 +1395,9 @@ datan(PG_FUNCTION_ARGS) ...@@ -1344,7 +1395,9 @@ datan(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1368,7 +1421,9 @@ datan2(PG_FUNCTION_ARGS) ...@@ -1368,7 +1421,9 @@ datan2(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1391,7 +1446,9 @@ dcos(PG_FUNCTION_ARGS) ...@@ -1391,7 +1446,9 @@ dcos(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1414,7 +1471,9 @@ dcot(PG_FUNCTION_ARGS) ...@@ -1414,7 +1471,9 @@ dcot(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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; result = 1.0 / result;
CheckFloat8Val(result); CheckFloat8Val(result);
...@@ -1438,7 +1497,9 @@ dsin(PG_FUNCTION_ARGS) ...@@ -1438,7 +1497,9 @@ dsin(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1461,7 +1522,9 @@ dtan(PG_FUNCTION_ARGS) ...@@ -1461,7 +1522,9 @@ dtan(PG_FUNCTION_ARGS)
|| !finite(result) || !finite(result)
#endif #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); CheckFloat8Val(result);
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
...@@ -1777,7 +1840,9 @@ float48div(PG_FUNCTION_ARGS) ...@@ -1777,7 +1840,9 @@ float48div(PG_FUNCTION_ARGS)
float8 result; float8 result;
if (arg2 == 0.0) if (arg2 == 0.0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = arg1 / arg2; result = arg1 / arg2;
CheckFloat8Val(result); CheckFloat8Val(result);
...@@ -1837,7 +1902,9 @@ float84div(PG_FUNCTION_ARGS) ...@@ -1837,7 +1902,9 @@ float84div(PG_FUNCTION_ARGS)
float8 result; float8 result;
if (arg2 == 0.0) if (arg2 == 0.0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = arg1 / arg2; result = arg1 / arg2;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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, ...@@ -133,8 +133,7 @@ format_type_internal(Oid type_oid, int32 typemod,
if (allow_invalid) if (allow_invalid)
return pstrdup("???"); return pstrdup("???");
else else
elog(ERROR, "could not locate data type with oid %u in catalog", elog(ERROR, "cache lookup failed for type %u", type_oid);
type_oid);
} }
typeform = (Form_pg_type) GETSTRUCT(tuple); typeform = (Form_pg_type) GETSTRUCT(tuple);
...@@ -159,8 +158,7 @@ format_type_internal(Oid type_oid, int32 typemod, ...@@ -159,8 +158,7 @@ format_type_internal(Oid type_oid, int32 typemod,
if (allow_invalid) if (allow_invalid)
return pstrdup("???[]"); return pstrdup("???[]");
else else
elog(ERROR, "could not locate data type with oid %u in catalog", elog(ERROR, "cache lookup failed for type %u", type_oid);
type_oid);
} }
typeform = (Form_pg_type) GETSTRUCT(tuple); typeform = (Form_pg_type) GETSTRUCT(tuple);
type_oid = array_base_type; type_oid = array_base_type;
...@@ -312,7 +310,7 @@ format_type_internal(Oid type_oid, int32 typemod, ...@@ -312,7 +310,7 @@ format_type_internal(Oid type_oid, int32 typemod,
fieldstr = ""; fieldstr = "";
break; break;
default: default:
elog(LOG, "Invalid INTERVAL typmod 0x%x", typemod); elog(ERROR, "invalid INTERVAL typmod: 0x%x", typemod);
fieldstr = ""; fieldstr = "";
break; break;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -121,7 +121,10 @@ int2vectorin(PG_FUNCTION_ARGS)
while (*intString && isspace((unsigned char) *intString)) while (*intString && isspace((unsigned char) *intString))
intString++; intString++;
if (*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) while (slot < INDEX_MAX_KEYS)
result[slot++] = 0; result[slot++] = 0;
...@@ -281,10 +284,10 @@ i4toi2(PG_FUNCTION_ARGS) ...@@ -281,10 +284,10 @@ i4toi2(PG_FUNCTION_ARGS)
{ {
int32 arg1 = PG_GETARG_INT32(0); int32 arg1 = PG_GETARG_INT32(0);
if (arg1 < SHRT_MIN) if (arg1 < SHRT_MIN || arg1 > SHRT_MAX)
elog(ERROR, "i4toi2: '%d' causes int2 underflow", arg1); ereport(ERROR,
if (arg1 > SHRT_MAX) (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
elog(ERROR, "i4toi2: '%d' causes int2 overflow", arg1); errmsg("integer out of range")));
PG_RETURN_INT16((int16) arg1); PG_RETURN_INT16((int16) arg1);
} }
...@@ -640,7 +643,9 @@ int4div(PG_FUNCTION_ARGS) ...@@ -640,7 +643,9 @@ int4div(PG_FUNCTION_ARGS)
int32 arg2 = PG_GETARG_INT32(1); int32 arg2 = PG_GETARG_INT32(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT32(arg1 / arg2); PG_RETURN_INT32(arg1 / arg2);
} }
...@@ -703,7 +708,9 @@ int2div(PG_FUNCTION_ARGS) ...@@ -703,7 +708,9 @@ int2div(PG_FUNCTION_ARGS)
int16 arg2 = PG_GETARG_INT16(1); int16 arg2 = PG_GETARG_INT16(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT16(arg1 / arg2); PG_RETURN_INT16(arg1 / arg2);
} }
...@@ -742,7 +749,9 @@ int24div(PG_FUNCTION_ARGS) ...@@ -742,7 +749,9 @@ int24div(PG_FUNCTION_ARGS)
int32 arg2 = PG_GETARG_INT32(1); int32 arg2 = PG_GETARG_INT32(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT32(arg1 / arg2); PG_RETURN_INT32(arg1 / arg2);
} }
...@@ -781,7 +790,9 @@ int42div(PG_FUNCTION_ARGS) ...@@ -781,7 +790,9 @@ int42div(PG_FUNCTION_ARGS)
int16 arg2 = PG_GETARG_INT16(1); int16 arg2 = PG_GETARG_INT16(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT32(arg1 / arg2); PG_RETURN_INT32(arg1 / arg2);
} }
...@@ -793,7 +804,9 @@ int4mod(PG_FUNCTION_ARGS) ...@@ -793,7 +804,9 @@ int4mod(PG_FUNCTION_ARGS)
int32 arg2 = PG_GETARG_INT32(1); int32 arg2 = PG_GETARG_INT32(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT32(arg1 % arg2); PG_RETURN_INT32(arg1 % arg2);
} }
...@@ -805,7 +818,9 @@ int2mod(PG_FUNCTION_ARGS) ...@@ -805,7 +818,9 @@ int2mod(PG_FUNCTION_ARGS)
int16 arg2 = PG_GETARG_INT16(1); int16 arg2 = PG_GETARG_INT16(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT16(arg1 % arg2); PG_RETURN_INT16(arg1 % arg2);
} }
...@@ -817,7 +832,9 @@ int24mod(PG_FUNCTION_ARGS) ...@@ -817,7 +832,9 @@ int24mod(PG_FUNCTION_ARGS)
int32 arg2 = PG_GETARG_INT32(1); int32 arg2 = PG_GETARG_INT32(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT32(arg1 % arg2); PG_RETURN_INT32(arg1 % arg2);
} }
...@@ -829,7 +846,9 @@ int42mod(PG_FUNCTION_ARGS) ...@@ -829,7 +846,9 @@ int42mod(PG_FUNCTION_ARGS)
int16 arg2 = PG_GETARG_INT16(1); int16 arg2 = PG_GETARG_INT16(1);
if (arg2 == 0) if (arg2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT32(arg1 % arg2); PG_RETURN_INT32(arg1 % arg2);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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 @@ ...@@ -36,7 +36,7 @@
/* /*
* scanint8 --- try to parse a string into an int8. * 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. * If errorOK is true, just return "false" for bad input.
*/ */
bool bool
...@@ -83,7 +83,9 @@ scanint8(const char *str, bool errorOK, int64 *result) ...@@ -83,7 +83,9 @@ scanint8(const char *str, bool errorOK, int64 *result)
if (errorOK) if (errorOK)
return false; return false;
else 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 */ /* process digits */
...@@ -96,7 +98,9 @@ scanint8(const char *str, bool errorOK, int64 *result) ...@@ -96,7 +98,9 @@ scanint8(const char *str, bool errorOK, int64 *result)
if (errorOK) if (errorOK)
return false; return false;
else 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; tmp = newtmp;
} }
...@@ -107,7 +111,9 @@ scanint8(const char *str, bool errorOK, int64 *result) ...@@ -107,7 +111,9 @@ scanint8(const char *str, bool errorOK, int64 *result)
if (errorOK) if (errorOK)
return false; return false;
else 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; *result = (sign < 0) ? -tmp : tmp;
...@@ -139,7 +145,7 @@ int8out(PG_FUNCTION_ARGS) ...@@ -139,7 +145,7 @@ int8out(PG_FUNCTION_ARGS)
char buf[MAXINT8LEN + 1]; char buf[MAXINT8LEN + 1];
if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0) if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
elog(ERROR, "Unable to format int8"); elog(ERROR, "could not format int8");
result = pstrdup(buf); result = pstrdup(buf);
PG_RETURN_CSTRING(result); PG_RETURN_CSTRING(result);
...@@ -515,7 +521,9 @@ int8div(PG_FUNCTION_ARGS) ...@@ -515,7 +521,9 @@ int8div(PG_FUNCTION_ARGS)
int64 val2 = PG_GETARG_INT64(1); int64 val2 = PG_GETARG_INT64(1);
if (val2 == 0) if (val2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT64(val1 / val2); PG_RETURN_INT64(val1 / val2);
} }
...@@ -542,7 +550,9 @@ int8mod(PG_FUNCTION_ARGS) ...@@ -542,7 +550,9 @@ int8mod(PG_FUNCTION_ARGS)
int64 result; int64 result;
if (val2 == 0) if (val2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = val1 / val2; result = val1 / val2;
result *= val2; result *= val2;
...@@ -638,7 +648,9 @@ int84div(PG_FUNCTION_ARGS) ...@@ -638,7 +648,9 @@ int84div(PG_FUNCTION_ARGS)
int32 val2 = PG_GETARG_INT32(1); int32 val2 = PG_GETARG_INT32(1);
if (val2 == 0) if (val2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT64(val1 / val2); PG_RETURN_INT64(val1 / val2);
} }
...@@ -677,7 +689,9 @@ int48div(PG_FUNCTION_ARGS) ...@@ -677,7 +689,9 @@ int48div(PG_FUNCTION_ARGS)
int64 val2 = PG_GETARG_INT64(1); int64 val2 = PG_GETARG_INT64(1);
if (val2 == 0) if (val2 == 0)
elog(ERROR, "division by zero"); ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
PG_RETURN_INT64(val1 / val2); PG_RETURN_INT64(val1 / val2);
} }
...@@ -767,7 +781,9 @@ int84(PG_FUNCTION_ARGS) ...@@ -767,7 +781,9 @@ int84(PG_FUNCTION_ARGS)
/* Test for overflow by reverse-conversion. */ /* Test for overflow by reverse-conversion. */
if ((int64) result != val) 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); PG_RETURN_INT32(result);
} }
...@@ -790,7 +806,9 @@ int82(PG_FUNCTION_ARGS) ...@@ -790,7 +806,9 @@ int82(PG_FUNCTION_ARGS)
/* Test for overflow by reverse-conversion. */ /* Test for overflow by reverse-conversion. */
if ((int64) result != val) 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); PG_RETURN_INT16(result);
} }
...@@ -826,7 +844,9 @@ dtoi8(PG_FUNCTION_ARGS) ...@@ -826,7 +844,9 @@ dtoi8(PG_FUNCTION_ARGS)
result = (int64) val; result = (int64) val;
if ((float8) result != 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); PG_RETURN_INT64(result);
} }
...@@ -863,7 +883,9 @@ ftoi8(PG_FUNCTION_ARGS) ...@@ -863,7 +883,9 @@ ftoi8(PG_FUNCTION_ARGS)
result = (int64) dval; result = (int64) dval;
if ((float8) result != 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); PG_RETURN_INT64(result);
} }
...@@ -878,7 +900,9 @@ i8tooid(PG_FUNCTION_ARGS) ...@@ -878,7 +900,9 @@ i8tooid(PG_FUNCTION_ARGS)
/* Test for overflow by reverse-conversion. */ /* Test for overflow by reverse-conversion. */
if ((int64) result != val) 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); PG_RETURN_OID(result);
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -448,7 +448,11 @@ like_escape_bytea(PG_FUNCTION_ARGS)
*/ */
BYTEA_NextChar(e, elen); BYTEA_NextChar(e, elen);
if (elen != 0) 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); e = VARDATA(esc);
/* /*
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* Copyright (c) 1996-2002, PostgreSQL Global Development Group * Copyright (c) 1996-2002, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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) ...@@ -286,7 +286,11 @@ do_like_escape(text *pat, text *esc)
*/ */
NextChar(e, elen); NextChar(e, elen);
if (elen != 0) 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); e = VARDATA(esc);
/* /*
......
/* /*
* PostgreSQL type definitions for MAC addresses. * 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" #include "postgres.h"
...@@ -60,12 +60,16 @@ macaddr_in(PG_FUNCTION_ARGS) ...@@ -60,12 +60,16 @@ macaddr_in(PG_FUNCTION_ARGS)
count = sscanf(str, "%2x%2x%2x%2x%2x%2x%1s", count = sscanf(str, "%2x%2x%2x%2x%2x%2x%1s",
&a, &b, &c, &d, &e, &f, junk); &a, &b, &c, &d, &e, &f, junk);
if (count != 6) 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) || if ((a < 0) || (a > 255) || (b < 0) || (b > 255) ||
(c < 0) || (c > 255) || (d < 0) || (d > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) ||
(e < 0) || (e > 255) || (f < 0) || (f > 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)); result = (macaddr *) palloc(sizeof(macaddr));
...@@ -181,7 +185,9 @@ text_macaddr(PG_FUNCTION_ARGS) ...@@ -181,7 +185,9 @@ text_macaddr(PG_FUNCTION_ARGS)
len = (VARSIZE(addr) - VARHDRSZ); len = (VARSIZE(addr) - VARHDRSZ);
if (len >= sizeof(str)) 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); memcpy(str, VARDATA(addr), len);
*(str + len) = '\0'; *(str + len) = '\0';
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -239,8 +239,10 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
*/ */
StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1); StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1);
if (strlen(tm->tm_zone) > MAXTZLEN) if (strlen(tm->tm_zone) > MAXTZLEN)
elog(WARNING, "Invalid timezone \'%s\'", ereport(WARNING,
tm->tm_zone); (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) ...@@ -273,8 +275,10 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
*/ */
StrNCpy(*tzn, tzname[tm->tm_isdst], MAXTZLEN + 1); StrNCpy(*tzn, tzname[tm->tm_isdst], MAXTZLEN + 1);
if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN) if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
elog(WARNING, "Invalid timezone \'%s\'", ereport(WARNING,
tzname[tm->tm_isdst]); (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid timezone name: \"%s\"",
tzname[tm->tm_isdst])));
} }
} }
} }
...@@ -367,11 +371,15 @@ abstimein(PG_FUNCTION_ARGS) ...@@ -367,11 +371,15 @@ abstimein(PG_FUNCTION_ARGS)
ftype[MAXDATEFIELDS]; ftype[MAXDATEFIELDS];
if (strlen(str) >= sizeof(lowstr)) 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) if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 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) switch (dtype)
{ {
...@@ -401,7 +409,8 @@ abstimein(PG_FUNCTION_ARGS) ...@@ -401,7 +409,8 @@ abstimein(PG_FUNCTION_ARGS)
break; break;
default: default:
elog(ERROR, "Bad abstime (internal coding error) '%s'", str); elog(ERROR, "unexpected dtype %d while parsing abstime \"%s\"",
dtype, str);
result = INVALID_ABSTIME; result = INVALID_ABSTIME;
break; break;
}; };
...@@ -513,7 +522,7 @@ abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b) ...@@ -513,7 +522,7 @@ abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b)
return -1; /* non-INVALID < INVALID */ return -1; /* non-INVALID < INVALID */
#if 0 #if 0
/* CURRENT is no longer stored internally... */ /* CURRENT is no longer stored internally... */
/* XXX this is broken, should go away: */ /* XXX this is broken, should go away: */
if (a == CURRENT_ABSTIME) if (a == CURRENT_ABSTIME)
a = GetCurrentTransactionStartTime(); a = GetCurrentTransactionStartTime();
...@@ -617,7 +626,9 @@ timestamp_abstime(PG_FUNCTION_ARGS) ...@@ -617,7 +626,9 @@ timestamp_abstime(PG_FUNCTION_ARGS)
} }
else 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; result = INVALID_ABSTIME;
} }
...@@ -641,7 +652,9 @@ abstime_timestamp(PG_FUNCTION_ARGS) ...@@ -641,7 +652,9 @@ abstime_timestamp(PG_FUNCTION_ARGS)
switch (abstime) switch (abstime)
{ {
case INVALID_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); TIMESTAMP_NOBEGIN(result);
break; break;
...@@ -656,8 +669,9 @@ abstime_timestamp(PG_FUNCTION_ARGS) ...@@ -656,8 +669,9 @@ abstime_timestamp(PG_FUNCTION_ARGS)
default: default:
abstime2tm(abstime, &tz, tm, &tzn); abstime2tm(abstime, &tz, tm, &tzn);
if (tm2timestamp(tm, 0, NULL, &result) != 0) if (tm2timestamp(tm, 0, NULL, &result) != 0)
elog(ERROR, "Unable to convert ABSTIME to TIMESTAMP" ereport(ERROR,
"\n\tabstime_timestamp() internal error"); (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range")));
break; break;
}; };
...@@ -685,7 +699,9 @@ timestamptz_abstime(PG_FUNCTION_ARGS) ...@@ -685,7 +699,9 @@ timestamptz_abstime(PG_FUNCTION_ARGS)
result = tm2abstime(tm, 0); result = tm2abstime(tm, 0);
else 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; result = INVALID_ABSTIME;
} }
...@@ -709,7 +725,9 @@ abstime_timestamptz(PG_FUNCTION_ARGS) ...@@ -709,7 +725,9 @@ abstime_timestamptz(PG_FUNCTION_ARGS)
switch (abstime) switch (abstime)
{ {
case INVALID_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); TIMESTAMP_NOBEGIN(result);
break; break;
...@@ -724,8 +742,9 @@ abstime_timestamptz(PG_FUNCTION_ARGS) ...@@ -724,8 +742,9 @@ abstime_timestamptz(PG_FUNCTION_ARGS)
default: default:
abstime2tm(abstime, &tz, tm, &tzn); abstime2tm(abstime, &tz, tm, &tzn);
if (tm2timestamp(tm, 0, &tz, &result) != 0) if (tm2timestamp(tm, 0, &tz, &result) != 0)
elog(ERROR, "Unable to convert ABSTIME to TIMESTAMP WITH TIME ZONE" ereport(ERROR,
"\n\tabstime_timestamptz() internal error"); (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range")));
break; break;
}; };
...@@ -755,11 +774,15 @@ reltimein(PG_FUNCTION_ARGS) ...@@ -755,11 +774,15 @@ reltimein(PG_FUNCTION_ARGS)
char lowstr[MAXDATELEN + 1]; char lowstr[MAXDATELEN + 1];
if (strlen(str) >= sizeof(lowstr)) 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) if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 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) switch (dtype)
{ {
...@@ -769,7 +792,8 @@ reltimein(PG_FUNCTION_ARGS) ...@@ -769,7 +792,8 @@ reltimein(PG_FUNCTION_ARGS)
break; break;
default: default:
elog(ERROR, "Bad reltime (internal coding error) '%s'", str); elog(ERROR, "unexpected dtype %d while parsing reltime \"%s\"",
dtype, str);
result = INVALID_RELTIME; result = INVALID_RELTIME;
break; break;
} }
...@@ -851,7 +875,10 @@ tintervalin(PG_FUNCTION_ARGS) ...@@ -851,7 +875,10 @@ tintervalin(PG_FUNCTION_ARGS)
interval = (TimeInterval) palloc(sizeof(TimeIntervalData)); interval = (TimeInterval) palloc(sizeof(TimeIntervalData));
if (istinterval(intervalstr, &t1, &t2) == 0) 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) if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME)
interval->status = T_INTERVAL_INVAL; /* undefined */ interval->status = T_INTERVAL_INVAL; /* undefined */
...@@ -911,7 +938,10 @@ tintervalrecv(PG_FUNCTION_ARGS) ...@@ -911,7 +938,10 @@ tintervalrecv(PG_FUNCTION_ARGS)
interval->status = pq_getmsgint(buf, sizeof(interval->status)); interval->status = pq_getmsgint(buf, sizeof(interval->status));
if (!(interval->status == T_INTERVAL_INVAL || if (!(interval->status == T_INTERVAL_INVAL ||
interval->status == T_INTERVAL_VALID)) 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[0] = pq_getmsgint(buf, sizeof(interval->data[0]));
interval->data[1] = pq_getmsgint(buf, sizeof(interval->data[1])); interval->data[1] = pq_getmsgint(buf, sizeof(interval->data[1]));
...@@ -1000,7 +1030,9 @@ reltime_interval(PG_FUNCTION_ARGS) ...@@ -1000,7 +1030,9 @@ reltime_interval(PG_FUNCTION_ARGS)
switch (reltime) switch (reltime)
{ {
case INVALID_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->time = 0;
result->month = 0; result->month = 0;
break; break;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -48,12 +48,10 @@ namein(PG_FUNCTION_ARGS)
char *s = PG_GETARG_CSTRING(0); char *s = PG_GETARG_CSTRING(0);
NameData *result; NameData *result;
int len; int len;
char *ermsg;
/* verify encoding */ /* verify encoding */
len = strlen(s); len = strlen(s);
if ((ermsg = pg_verifymbstr(s, len))) pg_verifymbstr(s, len, false);
elog(ERROR, "%s", ermsg);
len = pg_mbcliplen(s, len, NAMEDATALEN - 1); len = pg_mbcliplen(s, len, NAMEDATALEN - 1);
...@@ -87,7 +85,11 @@ namerecv(PG_FUNCTION_ARGS) ...@@ -87,7 +85,11 @@ namerecv(PG_FUNCTION_ARGS)
str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes); str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
if (nbytes >= NAMEDATALEN) 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); result = (NameData *) palloc0(NAMEDATALEN);
memcpy(result, str, nbytes); memcpy(result, str, nbytes);
pfree(str); pfree(str);
......
/* /*
* PostgreSQL type definitions for the INET and CIDR types. * 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 * Jon Postel RIP 16 Oct 1998
*/ */
...@@ -85,8 +85,11 @@ network_in(char *src, int type) ...@@ -85,8 +85,11 @@ network_in(char *src, int type)
bits = inet_net_pton(ip_family(dst), src, ip_addr(dst), bits = inet_net_pton(ip_family(dst), src, ip_addr(dst),
type ? ip_addrsize(dst) : -1); type ? ip_addrsize(dst) : -1);
if ((bits < 0) || (bits > ip_maxbits(dst))) if ((bits < 0) || (bits > ip_maxbits(dst)))
elog(ERROR, "invalid %s value '%s'", ereport(ERROR,
type ? "CIDR" : "INET", src); (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 * Error check: CIDR values must not have any bits set beyond
...@@ -95,7 +98,10 @@ network_in(char *src, int type) ...@@ -95,7 +98,10 @@ network_in(char *src, int type)
if (type) if (type)
{ {
if (!addressOK(ip_addr(dst), bits, ip_family(dst))) 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 VARATT_SIZEP(dst) = VARHDRSZ
...@@ -139,7 +145,10 @@ inet_out(PG_FUNCTION_ARGS) ...@@ -139,7 +145,10 @@ inet_out(PG_FUNCTION_ARGS)
dst = inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src), dst = inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src),
tmp, sizeof(tmp)); tmp, sizeof(tmp));
if (dst == NULL) 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 */ /* For CIDR, add /n if not present */
if (ip_type(src) && strchr(tmp, '/') == NULL) if (ip_type(src) && strchr(tmp, '/') == NULL)
{ {
...@@ -180,18 +189,25 @@ inet_recv(PG_FUNCTION_ARGS) ...@@ -180,18 +189,25 @@ inet_recv(PG_FUNCTION_ARGS)
ip_family(addr) = pq_getmsgbyte(buf); ip_family(addr) = pq_getmsgbyte(buf);
if (ip_family(addr) != AF_INET) 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); bits = pq_getmsgbyte(buf);
if (bits < 0 || bits > ip_maxbits(addr)) 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_bits(addr) = bits;
ip_type(addr) = pq_getmsgbyte(buf); ip_type(addr) = pq_getmsgbyte(buf);
if (ip_type(addr) != 0 && ip_type(addr) != 1) 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); nb = pq_getmsgbyte(buf);
if (nb != ip_addrsize(addr)) 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 VARATT_SIZEP(addr) = VARHDRSZ
+ ((char *)ip_addr(addr) - (char *) VARDATA(addr)) + ((char *)ip_addr(addr) - (char *) VARDATA(addr))
+ ip_addrsize(addr); + ip_addrsize(addr);
...@@ -207,7 +223,10 @@ inet_recv(PG_FUNCTION_ARGS) ...@@ -207,7 +223,10 @@ inet_recv(PG_FUNCTION_ARGS)
if (ip_type(addr)) if (ip_type(addr))
{ {
if (!addressOK(ip_addr(addr), bits, ip_family(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); PG_RETURN_INET_P(addr);
...@@ -291,7 +310,9 @@ inet_set_masklen(PG_FUNCTION_ARGS) ...@@ -291,7 +310,9 @@ inet_set_masklen(PG_FUNCTION_ARGS)
bits = ip_maxbits(src); bits = ip_maxbits(src);
if ((bits < 0) || (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 */ /* clone the original data */
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
...@@ -477,7 +498,9 @@ network_host(PG_FUNCTION_ARGS) ...@@ -477,7 +498,9 @@ network_host(PG_FUNCTION_ARGS)
/* force display of max bits, regardless of masklen... */ /* force display of max bits, regardless of masklen... */
if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
tmp, sizeof(tmp)) == NULL) 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) */ /* Suppress /n if present (shouldn't happen now) */
if ((ptr = strchr(tmp, '/')) != NULL) if ((ptr = strchr(tmp, '/')) != NULL)
...@@ -501,7 +524,10 @@ network_show(PG_FUNCTION_ARGS) ...@@ -501,7 +524,10 @@ network_show(PG_FUNCTION_ARGS)
if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
tmp, sizeof(tmp)) == NULL) 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) */ /* Add /n if not present (which it won't be) */
if (strchr(tmp, '/') == NULL) if (strchr(tmp, '/') == NULL)
{ {
...@@ -534,8 +560,9 @@ network_abbrev(PG_FUNCTION_ARGS) ...@@ -534,8 +560,9 @@ network_abbrev(PG_FUNCTION_ARGS)
ip_bits(ip), tmp, sizeof(tmp)); ip_bits(ip), tmp, sizeof(tmp));
if (dst == NULL) if (dst == NULL)
elog(ERROR, "unable to print address (%s)", ereport(ERROR,
strerror(errno)); (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("could not format inet value: %m")));
/* Return string as a text datum */ /* Return string as a text datum */
len = strlen(tmp); len = strlen(tmp);
...@@ -818,7 +845,7 @@ convert_network_to_scalar(Datum value, Oid typid) ...@@ -818,7 +845,7 @@ convert_network_to_scalar(Datum value, Oid typid)
* Can't get here unless someone tries to use scalarltsel/scalargtsel * Can't get here unless someone tries to use scalarltsel/scalargtsel
* on an operator with one network and one non-network operand. * 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; return 0;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -59,7 +59,10 @@ int4notin(PG_FUNCTION_ARGS)
names = textToQualifiedNameList(relation_and_attr, "int4notin"); names = textToQualifiedNameList(relation_and_attr, "int4notin");
nnames = length(names); nnames = length(names);
if (nnames < 2) 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)); attribute = strVal(nth(nnames - 1, names));
names = ltruncate(nnames - 1, names); names = ltruncate(nnames - 1, names);
relrv = makeRangeVarFromNameList(names); relrv = makeRangeVarFromNameList(names);
......
This diff is collapsed.
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * 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,27 +51,28 @@ ...@@ -51,27 +51,28 @@
* c, if not 0, is the terminator character that may appear after the * c, if not 0, is the terminator character that may appear after the
* integer. If 0, the string must end after the integer. * 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. * overflow.
*/ */
int32 int32
pg_atoi(char *s, int size, int c) pg_atoi(char *s, int size, int c)
{ {
long l = 0; long l;
char *badp = NULL; char *badp = NULL;
errno = 0;
/* /*
* Some versions of strtol treat the empty string as an error, but * 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. * some seem not to. Make an explicit test to be sure we catch it.
*/ */
if (s == (char *) NULL) if (s == (char *) NULL)
elog(ERROR, "pg_atoi: NULL pointer"); elog(ERROR, "NULL pointer");
else if (*s == 0) if (*s == 0)
elog(ERROR, "pg_atoi: zero-length string"); ereport(ERROR,
else (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"",
s)));
errno = 0;
l = strtol(s, &badp, 10); l = strtol(s, &badp, 10);
/* /*
...@@ -79,54 +80,44 @@ pg_atoi(char *s, int size, int c) ...@@ -79,54 +80,44 @@ pg_atoi(char *s, int size, int c)
* set EINVAL, which simply means it couldn't parse the input string. * set EINVAL, which simply means it couldn't parse the input string.
* This is handled by the second "if" consistent across platforms. * This is handled by the second "if" consistent across platforms.
*/ */
if (errno && errno != EINVAL) if (errno && errno != ERANGE && errno != EINVAL)
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s); ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"",
s)));
if (badp && *badp && *badp != c) 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) switch (size)
{ {
case sizeof(int32): case sizeof(int32):
if (errno == ERANGE
#if defined(HAVE_LONG_INT_64) #if defined(HAVE_LONG_INT_64)
/* won't get ERANGE on these with 64-bit longs... */ /* won't get ERANGE on these with 64-bit longs... */
if (l < INT_MIN) || l < INT_MIN || l > INT_MAX
{ #endif
errno = ERANGE; )
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s); ereport(ERROR,
} (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
if (l > INT_MAX) errmsg("%s is out of range for int4", s)));
{
errno = ERANGE;
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
}
#endif /* HAVE_LONG_INT_64 */
break; break;
case sizeof(int16): case sizeof(int16):
if (l < SHRT_MIN) if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX)
{ ereport(ERROR,
errno = ERANGE; (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s); errmsg("%s is out of range for int2", s)));
}
if (l > SHRT_MAX)
{
errno = ERANGE;
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
}
break; break;
case sizeof(int8): case sizeof(int8):
if (l < SCHAR_MIN) if (errno == ERANGE || l < SCHAR_MIN || l > SCHAR_MAX)
{ ereport(ERROR,
errno = ERANGE; (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s); errmsg("%s is out of range for int1", s)));
}
if (l > SCHAR_MAX)
{
errno = ERANGE;
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
}
break; break;
default: default:
elog(ERROR, "pg_atoi: invalid result size: %d", size); elog(ERROR, "unsupported result size: %d", size);
} }
return (int32) l; return (int32) l;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -34,7 +34,6 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
Oid result; Oid result;
errno = 0; errno = 0;
cvt = strtoul(s, &endptr, 10); cvt = strtoul(s, &endptr, 10);
/* /*
...@@ -44,12 +43,21 @@ oidin_subr(const char *funcname, const char *s, char **endloc) ...@@ -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 * Note that for historical reasons we accept an empty string as
* meaning 0. * meaning 0.
*/ */
if (errno && errno != EINVAL) if (errno && errno != ERANGE && errno != EINVAL)
elog(ERROR, "%s: error reading \"%s\": %m", ereport(ERROR,
funcname, s); (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for OID: \"%s\"",
s)));
if (endptr == s && *endptr) if (endptr == s && *endptr)
elog(ERROR, "%s: error in \"%s\": can't parse \"%s\"", ereport(ERROR,
funcname, s, endptr); (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) if (endloc)
{ {
...@@ -62,8 +70,10 @@ oidin_subr(const char *funcname, const char *s, char **endloc) ...@@ -62,8 +70,10 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
while (*endptr && isspace((unsigned char) *endptr)) while (*endptr && isspace((unsigned char) *endptr))
endptr++; endptr++;
if (*endptr) if (*endptr)
elog(ERROR, "%s: error in \"%s\": can't parse \"%s\"", ereport(ERROR,
funcname, s, endptr); (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for OID: \"%s\"",
s)));
} }
result = (Oid) cvt; result = (Oid) cvt;
...@@ -83,8 +93,9 @@ oidin_subr(const char *funcname, const char *s, char **endloc) ...@@ -83,8 +93,9 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
#if OID_MAX != ULONG_MAX #if OID_MAX != ULONG_MAX
if (cvt != (unsigned long) result && if (cvt != (unsigned long) result &&
cvt != (unsigned long) ((int) result)) cvt != (unsigned long) ((int) result))
elog(ERROR, "%s: error reading \"%s\": %s", ereport(ERROR,
funcname, s, strerror(ERANGE)); (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("%s is out of range for OID", s)));
#endif #endif
return result; return result;
...@@ -160,7 +171,9 @@ oidvectorin(PG_FUNCTION_ARGS) ...@@ -160,7 +171,9 @@ oidvectorin(PG_FUNCTION_ARGS)
while (*oidString && isspace((unsigned char) *oidString)) while (*oidString && isspace((unsigned char) *oidString))
oidString++; oidString++;
if (*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) while (slot < INDEX_MAX_KEYS)
result[slot++] = InvalidOid; result[slot++] = InvalidOid;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -201,7 +201,9 @@ lpad(PG_FUNCTION_ARGS)
/* check for integer overflow */ /* check for integer overflow */
if (len != 0 && bytelen / pg_database_encoding_max_length() != len) 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); ret = (text *) palloc(VARHDRSZ + bytelen);
...@@ -296,7 +298,9 @@ rpad(PG_FUNCTION_ARGS) ...@@ -296,7 +298,9 @@ rpad(PG_FUNCTION_ARGS)
/* Check for integer overflow */ /* Check for integer overflow */
if (len != 0 && bytelen / pg_database_encoding_max_length() != len) 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); ret = (text *) palloc(VARHDRSZ + bytelen);
m = len - s1len; m = len - s1len;
...@@ -917,7 +921,9 @@ repeat(PG_FUNCTION_ARGS) ...@@ -917,7 +921,9 @@ repeat(PG_FUNCTION_ARGS)
int check2 = check + VARHDRSZ; int check2 = check + VARHDRSZ;
if ((check / slen) != count || check2 <= check) 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); result = (text *) palloc(tlen);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 2002, PostgreSQL Global Development Group * 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) ...@@ -157,7 +157,7 @@ lc_collate_is_c(void)
return (bool) result; return (bool) result;
localeptr = setlocale(LC_COLLATE, NULL); localeptr = setlocale(LC_COLLATE, NULL);
if (!localeptr) if (!localeptr)
elog(PANIC, "Invalid LC_COLLATE setting"); elog(ERROR, "invalid LC_COLLATE setting");
if (strcmp(localeptr, "C") == 0) if (strcmp(localeptr, "C") == 0)
result = true; result = true;
......
...@@ -186,12 +186,16 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS) ...@@ -186,12 +186,16 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
if (fcinfo->resultinfo == NULL || if (fcinfo->resultinfo == NULL ||
!IsA(fcinfo->resultinfo, ReturnSetInfo)) !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_extra == NULL)
{ {
if (fmgr_info->fn_mcxt == 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, fmgr_info->fn_extra = MemoryContextAlloc(fmgr_info->fn_mcxt,
2 * sizeof(int)); 2 * sizeof(int));
((int *) (fmgr_info->fn_extra))[0] = 0; ((int *) (fmgr_info->fn_extra))[0] = 0;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * 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 @@ ...@@ -33,7 +33,9 @@
Datum Datum
record_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -44,7 +46,9 @@ record_in(PG_FUNCTION_ARGS) ...@@ -44,7 +46,9 @@ record_in(PG_FUNCTION_ARGS)
Datum Datum
record_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -55,7 +59,9 @@ record_out(PG_FUNCTION_ARGS) ...@@ -55,7 +59,9 @@ record_out(PG_FUNCTION_ARGS)
Datum Datum
record_recv(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -66,7 +72,9 @@ record_recv(PG_FUNCTION_ARGS) ...@@ -66,7 +72,9 @@ record_recv(PG_FUNCTION_ARGS)
Datum Datum
record_send(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -134,7 +142,9 @@ cstring_send(PG_FUNCTION_ARGS) ...@@ -134,7 +142,9 @@ cstring_send(PG_FUNCTION_ARGS)
Datum Datum
any_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -145,7 +155,9 @@ any_in(PG_FUNCTION_ARGS) ...@@ -145,7 +155,9 @@ any_in(PG_FUNCTION_ARGS)
Datum Datum
any_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -157,7 +169,9 @@ any_out(PG_FUNCTION_ARGS) ...@@ -157,7 +169,9 @@ any_out(PG_FUNCTION_ARGS)
Datum Datum
anyarray_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -183,7 +197,9 @@ anyarray_out(PG_FUNCTION_ARGS) ...@@ -183,7 +197,9 @@ anyarray_out(PG_FUNCTION_ARGS)
Datum Datum
anyarray_recv(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -231,7 +247,9 @@ void_out(PG_FUNCTION_ARGS) ...@@ -231,7 +247,9 @@ void_out(PG_FUNCTION_ARGS)
Datum Datum
trigger_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -242,7 +260,9 @@ trigger_in(PG_FUNCTION_ARGS) ...@@ -242,7 +260,9 @@ trigger_in(PG_FUNCTION_ARGS)
Datum Datum
trigger_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -254,7 +274,9 @@ trigger_out(PG_FUNCTION_ARGS) ...@@ -254,7 +274,9 @@ trigger_out(PG_FUNCTION_ARGS)
Datum Datum
language_handler_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -265,7 +287,9 @@ language_handler_in(PG_FUNCTION_ARGS) ...@@ -265,7 +287,9 @@ language_handler_in(PG_FUNCTION_ARGS)
Datum Datum
language_handler_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -277,7 +301,9 @@ language_handler_out(PG_FUNCTION_ARGS) ...@@ -277,7 +301,9 @@ language_handler_out(PG_FUNCTION_ARGS)
Datum Datum
internal_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -288,7 +314,9 @@ internal_in(PG_FUNCTION_ARGS) ...@@ -288,7 +314,9 @@ internal_in(PG_FUNCTION_ARGS)
Datum Datum
internal_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -300,7 +328,9 @@ internal_out(PG_FUNCTION_ARGS) ...@@ -300,7 +328,9 @@ internal_out(PG_FUNCTION_ARGS)
Datum Datum
opaque_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -311,7 +341,9 @@ opaque_in(PG_FUNCTION_ARGS) ...@@ -311,7 +341,9 @@ opaque_in(PG_FUNCTION_ARGS)
Datum Datum
opaque_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -323,7 +355,9 @@ opaque_out(PG_FUNCTION_ARGS) ...@@ -323,7 +355,9 @@ opaque_out(PG_FUNCTION_ARGS)
Datum Datum
anyelement_in(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -334,7 +368,9 @@ anyelement_in(PG_FUNCTION_ARGS) ...@@ -334,7 +368,9 @@ anyelement_in(PG_FUNCTION_ARGS)
Datum Datum
anyelement_out(PG_FUNCTION_ARGS) 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 */ PG_RETURN_VOID(); /* keep compiler quiet */
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance * 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, ...@@ -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)); pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg));
/* XXX should we pg_regfree here? */ /* 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, ...@@ -182,7 +184,9 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
if (re_temp.cre_pat == NULL) if (re_temp.cre_pat == NULL)
{ {
pg_regfree(&re_temp.cre_re); 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); memcpy(re_temp.cre_pat, text_re, text_re_len);
re_temp.cre_flags = cflags; re_temp.cre_flags = cflags;
...@@ -450,7 +454,10 @@ similar_escape(PG_FUNCTION_ARGS) ...@@ -450,7 +454,10 @@ similar_escape(PG_FUNCTION_ARGS)
if (elen == 0) if (elen == 0)
e = NULL; /* no escape character */ e = NULL; /* no escape character */
else if (elen != 1) 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 */ /* We need room for ^, $, and up to 2 output bytes per input byte */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -112,10 +112,16 @@ regprocin(PG_FUNCTION_ARGS)
heap_close(hdesc, AccessShareLock); heap_close(hdesc, AccessShareLock);
if (matches == 0) 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) else if (matches > 1)
elog(ERROR, "There is more than one procedure named %s", ereport(ERROR,
pro_name_or_oid); (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("more than one procedure named %s",
pro_name_or_oid)));
PG_RETURN_OID(result); PG_RETURN_OID(result);
} }
...@@ -127,10 +133,14 @@ regprocin(PG_FUNCTION_ARGS) ...@@ -127,10 +133,14 @@ regprocin(PG_FUNCTION_ARGS)
clist = FuncnameGetCandidates(names, -1); clist = FuncnameGetCandidates(names, -1);
if (clist == NULL) 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) else if (clist->next != NULL)
elog(ERROR, "There is more than one procedure named %s", ereport(ERROR,
pro_name_or_oid); (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("more than one procedure named %s",
pro_name_or_oid)));
result = clist->oid; result = clist->oid;
...@@ -275,7 +285,9 @@ regprocedurein(PG_FUNCTION_ARGS) ...@@ -275,7 +285,9 @@ regprocedurein(PG_FUNCTION_ARGS)
} }
if (clist == NULL) 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; result = clist->oid;
...@@ -450,10 +462,15 @@ regoperin(PG_FUNCTION_ARGS) ...@@ -450,10 +462,15 @@ regoperin(PG_FUNCTION_ARGS)
heap_close(hdesc, AccessShareLock); heap_close(hdesc, AccessShareLock);
if (matches == 0) 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) else if (matches > 1)
elog(ERROR, "There is more than one operator named %s", ereport(ERROR,
opr_name_or_oid); (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("more than one operator named %s",
opr_name_or_oid)));
PG_RETURN_OID(result); PG_RETURN_OID(result);
} }
...@@ -465,10 +482,14 @@ regoperin(PG_FUNCTION_ARGS) ...@@ -465,10 +482,14 @@ regoperin(PG_FUNCTION_ARGS)
clist = OpernameGetCandidates(names, '\0'); clist = OpernameGetCandidates(names, '\0');
if (clist == NULL) 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) else if (clist->next != NULL)
elog(ERROR, "There is more than one operator named %s", ereport(ERROR,
opr_name_or_oid); (errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("more than one operator named %s",
opr_name_or_oid)));
result = clist->oid; result = clist->oid;
...@@ -613,9 +634,15 @@ regoperatorin(PG_FUNCTION_ARGS) ...@@ -613,9 +634,15 @@ regoperatorin(PG_FUNCTION_ARGS)
parseNameAndArgTypes(opr_name_or_oid, "regoperatorin", true, parseNameAndArgTypes(opr_name_or_oid, "regoperatorin", true,
&names, &nargs, argtypes); &names, &nargs, argtypes);
if (nargs == 1) 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) 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) if (argtypes[0] == InvalidOid)
oprkind = 'l'; oprkind = 'l';
...@@ -633,7 +660,9 @@ regoperatorin(PG_FUNCTION_ARGS) ...@@ -633,7 +660,9 @@ regoperatorin(PG_FUNCTION_ARGS)
} }
if (clist == NULL) 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; result = clist->oid;
...@@ -803,7 +832,9 @@ regclassin(PG_FUNCTION_ARGS) ...@@ -803,7 +832,9 @@ regclassin(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
result = HeapTupleGetOid(tuple); result = HeapTupleGetOid(tuple);
else 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 */ /* We assume there can be only one match */
...@@ -967,7 +998,9 @@ regtypein(PG_FUNCTION_ARGS) ...@@ -967,7 +998,9 @@ regtypein(PG_FUNCTION_ARGS)
if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
result = HeapTupleGetOid(tuple); result = HeapTupleGetOid(tuple);
else 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 */ /* We assume there can be only one match */
...@@ -1072,10 +1105,14 @@ stringToQualifiedNameList(const char *string, const char *caller) ...@@ -1072,10 +1105,14 @@ stringToQualifiedNameList(const char *string, const char *caller)
rawname = pstrdup(string); rawname = pstrdup(string);
if (!SplitIdentifierString(rawname, '.', &namelist)) if (!SplitIdentifierString(rawname, '.', &namelist))
elog(ERROR, "%s: invalid name syntax", caller); ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid name syntax")));
if (namelist == NIL) if (namelist == NIL)
elog(ERROR, "%s: invalid name syntax", caller); ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid name syntax")));
foreach(l, namelist) foreach(l, namelist)
{ {
...@@ -1132,7 +1169,9 @@ parseNameAndArgTypes(const char *string, const char *caller, ...@@ -1132,7 +1169,9 @@ parseNameAndArgTypes(const char *string, const char *caller,
break; break;
} }
if (*ptr == '\0') 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 */ /* Separate the name and parse it into a list */
*ptr++ = '\0'; *ptr++ = '\0';
...@@ -1146,7 +1185,10 @@ parseNameAndArgTypes(const char *string, const char *caller, ...@@ -1146,7 +1185,10 @@ parseNameAndArgTypes(const char *string, const char *caller,
break; break;
} }
if (*ptr2 != ')') if (*ptr2 != ')')
elog(ERROR, "%s: expected a right parenthesis", caller); ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("expected a right parenthesis")));
*ptr2 = '\0'; *ptr2 = '\0';
/* Separate the remaining string into comma-separated type names */ /* Separate the remaining string into comma-separated type names */
...@@ -1162,7 +1204,9 @@ parseNameAndArgTypes(const char *string, const char *caller, ...@@ -1162,7 +1204,9 @@ parseNameAndArgTypes(const char *string, const char *caller,
{ {
/* End of string. Okay unless we had a comma before. */ /* End of string. Okay unless we had a comma before. */
if (had_comma) if (had_comma)
elog(ERROR, "%s: expected a type name", caller); ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("expected a type name")));
break; break;
} }
typename = ptr; typename = ptr;
...@@ -1192,7 +1236,10 @@ parseNameAndArgTypes(const char *string, const char *caller, ...@@ -1192,7 +1236,10 @@ parseNameAndArgTypes(const char *string, const char *caller,
} }
} }
if (in_quote || paren_count != 0) 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; ptr2 = ptr;
if (*ptr == ',') if (*ptr == ',')
{ {
...@@ -1224,7 +1271,10 @@ parseNameAndArgTypes(const char *string, const char *caller, ...@@ -1224,7 +1271,10 @@ parseNameAndArgTypes(const char *string, const char *caller,
parseTypeString(typename, &typeid, &typmod); parseTypeString(typename, &typeid, &typmod);
} }
if (*nargs >= FUNC_MAX_ARGS) 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; argtypes[*nargs] = typeid;
(*nargs)++; (*nargs)++;
} }
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -939,7 +939,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
prefix->constvalue)); prefix->constvalue));
break; break;
default: default:
elog(ERROR, "patternsel: unexpected consttype %u", elog(ERROR, "unrecognized consttype: %u",
prefix->consttype); prefix->consttype);
return DEFAULT_MATCH_SEL; return DEFAULT_MATCH_SEL;
} }
...@@ -956,7 +956,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) ...@@ -956,7 +956,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
List *eqargs; List *eqargs;
if (eqopr == InvalidOid) if (eqopr == InvalidOid)
elog(ERROR, "patternsel: no = operator for opclass %u", opclass); elog(ERROR, "no = operator for opclass %u", opclass);
eqargs = makeList2(var, prefix); eqargs = makeList2(var, prefix);
result = DatumGetFloat8(DirectFunctionCall4(eqsel, result = DatumGetFloat8(DirectFunctionCall4(eqsel,
PointerGetDatum(root), PointerGetDatum(root),
...@@ -1136,7 +1136,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg, ...@@ -1136,7 +1136,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
varRelid, jointype); varRelid, jointype);
break; break;
default: default:
elog(ERROR, "booltestsel: unexpected booltesttype %d", elog(ERROR, "unrecognized booltesttype: %d",
(int) booltesttype); (int) booltesttype);
selec = 0.0; /* Keep compiler quiet */ selec = 0.0; /* Keep compiler quiet */
break; break;
...@@ -1213,7 +1213,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg, ...@@ -1213,7 +1213,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
selec = 1.0 - freq_false; selec = 1.0 - freq_false;
break; break;
default: default:
elog(ERROR, "booltestsel: unexpected booltesttype %d", elog(ERROR, "unrecognized booltesttype: %d",
(int) booltesttype); (int) booltesttype);
selec = 0.0; /* Keep compiler quiet */ selec = 0.0; /* Keep compiler quiet */
break; break;
...@@ -1254,7 +1254,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg, ...@@ -1254,7 +1254,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
selec = (1.0 - freq_null) / 2.0; selec = (1.0 - freq_null) / 2.0;
break; break;
default: default:
elog(ERROR, "booltestsel: unexpected booltesttype %d", elog(ERROR, "unrecognized booltesttype: %d",
(int) booltesttype); (int) booltesttype);
selec = 0.0; /* Keep compiler quiet */ selec = 0.0; /* Keep compiler quiet */
break; break;
...@@ -1284,7 +1284,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg, ...@@ -1284,7 +1284,7 @@ booltestsel(Query *root, BoolTestType booltesttype, Node *arg,
selec = DEFAULT_BOOL_SEL; selec = DEFAULT_BOOL_SEL;
break; break;
default: default:
elog(ERROR, "booltestsel: unexpected booltesttype %d", elog(ERROR, "unrecognized booltesttype: %d",
(int) booltesttype); (int) booltesttype);
selec = 0.0; /* Keep compiler quiet */ selec = 0.0; /* Keep compiler quiet */
break; break;
...@@ -1319,7 +1319,7 @@ nulltestsel(Query *root, NullTestType nulltesttype, Node *arg, int varRelid) ...@@ -1319,7 +1319,7 @@ nulltestsel(Query *root, NullTestType nulltesttype, Node *arg, int varRelid)
defselec = DEFAULT_NOT_UNK_SEL; defselec = DEFAULT_NOT_UNK_SEL;
break; break;
default: default:
elog(ERROR, "nulltestsel: unexpected nulltesttype %d", elog(ERROR, "unrecognized nulltesttype: %d",
(int) nulltesttype); (int) nulltesttype);
return (Selectivity) 0; /* keep compiler quiet */ return (Selectivity) 0; /* keep compiler quiet */
} }
...@@ -1373,7 +1373,7 @@ nulltestsel(Query *root, NullTestType nulltesttype, Node *arg, int varRelid) ...@@ -1373,7 +1373,7 @@ nulltestsel(Query *root, NullTestType nulltesttype, Node *arg, int varRelid)
selec = 1.0 - freq_null; selec = 1.0 - freq_null;
break; break;
default: default:
elog(ERROR, "nulltestsel: unexpected nulltesttype %d", elog(ERROR, "unrecognized nulltesttype: %d",
(int) nulltesttype); (int) nulltesttype);
return (Selectivity) 0; /* keep compiler quiet */ return (Selectivity) 0; /* keep compiler quiet */
} }
...@@ -2500,7 +2500,7 @@ convert_numeric_to_scalar(Datum value, Oid typid) ...@@ -2500,7 +2500,7 @@ convert_numeric_to_scalar(Datum value, Oid typid)
* Can't get here unless someone tries to use scalarltsel/scalargtsel * Can't get here unless someone tries to use scalarltsel/scalargtsel
* on an operator with one numeric and one non-numeric operand. * 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; return 0;
} }
...@@ -2684,7 +2684,7 @@ convert_string_datum(Datum value, Oid typid) ...@@ -2684,7 +2684,7 @@ convert_string_datum(Datum value, Oid typid)
* Can't get here unless someone tries to use scalarltsel on * Can't get here unless someone tries to use scalarltsel on
* an operator with one string and one non-string operand. * 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; return NULL;
} }
...@@ -2882,7 +2882,7 @@ convert_timevalue_to_scalar(Datum value, Oid typid) ...@@ -2882,7 +2882,7 @@ convert_timevalue_to_scalar(Datum value, Oid typid)
* Can't get here unless someone tries to use scalarltsel/scalargtsel * Can't get here unless someone tries to use scalarltsel/scalargtsel
* on an operator with one timevalue and one non-timevalue operand. * 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; return 0;
} }
...@@ -3111,7 +3111,9 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, ...@@ -3111,7 +3111,9 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
Assert(typeid == BYTEAOID || typeid == TEXTOID); Assert(typeid == BYTEAOID || typeid == TEXTOID);
if (typeid == BYTEAOID && case_insensitive) 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) if (typeid != BYTEAOID)
{ {
...@@ -3194,7 +3196,9 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, ...@@ -3194,7 +3196,9 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
* been made safe for binary (possibly NULL containing) strings. * been made safe for binary (possibly NULL containing) strings.
*/ */
if (typeid == BYTEAOID) 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 */ /* the right-hand const is type text for all of these */
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue)); patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
...@@ -3337,7 +3341,7 @@ pattern_fixed_prefix(Const *patt, Pattern_Type ptype, ...@@ -3337,7 +3341,7 @@ pattern_fixed_prefix(Const *patt, Pattern_Type ptype,
result = regex_fixed_prefix(patt, true, prefix, rest); result = regex_fixed_prefix(patt, true, prefix, rest);
break; break;
default: default:
elog(ERROR, "pattern_fixed_prefix: bogus ptype"); elog(ERROR, "unrecognized ptype: %d", (int) ptype);
result = Pattern_Prefix_None; /* keep compiler quiet */ result = Pattern_Prefix_None; /* keep compiler quiet */
break; break;
} }
...@@ -3368,8 +3372,7 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon) ...@@ -3368,8 +3372,7 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon)
cmpopr = get_opclass_member(opclass, BTGreaterEqualStrategyNumber); cmpopr = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
if (cmpopr == InvalidOid) if (cmpopr == InvalidOid)
elog(ERROR, "prefix_selectivity: no >= operator for opclass %u", elog(ERROR, "no >= operator for opclass %u", opclass);
opclass);
cmpargs = makeList2(var, prefixcon); cmpargs = makeList2(var, prefixcon);
/* Assume scalargtsel is appropriate for all supported types */ /* Assume scalargtsel is appropriate for all supported types */
prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel, prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel,
...@@ -3390,8 +3393,7 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon) ...@@ -3390,8 +3393,7 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon)
cmpopr = get_opclass_member(opclass, BTLessStrategyNumber); cmpopr = get_opclass_member(opclass, BTLessStrategyNumber);
if (cmpopr == InvalidOid) if (cmpopr == InvalidOid)
elog(ERROR, "prefix_selectivity: no < operator for opclass %u", elog(ERROR, "no < operator for opclass %u", opclass);
opclass);
cmpargs = makeList2(var, greaterstrcon); cmpargs = makeList2(var, greaterstrcon);
/* Assume scalarltsel is appropriate for all supported types */ /* Assume scalarltsel is appropriate for all supported types */
topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel, topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel,
...@@ -3472,7 +3474,9 @@ like_selectivity(Const *patt_const, bool case_insensitive) ...@@ -3472,7 +3474,9 @@ like_selectivity(Const *patt_const, bool case_insensitive)
Assert(typeid == BYTEAOID || typeid == TEXTOID); Assert(typeid == BYTEAOID || typeid == TEXTOID);
if (typeid == BYTEAOID && case_insensitive) 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) if (typeid != BYTEAOID)
{ {
...@@ -3618,7 +3622,9 @@ regex_selectivity(Const *patt_const, bool case_insensitive) ...@@ -3618,7 +3622,9 @@ regex_selectivity(Const *patt_const, bool case_insensitive)
* been made safe for binary (possibly NULL containing) strings. * been made safe for binary (possibly NULL containing) strings.
*/ */
if (typeid == BYTEAOID) 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 */ /* the right-hand const is type text for all of these */
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue)); patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
...@@ -3662,7 +3668,7 @@ pattern_selectivity(Const *patt, Pattern_Type ptype) ...@@ -3662,7 +3668,7 @@ pattern_selectivity(Const *patt, Pattern_Type ptype)
result = regex_selectivity(patt, true); result = regex_selectivity(patt, true);
break; break;
default: default:
elog(ERROR, "pattern_selectivity: bogus ptype"); elog(ERROR, "unrecognized ptype: %d", (int) ptype);
result = 1.0; /* keep compiler quiet */ result = 1.0; /* keep compiler quiet */
break; break;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -83,7 +83,7 @@ SetDefine(char *querystr, Oid elemType)
ObjectIdGetDatum(setoid), ObjectIdGetDatum(setoid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) 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 * We can tell whether the set was already defined by checking the
...@@ -201,7 +201,10 @@ seteval(PG_FUNCTION_ARGS) ...@@ -201,7 +201,10 @@ seteval(PG_FUNCTION_ARGS)
if (rsi && IsA(rsi, ReturnSetInfo)) if (rsi && IsA(rsi, ReturnSetInfo))
rsi->isDone = isDone; rsi->isDone = isDone;
else 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); PG_RETURN_DATUM(result);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* $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 #ifndef PG_WCHAR_H
#define PG_WCHAR_H #define PG_WCHAR_H
...@@ -323,7 +323,7 @@ extern void LocalToUtf(unsigned char *iso, unsigned char *utf, ...@@ -323,7 +323,7 @@ extern void LocalToUtf(unsigned char *iso, unsigned char *utf,
extern void UtfToLocal(unsigned char *utf, unsigned char *iso, extern void UtfToLocal(unsigned char *utf, unsigned char *iso,
pg_utf_to_local *map, int size, int len); 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_ascii2mic(unsigned char *src, unsigned char *dest, int len);
extern void pg_mic2ascii(unsigned char *src, unsigned char *dest, int len); extern void pg_mic2ascii(unsigned char *src, unsigned char *dest, int len);
......
This diff is collapsed.
...@@ -28,12 +28,12 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity'); ...@@ -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'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
-- what happens if we specify slightly misformatted abstime? -- what happens if we specify slightly misformatted abstime?
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00'); 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'); 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 -- badly formatted abstimes: these should result in invalid abstimes
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format'); 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'); INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
-- test abstime operators -- test abstime operators
SELECT '' AS eight, ABSTIME_TBL.*; SELECT '' AS eight, ABSTIME_TBL.*;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment