break;
default:
/* result type isn't composite */
- elog(ERROR, "return type must be a row type");
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("return type must be a row type")));
break;
}
appendStringInfo(&chk_current_key, "%s%s%s",
branch_delim, current_key, branch_delim);
if (strstr(chk_branchstr.data, chk_current_key.data))
- elog(ERROR, "infinite recursion detected");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_RECURSION),
+ errmsg("infinite recursion detected")));
}
/* OK, extend the branch */
{
if (tupdesc->natts != (CONNECTBY_NCOLS + serial_column))
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("Query-specified return tuple has " \
"wrong number of columns.")));
{
if (tupdesc->natts != CONNECTBY_NCOLS_NOBRANCH + serial_column)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("Query-specified return tuple has " \
"wrong number of columns.")));
/* check that the types of the first two columns match */
if (tupdesc->attrs[0]->atttypid != tupdesc->attrs[1]->atttypid)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("First two columns must be the same type.")));
/* check that the type of the third column is INT4 */
if (tupdesc->attrs[2]->atttypid != INT4OID)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("Third column must be type %s.",
format_type_be(INT4OID))));
/* check that the type of the fourth column is TEXT if applicable */
if (show_branch && tupdesc->attrs[3]->atttypid != TEXTOID)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("Fourth column must be type %s.",
format_type_be(TEXTOID))));
/* check that the type of the fifth column is INT4 */
if (show_branch && show_serial && tupdesc->attrs[4]->atttypid != INT4OID)
- elog(ERROR, "query-specified return tuple not valid for Connectby: "
- "fifth column must be type %s", format_type_be(INT4OID));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("query-specified return tuple not valid for Connectby: "
+ "fifth column must be type %s",
+ format_type_be(INT4OID))));
/* check that the type of the fifth column is INT4 */
if (!show_branch && show_serial && tupdesc->attrs[3]->atttypid != INT4OID)
- elog(ERROR, "query-specified return tuple not valid for Connectby: "
- "fourth column must be type %s", format_type_be(INT4OID));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("query-specified return tuple not valid for Connectby: "
+ "fourth column must be type %s",
+ format_type_be(INT4OID))));
/* OK, the tupdesc is valid for our purposes */
}
*/
if (sql_tupdesc->natts < 2)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("Query must return at least two columns.")));
if (ret_atttypid != sql_atttypid ||
(ret_atttypmod >= 0 && ret_atttypmod != sql_atttypmod))
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("SQL key field type %s does " \
"not match return key field type %s.",
if (ret_atttypid != sql_atttypid ||
(ret_atttypmod >= 0 && ret_atttypmod != sql_atttypmod))
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("SQL parent key field type %s does " \
"not match return parent key field type %s.",
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid return type"),
errdetail("SQL rowid datatype does not match " \
"return rowid datatype.")));
size = sizeof(relopt_string);
break;
default:
- elog(ERROR, "unsupported option type");
+ elog(ERROR, "unsupported reloption type %d", type);
return NULL; /* keep compiler quiet */
}
parsed = parse_bool(value, &option->values.bool_val);
if (validate && !parsed)
ereport(ERROR,
- (errmsg("invalid value for boolean option \"%s\": %s",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid value for boolean option \"%s\": %s",
option->gen->name, value)));
}
break;
parsed = parse_int(value, &option->values.int_val, 0, NULL);
if (validate && !parsed)
ereport(ERROR,
- (errmsg("invalid value for integer option \"%s\": %s",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid value for integer option \"%s\": %s",
option->gen->name, value)));
if (validate && (option->values.int_val < optint->min ||
option->values.int_val > optint->max))
ereport(ERROR,
- (errmsg("value %s out of bounds for option \"%s\"",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("value %s out of bounds for option \"%s\"",
value, option->gen->name),
errdetail("Valid values are between \"%d\" and \"%d\".",
optint->min, optint->max)));
parsed = parse_real(value, &option->values.real_val);
if (validate && !parsed)
ereport(ERROR,
- (errmsg("invalid value for floating point option \"%s\": %s",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid value for floating point option \"%s\": %s",
option->gen->name, value)));
if (validate && (option->values.real_val < optreal->min ||
option->values.real_val > optreal->max))
ereport(ERROR,
- (errmsg("value %s out of bounds for option \"%s\"",
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("value %s out of bounds for option \"%s\"",
value, option->gen->name),
errdetail("Valid values are between \"%f\" and \"%f\".",
optreal->min, optreal->max)));
}
break;
default:
- elog(ERROR, "unrecognized reloption type %c",
+ elog(ERROR, "unsupported reloption type %d",
options[i].gen->type);
break;
}
if (result == HeapTupleInvisible)
{
UnlockReleaseBuffer(buffer);
- elog(ERROR, "attempted to delete invisible tuple");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("attempted to delete invisible tuple")));
}
else if (result == HeapTupleBeingUpdated && wait)
{
if (result == HeapTupleInvisible)
{
UnlockReleaseBuffer(buffer);
- elog(ERROR, "attempted to update invisible tuple");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("attempted to update invisible tuple")));
}
else if (result == HeapTupleBeingUpdated && wait)
{
* in any RLS clauses.
*
* When this happens, we are passed in the relid of the originally
- * found relation (which we have locked). As the planner will look
- * up the relation again, we double-check here to make sure it found
- * the same one that we have locked.
+ * found relation (which we have locked). As the planner will look up
+ * the relation again, we double-check here to make sure it found the
+ * same one that we have locked.
*/
if (queryRelId != InvalidOid)
{
pclose_rc = ClosePipeStream(cstate->copy_file);
if (pclose_rc == -1)
ereport(ERROR,
- (errmsg("could not close pipe to external command: %m")));
+ (errcode_for_file_access(),
+ errmsg("could not close pipe to external command: %m")));
else if (pclose_rc != 0)
ereport(ERROR,
- (errmsg("program \"%s\" failed",
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("program \"%s\" failed",
cstate->filename),
errdetail_internal("%s", wait_result_to_str(pclose_rc))));
}
cstate->copy_file = OpenPipeStream(cstate->filename, PG_BINARY_W);
if (cstate->copy_file == NULL)
ereport(ERROR,
- (errmsg("could not execute command \"%s\": %m",
+ (errcode_for_file_access(),
+ errmsg("could not execute command \"%s\": %m",
cstate->filename)));
}
else
cstate->filename)));
if (fstat(fileno(cstate->copy_file), &st))
- elog(ERROR, "could not stat file \"%s\": %m", cstate->filename);
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not stat file \"%s\": %m",
+ cstate->filename)));
if (S_ISDIR(st.st_mode))
ereport(ERROR,
{
if (!ThereAreNoPriorRegisteredSnapshots() || !ThereAreNoReadyPortals())
ereport(ERROR,
- (ERRCODE_INVALID_TRANSACTION_STATE,
+ (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
errmsg("cannot perform FREEZE because of prior transaction activity")));
if (cstate->rel->rd_createSubid != GetCurrentSubTransactionId() &&
cstate->rel->rd_newRelfilenodeSubid != GetCurrentSubTransactionId())
ereport(ERROR,
- (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot perform FREEZE because the table was not created or truncated in the current subtransaction")));
hi_options |= HEAP_INSERT_FROZEN;
cstate->copy_file = OpenPipeStream(cstate->filename, PG_BINARY_R);
if (cstate->copy_file == NULL)
ereport(ERROR,
- (errmsg("could not execute command \"%s\": %m",
+ (errcode_for_file_access(),
+ errmsg("could not execute command \"%s\": %m",
cstate->filename)));
}
else
cstate->filename)));
if (fstat(fileno(cstate->copy_file), &st))
- elog(ERROR, "could not stat file \"%s\": %m", cstate->filename);
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not stat file \"%s\": %m",
+ cstate->filename)));
if (S_ISDIR(st.st_mode))
ereport(ERROR,
* calls a hostile index expression that itself calls ANALYZE.
*/
if (in_vacuum)
- elog(ERROR, "%s cannot be executed from VACUUM or ANALYZE", stmttype);
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("%s cannot be executed from VACUUM or ANALYZE",
+ stmttype)));
/*
* Send info about dead objects to the statistics collector, unless we are
{
if (variable->vartype != attr->atttypid)
ereport(ERROR,
- (errmsg("attribute %d has wrong type", attnum),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("attribute %d has wrong type", attnum),
errdetail("Table has type %s, but query expects %s.",
format_type_be(attr->atttypid),
format_type_be(variable->vartype))));
/* As in ExecEvalScalarVar, we should but can't check typmod */
if (fselect->resulttype != attr->atttypid)
ereport(ERROR,
- (errmsg("attribute %d has wrong type", fieldnum),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("attribute %d has wrong type", fieldnum),
errdetail("Table has type %s, but query expects %s.",
format_type_be(attr->atttypid),
format_type_be(fselect->resulttype))));
return buf_finalize(buf);
bad_format:
- elog(ERROR, "invalid input for txid_snapshot: \"%s\"", str_start);
- return NULL;
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for type txid_snapshot: \"%s\"",
+ str_start)));
+ return NULL; /* keep compiler quiet */
}
/*
PG_RETURN_POINTER(snap);
bad_format:
- elog(ERROR, "invalid snapshot data");
- return (Datum) NULL;
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
+ errmsg("invalid external txid_snapshot data")));
+ PG_RETURN_POINTER(NULL); /* keep compiler quiet */
}
/*
else
plperl_untrusted_init();
#else
- elog(ERROR,
- "cannot allocate multiple Perl interpreters on this platform");
+ errmsg(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot allocate multiple Perl interpreters on this platform")));
#endif
}
eval_pv("PostgreSQL::InServer::SPI::bootstrap()", FALSE);
if (SvTRUE(ERRSV))
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while executing PostgreSQL::InServer::SPI::bootstrap")));
/* Fully initialized, so mark the hashtable entry valid */
if (perl_parse(plperl, plperl_init_shared_libs,
nargs, embedding, NULL) != 0)
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while parsing Perl initialization")));
if (perl_run(plperl) != 0)
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while running Perl initialization")));
#ifdef PLPERL_RESTORE_LOCALE
eval_pv(PLC_TRUSTED, FALSE);
if (SvTRUE(ERRSV))
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while executing PLC_TRUSTED")));
/*
eval_pv("my $a=chr(0x100); return $a =~ /\\xa9/i", FALSE);
if (SvTRUE(ERRSV))
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while executing utf8fix")));
/*
if (plperl_on_plperl_init && *plperl_on_plperl_init)
{
eval_pv(plperl_on_plperl_init, FALSE);
+ /* XXX need to find a way to determine a better errcode here */
if (SvTRUE(ERRSV))
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while executing plperl.on_plperl_init")));
-
}
}
eval_pv(plperl_on_plperlu_init, FALSE);
if (SvTRUE(ERRSV))
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
errcontext("while executing plperl.on_plperlu_init")));
}
}
isnull;
if (!OidIsValid(typid))
- elog(ERROR, "lookup failed for type %s", fqtypename);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("lookup failed for type %s", fqtypename)));
datum = plperl_sv_to_datum(sv,
typid, -1,
if (!subref)
ereport(ERROR,
- (errmsg("didn't get a CODE reference from compiling function \"%s\"",
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("didn't get a CODE reference from compiling function \"%s\"",
prodesc->proname)));
prodesc->reference = subref;
PUTBACK;
FREETMPS;
LEAVE;
- elog(ERROR, "didn't get a return item from function");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("didn't get a return item from function")));
}
if (SvTRUE(ERRSV))
PUTBACK;
FREETMPS;
LEAVE;
- /* XXX need to find a way to assign an errcode here */
+ /* XXX need to find a way to determine a better errcode here */
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
}
retval = newSVsv(POPs);
TDsv = get_sv("main::_TD", 0);
if (!TDsv)
- elog(ERROR, "couldn't fetch $_TD");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("couldn't fetch $_TD")));
save_item(TDsv); /* local $_TD */
sv_setsv(TDsv, td);
PUTBACK;
FREETMPS;
LEAVE;
- elog(ERROR, "didn't get a return item from trigger function");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("didn't get a return item from trigger function")));
}
if (SvTRUE(ERRSV))
PUTBACK;
FREETMPS;
LEAVE;
- /* XXX need to find a way to assign an errcode here */
+ /* XXX need to find a way to determine a better errcode here */
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
}
retval = newSVsv(POPs);
TDsv = get_sv("main::_TD", 0);
if (!TDsv)
- elog(ERROR, "couldn't fetch $_TD");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("couldn't fetch $_TD")));
save_item(TDsv); /* local $_TD */
sv_setsv(TDsv, td);
PUTBACK;
FREETMPS;
LEAVE;
- elog(ERROR, "didn't get a return item from trigger function");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("didn't get a return item from trigger function")));
}
if (SvTRUE(ERRSV))
PUTBACK;
FREETMPS;
LEAVE;
- /* XXX need to find a way to assign an errcode here */
+ /* XXX need to find a way to determine a better errcode here */
ereport(ERROR,
- (errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
}
retval = newSVsv(POPs);
PG_TRY();
{
ereport(elevel,
- (errcode(sqlerrcode ? sqlerrcode : ERRCODE_INTERNAL_ERROR),
+ (errcode(sqlerrcode ? sqlerrcode : ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
errmsg_internal("%s", primary ? primary : "no exception data"),
(detail) ? errdetail_internal("%s", detail) : 0,
(tb_depth > 0 && tbmsg) ? errcontext("%s", tbmsg) : 0,
{
if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL)
ereport(ERROR,
- (errmsg("TD[\"new\"] deleted, cannot modify row")));
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("TD[\"new\"] deleted, cannot modify row")));
Py_INCREF(plntup);
if (!PyDict_Check(plntup))
ereport(ERROR,
- (errmsg("TD[\"new\"] is not a dictionary")));
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("TD[\"new\"] is not a dictionary")));
plkeys = PyDict_Keys(plntup);
natts = PyList_Size(plkeys);
else
{
ereport(ERROR,
- (errmsg("TD[\"new\"] dictionary key at ordinal position %d is not a string", i)));
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("TD[\"new\"] dictionary key at ordinal position %d is not a string", i)));
plattstr = NULL; /* keep compiler quiet */
}
attn = SPI_fnumber(tupdesc, plattstr);
if (attn == SPI_ERROR_NOATTRIBUTE)
ereport(ERROR,
- (errmsg("key \"%s\" found in TD[\"new\"] does not exist as a column in the triggering row",
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("key \"%s\" found in TD[\"new\"] does not exist as a column in the triggering row",
plattstr)));
atti = attn - 1;
if (SPI_processed == 0)
{
SPI_freetuptable(SPI_tuptable);
- elog(WARNING, "module \"unknown\" not found in pltcl_modules");
+ ereport(WARNING,
+ (errmsg("module \"unknown\" not found in pltcl_modules")));
relation_close(pmrel, AccessShareLock);
return;
}
if (tcl_rc != TCL_OK)
{
UTF_BEGIN;
- elog(ERROR, "could not load module \"unknown\": %s",
- UTF_U2E(Tcl_GetStringResult(interp)));
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("could not load module \"unknown\": %s",
+ UTF_U2E(Tcl_GetStringResult(interp)))));
UTF_END;
}
&ret_numvals, &ret_values) != TCL_OK)
{
UTF_BEGIN;
- elog(ERROR, "could not split return value from trigger: %s",
- UTF_U2E(Tcl_GetStringResult(interp)));
+ ereport(ERROR,
+ (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
+ errmsg("could not split return value from trigger: %s",
+ UTF_U2E(Tcl_GetStringResult(interp)))));
UTF_END;
}
PG_TRY();
{
if (ret_numvals % 2 != 0)
- elog(ERROR, "invalid return list from trigger - must have even # of elements");
+ ereport(ERROR,
+ (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
+ errmsg("invalid return list from trigger - must have even # of elements")));
modattrs = (int *) palloc(tupdesc->natts * sizeof(int));
modvalues = (Datum *) palloc(tupdesc->natts * sizeof(Datum));
************************************************************/
attnum = SPI_fnumber(tupdesc, ret_name);
if (attnum == SPI_ERROR_NOATTRIBUTE)
- elog(ERROR, "invalid attribute \"%s\"", ret_name);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("unrecognized attribute \"%s\"",
+ ret_name)));
if (attnum <= 0)
- elog(ERROR, "cannot set system attribute \"%s\"", ret_name);
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot set system attribute \"%s\"",
+ ret_name)));
/************************************************************
* Ignore dropped columns
econtext = UTF_U2E((char *) Tcl_GetVar(interp, "errorInfo",
TCL_GLOBAL_ONLY));
ereport(ERROR,
- (errmsg("%s", emsg),
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", emsg),
errcontext("%s\nin PL/Tcl function \"%s\"",
econtext, proname)));
UTF_END;
free(prodesc->internal_proname);
free(prodesc);
UTF_BEGIN;
- elog(ERROR, "could not create internal procedure \"%s\": %s",
- internal_proname, UTF_U2E(Tcl_GetStringResult(interp)));
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("could not create internal procedure \"%s\": %s",
+ internal_proname,
+ UTF_U2E(Tcl_GetStringResult(interp)))));
UTF_END;
}
}
/*
- * For non-error messages, just pass 'em to elog(). We do not expect that
- * this will fail, but just on the off chance it does, report the error
- * back to Tcl. Note we are assuming that elog() can't have any internal
- * failures that are so bad as to require a transaction abort.
+ * For non-error messages, just pass 'em to ereport(). We do not expect
+ * that this will fail, but just on the off chance it does, report the
+ * error back to Tcl. Note we are assuming that ereport() can't have any
+ * internal failures that are so bad as to require a transaction abort.
*
* This path is also used for FATAL errors, which aren't going to come
* back to us at all.
PG_TRY();
{
UTF_BEGIN;
- elog(level, "%s", UTF_U2E(argv[2]));
+ ereport(level,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", UTF_U2E(argv[2]))));
UTF_END;
}
PG_CATCH();
-- errors
select '31:12:'::txid_snapshot;
-ERROR: invalid input for txid_snapshot: "31:12:"
+ERROR: invalid input syntax for type txid_snapshot: "31:12:"
LINE 1: select '31:12:'::txid_snapshot;
^
select '0:1:'::txid_snapshot;
-ERROR: invalid input for txid_snapshot: "0:1:"
+ERROR: invalid input syntax for type txid_snapshot: "0:1:"
LINE 1: select '0:1:'::txid_snapshot;
^
select '12:13:0'::txid_snapshot;
-ERROR: invalid input for txid_snapshot: "12:13:0"
+ERROR: invalid input syntax for type txid_snapshot: "12:13:0"
LINE 1: select '12:13:0'::txid_snapshot;
^
select '12:16:14,13'::txid_snapshot;
-ERROR: invalid input for txid_snapshot: "12:16:14,13"
+ERROR: invalid input syntax for type txid_snapshot: "12:16:14,13"
LINE 1: select '12:16:14,13'::txid_snapshot;
^
create temp table snapshot_test (
(1 row)
SELECT txid_snapshot '1:9223372036854775808:3';
-ERROR: invalid input for txid_snapshot: "1:9223372036854775808:3"
+ERROR: invalid input syntax for type txid_snapshot: "1:9223372036854775808:3"
LINE 1: SELECT txid_snapshot '1:9223372036854775808:3';
^
elog(ERROR, "ttdummy (%s): %s must be NOT NULL", relname, args[1]);
if (oldon != newon || oldoff != newoff)
- elog(ERROR, "ttdummy (%s): you cannot change %s and/or %s columns (use set_ttdummy)",
- relname, args[0], args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("ttdummy (%s): you cannot change %s and/or %s columns (use set_ttdummy)",
+ relname, args[0], args[1])));
if (newoff != TTDUMMY_INFINITY)
{