Datum
__BTREE_GIST_TYPE2__key_in(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("<datatype>key_in() not implemented")));
+
PG_RETURN_POINTER(NULL);
}
Datum
__BTREE_GIST_TYPE2__key_out(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("<datatype>key_out() not implemented")));
+
PG_RETURN_POINTER(NULL);
}
Datum
tskey_in(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("feature not implemented")));
+
PG_RETURN_POINTER(NULL);
}
Datum
tskey_out(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("feature not implemented")));
+
PG_RETURN_POINTER(NULL);
}
-- does not depend on contents of btree_gist.sql.
--
\set ECHO none
-psql:btree_gist.sql:8: NOTICE: ProcedureCreate: type int2key is not yet defined
-psql:btree_gist.sql:13: NOTICE: Argument type "int2key" is only a shell
-psql:btree_gist.sql:25: NOTICE: ProcedureCreate: type int4key is not yet defined
-psql:btree_gist.sql:30: NOTICE: Argument type "int4key" is only a shell
-psql:btree_gist.sql:42: NOTICE: ProcedureCreate: type int8key is not yet defined
-psql:btree_gist.sql:47: NOTICE: Argument type "int8key" is only a shell
-psql:btree_gist.sql:59: NOTICE: ProcedureCreate: type float4key is not yet defined
-psql:btree_gist.sql:64: NOTICE: Argument type "float4key" is only a shell
-psql:btree_gist.sql:77: NOTICE: ProcedureCreate: type float8key is not yet defined
-psql:btree_gist.sql:82: NOTICE: Argument type "float8key" is only a shell
-psql:btree_gist.sql:392: NOTICE: ProcedureCreate: type tskey is not yet defined
-psql:btree_gist.sql:397: NOTICE: Argument type "tskey" is only a shell
+psql:btree_gist.sql:8: NOTICE: type int2key is not yet defined
+DETAIL: Creating a shell type definition.
+psql:btree_gist.sql:13: NOTICE: argument type int2key is only a shell
+psql:btree_gist.sql:25: NOTICE: type int4key is not yet defined
+DETAIL: Creating a shell type definition.
+psql:btree_gist.sql:30: NOTICE: argument type int4key is only a shell
+psql:btree_gist.sql:42: NOTICE: type int8key is not yet defined
+DETAIL: Creating a shell type definition.
+psql:btree_gist.sql:47: NOTICE: argument type int8key is only a shell
+psql:btree_gist.sql:59: NOTICE: type float4key is not yet defined
+DETAIL: Creating a shell type definition.
+psql:btree_gist.sql:64: NOTICE: argument type float4key is only a shell
+psql:btree_gist.sql:77: NOTICE: type float8key is not yet defined
+DETAIL: Creating a shell type definition.
+psql:btree_gist.sql:82: NOTICE: argument type float8key is only a shell
+psql:btree_gist.sql:392: NOTICE: type tskey is not yet defined
+DETAIL: Creating a shell type definition.
+psql:btree_gist.sql:397: NOTICE: argument type tskey is only a shell
CREATE TABLE int4tmp (b int4);
\copy int4tmp from 'data/test_btree.data'
CREATE TABLE int8tmp (b int8);
* darcy@druid.net
* http://www.druid.net/darcy/
*
- * $Id: chkpass.c,v 1.9 2002/10/26 15:00:59 tgl Exp $
+ * $Id: chkpass.c,v 1.10 2003/07/24 17:52:12 tgl Exp $
* best viewed with tabs set to 4
*/
if (verify_pass(str) != 0)
{
- elog(ERROR, "chkpass_in: purported CHKPASS \"%s\" is a weak password",
- str);
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_EXCEPTION),
+ errmsg("password \"%s\" is weak", str)));
+
PG_RETURN_POINTER(NULL);
}
#include "postgres.h"
-#include "utils/elog.h"
-
static char *PARSE_BUFFER;
static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE;
PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s);
if (PARSE_BUFFER_SIZE == 0)
- elog(ERROR, "cube_in: can't parse an empty string");
+ ereport(ERROR,
+ (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
+ errmsg("can't parse an empty string")));
+
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
}
#include "cubedata.h"
#include "buffer.h"
-#include "utils/palloc.h"
-#include "utils/elog.h"
-
#undef yylex /* falure to redefine yylex will result in a call to the */
#define yylex cube_yylex /* wrong scanner when running inside the postgres backend */
if ( c != '\0' ) {
/* Not at EOF */
reset_parse_buffer();
- elog(ERROR, "(0) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c );
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("garbage at or before char %d, ('%c', \\%03o)",
+ pos, c, c)));
YYERROR;
}
dim = delim_count($2, ',') + 1;
if ( (delim_count($4, ',') + 1) != dim ) {
reset_parse_buffer();
- elog(ERROR, "(1) bad cube representation; different point dimensions in (%s) and (%s)\n", $2, $4);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("different point dimensions in (%s) and (%s)",
+ $2, $4)));
YYABORT;
}
if (dim > CUBE_MAX_DIM) {
reset_parse_buffer();
- elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("more than %d dimensions",
+ CUBE_MAX_DIM)));
YYABORT;
}
if ( c != '\0' ) { /* Not at EOF */
reset_parse_buffer();
- elog(ERROR, "(2) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c );
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("garbage at or before char %d, ('%c', \\%03o)",
+ pos, c, c)));
YYABORT;
}
if ( (delim_count($3, ',') + 1) != dim ) {
reset_parse_buffer();
- elog(ERROR, "(3) bad cube representation; different point dimensions in (%s) and (%s)\n", $1, $3);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("different point dimensions in (%s) and (%s)",
+ $1, $3)));
YYABORT;
}
if (dim > CUBE_MAX_DIM) {
reset_parse_buffer();
- elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("more than %d dimensions",
+ CUBE_MAX_DIM)));
YYABORT;
}
if ( c != '\0') { /* Not at EOF */
reset_parse_buffer();
- elog(ERROR, "(4) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c );
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("garbage at or before char %d, ('%c', \\%03o)",
+ pos, c, c)));
YYABORT;
}
if ( yychar != YYEOF) {
/* There's still a lookahead token to be parsed */
reset_parse_buffer();
- elog(ERROR, "(5) bad cube representation; garbage at or before char %d, ('end of input', \\%03o)\n", pos, c);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("garbage at or before char %d, ('end of input', \\%03o)",
+ pos, c)));
YYABORT;
}
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) {
reset_parse_buffer();
- elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("more than %d dimensions",
+ CUBE_MAX_DIM)));
YYABORT;
}
if ( c != '\0') { /* Not at EOF */
reset_parse_buffer();
- elog(ERROR, "(6) bad cube representation; garbage at or before char %d, ('%c', \\%03o)\n", pos, c, c);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("garbage at or before char %d, ('%c', \\%03o)",
+ pos, c, c)));
YYABORT;
}
if ( yychar != YYEOF) {
/* There's still a lookahead token to be parsed */
reset_parse_buffer();
- elog(ERROR, "(7) bad cube representation; garbage at or before char %d, ('end of input', \\%03o)\n", pos, c);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("garbage at or before char %d, ('end of input', \\%03o)",
+ pos, c)));
YYABORT;
}
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) {
reset_parse_buffer();
- elog(ERROR, "(8) bad cube representation; more than %d dimensions\n", CUBE_MAX_DIM);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("more than %d dimensions",
+ CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
snprintf(
buf,
256,
- "%s at or before position %d, character ('%c', \\%03o), input: '%s'\n",
+ "%s at or before position %d, character ('%c', \\%03o), input: '%s'",
msg,
position,
parse_buffer()[position - 1],
);
reset_parse_buffer();
- elog(ERROR, "%s", buf);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad cube representation"),
+ errdetail("%s", buf)));
+
return 0;
}
-- does not depend on contents of cube.sql.
--
\set ECHO none
-psql:cube.sql:10: NOTICE: ProcedureCreate: type cube is not yet defined
-psql:cube.sql:15: NOTICE: Argument type "cube" is only a shell
+psql:cube.sql:10: NOTICE: type cube is not yet defined
+DETAIL: Creating a shell type definition.
+psql:cube.sql:15: NOTICE: argument type cube is only a shell
--
-- testing the input and output functions
--
-- invalid input: parse errors
SELECT ''::cube AS cube;
-ERROR: cube_in: can't parse an empty string
+ERROR: can't parse an empty string
SELECT 'ABC'::cube AS cube;
-ERROR: syntax error at or before position 1, character ('A', \101), input: 'ABC'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 1, character ('A', \101), input: 'ABC'
SELECT '()'::cube AS cube;
-ERROR: syntax error at or before position 2, character (')', \051), input: '()'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 2, character (')', \051), input: '()'
SELECT '[]'::cube AS cube;
-ERROR: syntax error at or before position 2, character (']', \135), input: '[]'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 2, character (']', \135), input: '[]'
SELECT '[()]'::cube AS cube;
-ERROR: syntax error at or before position 3, character (')', \051), input: '[()]'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 3, character (')', \051), input: '[()]'
SELECT '[(1)]'::cube AS cube;
-ERROR: syntax error at or before position 5, character (']', \135), input: '[(1)]'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 5, character (']', \135), input: '[(1)]'
SELECT '[(1),]'::cube AS cube;
-ERROR: syntax error at or before position 6, character (']', \135), input: '[(1),]'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 6, character (']', \135), input: '[(1),]'
SELECT '[(1),2]'::cube AS cube;
-ERROR: syntax error at or before position 7, character (']', \135), input: '[(1),2]'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 7, character (']', \135), input: '[(1),2]'
SELECT '[(1),(2),(3)]'::cube AS cube;
-ERROR: syntax error at or before position 9, character (',', \054), input: '[(1),(2),(3)]'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 9, character (',', \054), input: '[(1),(2),(3)]'
SELECT '1,'::cube AS cube;
-ERROR: syntax error at or before position 2, character (',', \054), input: '1,'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 2, character (',', \054), input: '1,'
SELECT '1,2,'::cube AS cube;
-ERROR: syntax error at or before position 4, character (',', \054), input: '1,2,'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 4, character (',', \054), input: '1,2,'
SELECT '1,,2'::cube AS cube;
-ERROR: syntax error at or before position 3, character (',', \054), input: '1,,2'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 3, character (',', \054), input: '1,,2'
SELECT '(1,)'::cube AS cube;
-ERROR: syntax error at or before position 4, character (')', \051), input: '(1,)'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 4, character (')', \051), input: '(1,)'
SELECT '(1,2,)'::cube AS cube;
-ERROR: syntax error at or before position 6, character (')', \051), input: '(1,2,)'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 6, character (')', \051), input: '(1,2,)'
SELECT '(1,,2)'::cube AS cube;
-ERROR: syntax error at or before position 4, character (',', \054), input: '(1,,2)'
-
+ERROR: bad cube representation
+DETAIL: syntax error at or before position 4, character (',', \054), input: '(1,,2)'
-- invalid input: semantic errors and trailing garbage
SELECT '[(1),(2)],'::cube AS cube; -- 0
-ERROR: (0) bad cube representation; garbage at or before char 9, (',', \054)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 9, (',', \054)
SELECT '[(1,2,3),(2,3)]'::cube AS cube; -- 1
-ERROR: (1) bad cube representation; different point dimensions in (1,2,3) and (2,3)
-
+ERROR: bad cube representation
+DETAIL: different point dimensions in (1,2,3) and (2,3)
SELECT '[(1,2),(1,2,3)]'::cube AS cube; -- 1
-ERROR: (1) bad cube representation; different point dimensions in (1,2) and (1,2,3)
-
+ERROR: bad cube representation
+DETAIL: different point dimensions in (1,2) and (1,2,3)
SELECT '(1),(2),'::cube AS cube; -- 2
-ERROR: (2) bad cube representation; garbage at or before char 7, (',', \054)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 7, (',', \054)
SELECT '(1,2,3),(2,3)'::cube AS cube; -- 3
-ERROR: (3) bad cube representation; different point dimensions in (1,2,3) and (2,3)
-
+ERROR: bad cube representation
+DETAIL: different point dimensions in (1,2,3) and (2,3)
SELECT '(1,2),(1,2,3)'::cube AS cube; -- 3
-ERROR: (3) bad cube representation; different point dimensions in (1,2) and (1,2,3)
-
+ERROR: bad cube representation
+DETAIL: different point dimensions in (1,2) and (1,2,3)
SELECT '(1,2,3)ab'::cube AS cube; -- 4
-ERROR: (4) bad cube representation; garbage at or before char 8, ('b', \142)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 8, ('b', \142)
SELECT '(1,2,3)a'::cube AS cube; -- 5
-ERROR: (5) bad cube representation; garbage at or before char 8, ('end of input', \000)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 8, ('end of input', \000)
SELECT '(1,2)('::cube AS cube; -- 5
-ERROR: (5) bad cube representation; garbage at or before char 6, ('end of input', \000)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 6, ('end of input', \000)
SELECT '1,2ab'::cube AS cube; -- 6
-ERROR: (6) bad cube representation; garbage at or before char 4, ('b', \142)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 4, ('b', \142)
SELECT '1 e7'::cube AS cube; -- 6
-ERROR: (6) bad cube representation; garbage at or before char 3, ('7', \067)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 3, ('7', \067)
SELECT '1,2a'::cube AS cube; -- 7
-ERROR: (7) bad cube representation; garbage at or before char 4, ('end of input', \000)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 4, ('end of input', \000)
SELECT '1..2'::cube AS cube; -- 7
-ERROR: (7) bad cube representation; garbage at or before char 4, ('end of input', \000)
-
+ERROR: bad cube representation
+DETAIL: garbage at or before char 4, ('end of input', \000)
--
-- Testing building cubes from float8 values
--
-- Testing limit of CUBE_MAX_DIM dimensions check in cube_in.
--
select '(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)'::cube;
-ERROR: (8) bad cube representation; more than 100 dimensions
-
+ERROR: bad cube representation
+DETAIL: more than 100 dimensions
select '(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)'::cube;
-ERROR: (8) bad cube representation; more than 100 dimensions
-
+ERROR: bad cube representation
+DETAIL: more than 100 dimensions
--
-- testing the operators
--
*
*/
#include "postgres.h"
+
#include "libpq-fe.h"
#include "fmgr.h"
#include "funcapi.h"
#include "utils/array.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
-#include "utils/palloc.h"
#include "utils/dynahash.h"
#include "utils/hsearch.h"
#include "utils/memutils.h"
*/
static remoteConn *getConnectionByName(const char *name);
static HTAB *createConnHash(void);
-static bool createNewConnection(const char *name,remoteConn *con);
+static void createNewConnection(const char *name,remoteConn *con);
static void deleteConnection(const char *name);
static char **get_pkey_attnames(Oid relid, int16 *numatts);
static char *get_sql_insert(Oid relid, int16 *pkattnums, int16 pknumatts, char **src_pkattvals, char **tgt_pkattvals);
var_ = NULL; \
} \
} while (0)
-#define DBLINK_RES_ERROR(p1, p2) \
+#define DBLINK_RES_INTERNALERROR(p2) \
+ do { \
+ msg = pstrdup(PQerrorMessage(conn)); \
+ if (res) \
+ PQclear(res); \
+ elog(ERROR, "%s: %s", p2, msg); \
+ } while (0)
+#define DBLINK_RES_ERROR(p2) \
do { \
msg = pstrdup(PQerrorMessage(conn)); \
if (res) \
PQclear(res); \
- elog(ERROR, "%s: %s: %s", p1, p2, msg); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_SYNTAX_ERROR), \
+ errmsg("%s", p2), \
+ errdetail("%s", msg))); \
} while (0)
-#define DBLINK_CONN_NOT_AVAIL(p1) \
+#define DBLINK_CONN_NOT_AVAIL \
do { \
if(conname) \
- elog(ERROR, "%s: connection %s not available", p1, conname); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), \
+ errmsg("connection \"%s\" not available", conname))); \
else \
- elog(ERROR, "%s: connection not available", p1); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), \
+ errmsg("connection not available"))); \
} while (0)
-#define DBLINK_GET_CONN(p1) \
+#define DBLINK_GET_CONN \
do { \
char *conname_or_str = GET_STR(PG_GETARG_TEXT_P(0)); \
rcon = getConnectionByName(conname_or_str); \
{ \
msg = pstrdup(PQerrorMessage(conn)); \
PQfinish(conn); \
- elog(ERROR, "%s: connection error: %s", p1, msg); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), \
+ errmsg("could not establish connection"), \
+ errdetail("%s", msg))); \
} \
} \
} while (0)
PQfinish(conn);
if(rcon)
pfree(rcon);
- elog(ERROR, "dblink_connect: connection error: %s", msg);
+
+ ereport(ERROR,
+ (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
+ errmsg("could not establish connection"),
+ errdetail("%s", msg)));
}
if(connname)
{
rcon->con = conn;
- if(createNewConnection(connname, rcon) == false)
- {
- PQfinish(conn);
- pfree(rcon);
- elog(ERROR, "dblink_connect: cannot save named connection");
- }
+ createNewConnection(connname, rcon);
}
else
persistent_conn = conn;
Datum
dblink_disconnect(PG_FUNCTION_ARGS)
{
- char *str = NULL;
+ char *conname = NULL;
remoteConn *rcon = NULL;
PGconn *conn = NULL;
if (PG_NARGS() ==1 )
{
- str = GET_STR(PG_GETARG_TEXT_P(0));
- rcon = getConnectionByName(str);
+ conname = GET_STR(PG_GETARG_TEXT_P(0));
+ rcon = getConnectionByName(conname);
if (rcon)
conn = rcon->con;
}
conn = persistent_conn;
if (!conn)
- {
- if (str)
- elog(ERROR,"dblink_disconnect: connection named \"%s\" not found",
- str);
- else
- elog(ERROR,"dblink_disconnect: connection not found");
- }
+ DBLINK_CONN_NOT_AVAIL;
PQfinish(conn);
if (rcon)
{
- deleteConnection(str);
+ deleteConnection(conname);
pfree(rcon);
}
}
if (!conn)
- DBLINK_CONN_NOT_AVAIL("dblink_open");
+ DBLINK_CONN_NOT_AVAIL;
res = PQexec(conn, "BEGIN");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
- DBLINK_RES_ERROR("dblink_open", "begin error");
+ DBLINK_RES_INTERNALERROR("begin error");
PQclear(res);
if (!res ||
(PQresultStatus(res) != PGRES_COMMAND_OK &&
PQresultStatus(res) != PGRES_TUPLES_OK))
- DBLINK_RES_ERROR("dblink_open", "sql error");
+ DBLINK_RES_ERROR("sql error");
PQclear(res);
}
if (!conn)
- DBLINK_CONN_NOT_AVAIL("dblink_close");
+ DBLINK_CONN_NOT_AVAIL;
appendStringInfo(str, "CLOSE %s", curname);
/* close the cursor */
res = PQexec(conn, str->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- DBLINK_RES_ERROR("dblink_close", "sql error");
+ DBLINK_RES_ERROR("sql error");
PQclear(res);
/* commit the transaction */
res = PQexec(conn, "COMMIT");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
- DBLINK_RES_ERROR("dblink_close", "commit error");
+ DBLINK_RES_INTERNALERROR("commit error");
PQclear(res);
}
if(!conn)
- DBLINK_CONN_NOT_AVAIL("dblink_fetch");
+ DBLINK_CONN_NOT_AVAIL;
/* create a function context for cross-call persistence */
funcctx = SRF_FIRSTCALL_INIT();
(PQresultStatus(res) != PGRES_COMMAND_OK &&
PQresultStatus(res) != PGRES_TUPLES_OK))
{
- DBLINK_RES_ERROR("dblink_fetch", "sql error");
+ DBLINK_RES_ERROR("sql error");
}
else if (PQresultStatus(res) == PGRES_COMMAND_OK)
{
/* cursor does not exist - closed already or bad name */
PQclear(res);
- elog(ERROR, "dblink_fetch: cursor not found: %s", curname);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_CURSOR_NAME),
+ errmsg("cursor \"%s\" does not exist", curname)));
}
funcctx->max_calls = PQntuples(res);
else if (functyptype == 'p' && functypeid == RECORDOID)
tupdesc = pgresultGetTupleDesc(res);
else
- elog(ERROR, "dblink_fetch: return type must be a row type");
+ /* shouldn't happen */
+ elog(ERROR, "return type must be a row type");
/* store needed metadata for subsequent calls */
slot = TupleDescGetSlot(tupdesc);
if (PG_NARGS() == 2)
{
- DBLINK_GET_CONN("dblink");
+ DBLINK_GET_CONN;
sql = GET_STR(PG_GETARG_TEXT_P(1));
}
else if (PG_NARGS() == 1)
sql = GET_STR(PG_GETARG_TEXT_P(0));
}
else
- elog(ERROR, "dblink: wrong number of arguments");
+ /* shouldn't happen */
+ elog(ERROR, "wrong number of arguments");
if(!conn)
- DBLINK_CONN_NOT_AVAIL("dblink_record");
+ DBLINK_CONN_NOT_AVAIL;
res = PQexec(conn, sql);
if (!res || (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK))
- DBLINK_RES_ERROR("dblink", "sql error");
+ DBLINK_RES_ERROR("sql error");
if (PQresultStatus(res) == PGRES_COMMAND_OK)
{
else if (functyptype == 'p' && functypeid == RECORDOID)
tupdesc = pgresultGetTupleDesc(res);
else
- elog(ERROR, "dblink: return type must be a row type");
+ /* shouldn't happen */
+ elog(ERROR, "return type must be a row type");
}
/* store needed metadata for subsequent calls */
if (PG_NARGS() == 2)
{
- DBLINK_GET_CONN("dblink_exec");
+ DBLINK_GET_CONN;
sql = GET_STR(PG_GETARG_TEXT_P(1));
}
else if (PG_NARGS() == 1)
sql = GET_STR(PG_GETARG_TEXT_P(0));
}
else
- elog(ERROR, "dblink_exec: wrong number of arguments");
+ /* shouldn't happen */
+ elog(ERROR, "wrong number of arguments");
if(!conn)
- DBLINK_CONN_NOT_AVAIL("dblink_exec");
+ DBLINK_CONN_NOT_AVAIL;
res = PQexec(conn, sql);
if (!res ||
(PQresultStatus(res) != PGRES_COMMAND_OK &&
PQresultStatus(res) != PGRES_TUPLES_OK))
- DBLINK_RES_ERROR("dblink_exec", "sql error");
+ DBLINK_RES_ERROR("sql error");
if (PQresultStatus(res) == PGRES_COMMAND_OK)
{
sql_cmd_status = GET_TEXT(PQcmdStatus(res));
}
else
- elog(ERROR, "dblink_exec: queries returning results not allowed");
+ ereport(ERROR,
+ (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
+ errmsg("statement returning results not allowed")));
PQclear(res);
/* convert relname to rel Oid */
relid = get_relid_from_relname(PG_GETARG_TEXT_P(0));
if (!OidIsValid(relid))
- elog(ERROR, "dblink_get_pkey: relation does not exist");
-
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_TABLE),
+ errmsg("relation \"%s\" does not exist",
+ GET_STR(PG_GETARG_TEXT_P(0)))));
/*
* need a tuple descriptor representing one INT and one TEXT
* column
*/
relid = get_relid_from_relname(relname_text);
if (!OidIsValid(relid))
- elog(ERROR, "dblink_build_sql_insert: relation does not exist");
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_TABLE),
+ errmsg("relation \"%s\" does not exist",
+ GET_STR(relname_text))));
pkattnums = (int16 *) PG_GETARG_POINTER(1);
pknumatts_tmp = PG_GETARG_INT32(2);
if (pknumatts_tmp <= SHRT_MAX)
pknumatts = pknumatts_tmp;
else
- elog(ERROR, "Bad input value for pknumatts; too large");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input for number of primary key " \
+ "attributes too large")));
/*
* There should be at least one key attribute
*/
if (pknumatts == 0)
- elog(ERROR, "dblink_build_sql_insert: number of key attributes must be > 0.");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("number of key attributes must be > 0")));
src_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(4);
* There should be one source array key value for each key attnum
*/
if (src_nitems != pknumatts)
- elog(ERROR, "dblink_build_sql_insert: source key array length does not match number of key attributes.");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("source key array length must match number of key " \
+ "attributes")));
/*
* get array of pointers to c-strings from the input source array
* There should be one target array key value for each key attnum
*/
if (tgt_nitems != pknumatts)
- elog(ERROR, "dblink_build_sql_insert: target key array length does not match number of key attributes.");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("target key array length must match number of key " \
+ "attributes")));
/*
* get array of pointers to c-strings from the input target array
*/
relid = get_relid_from_relname(relname_text);
if (!OidIsValid(relid))
- elog(ERROR, "dblink_build_sql_delete: relation does not exist");
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_TABLE),
+ errmsg("relation \"%s\" does not exist",
+ GET_STR(relname_text))));
pkattnums = (int16 *) PG_GETARG_POINTER(1);
pknumatts_tmp = PG_GETARG_INT32(2);
if (pknumatts_tmp <= SHRT_MAX)
pknumatts = pknumatts_tmp;
else
- elog(ERROR, "Bad input value for pknumatts; too large");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input for number of primary key " \
+ "attributes too large")));
/*
* There should be at least one key attribute
*/
if (pknumatts == 0)
- elog(ERROR, "dblink_build_sql_insert: number of key attributes must be > 0.");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("number of key attributes must be > 0")));
tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
* There should be one target array key value for each key attnum
*/
if (tgt_nitems != pknumatts)
- elog(ERROR, "dblink_build_sql_insert: target key array length does not match number of key attributes.");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("target key array length must match number of key " \
+ "attributes")));
/*
* get array of pointers to c-strings from the input target array
*/
relid = get_relid_from_relname(relname_text);
if (!OidIsValid(relid))
- elog(ERROR, "dblink_build_sql_update: relation does not exist");
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_TABLE),
+ errmsg("relation \"%s\" does not exist",
+ GET_STR(relname_text))));
pkattnums = (int16 *) PG_GETARG_POINTER(1);
pknumatts_tmp = PG_GETARG_INT32(2);
if (pknumatts_tmp <= SHRT_MAX)
pknumatts = pknumatts_tmp;
else
- elog(ERROR, "Bad input value for pknumatts; too large");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("input for number of primary key " \
+ "attributes too large")));
/*
* There should be one source array key values for each key attnum
*/
if (pknumatts == 0)
- elog(ERROR, "dblink_build_sql_insert: number of key attributes must be > 0.");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("number of key attributes must be > 0")));
src_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(4);
* There should be one source array key value for each key attnum
*/
if (src_nitems != pknumatts)
- elog(ERROR, "dblink_build_sql_insert: source key array length does not match number of key attributes.");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("source key array length must match number of key " \
+ "attributes")));
/*
* get array of pointers to c-strings from the input source array
* There should be one target array key value for each key attnum
*/
if (tgt_nitems != pknumatts)
- elog(ERROR, "dblink_build_sql_insert: target key array length does not match number of key attributes.");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("target key array length must match number of key " \
+ "attributes")));
/*
* get array of pointers to c-strings from the input target array
tuple = get_tuple_of_interest(relid, pkattnums, pknumatts, src_pkattvals);
if (!tuple)
- elog(ERROR, "dblink_build_sql_insert: row not found");
+ ereport(ERROR,
+ (errcode(ERRCODE_CARDINALITY_VIOLATION),
+ errmsg("source row not found")));
appendStringInfo(str, "INSERT INTO %s(", relname);
int natts;
StringInfo str = makeStringInfo();
char *sql;
- char *val;
+ char *val = NULL;
int i;
/* get relation name including any needed schema prefix and quoting */
if (tgt_pkattvals != NULL)
val = pstrdup(tgt_pkattvals[i]);
else
- {
- elog(ERROR, "Target key array must not be NULL");
- val = NULL; /* keep compiler quiet */
- }
+ /* internal error */
+ elog(ERROR, "target key array must not be NULL");
if (val != NULL)
{
tuple = get_tuple_of_interest(relid, pkattnums, pknumatts, src_pkattvals);
if (!tuple)
- elog(ERROR, "dblink_build_sql_update: row not found");
+ ereport(ERROR,
+ (errcode(ERRCODE_CARDINALITY_VIOLATION),
+ errmsg("source row not found")));
appendStringInfo(str, "UPDATE %s SET ", relname);
* Connect to SPI manager
*/
if ((ret = SPI_connect()) < 0)
- elog(ERROR, "get_tuple_of_interest: SPI_connect returned %d", ret);
+ /* internal error */
+ elog(ERROR, "SPI connect failure - returned %d", ret);
/*
* Build sql statement to look up tuple of interest Use src_pkattvals
* Only allow one qualifying tuple
*/
if ((ret == SPI_OK_SELECT) && (SPI_processed > 1))
- elog(ERROR, "get_tuple_of_interest: Source criteria may not match more than one record.");
+ ereport(ERROR,
+ (errcode(ERRCODE_CARDINALITY_VIOLATION),
+ errmsg("source criteria matched more than one record")));
+
else if (ret == SPI_OK_SELECT && SPI_processed == 1)
{
SPITupleTable *tuptable = SPI_tuptable;
*/
natts = PQnfields(res);
if (natts < 1)
+ /* shouldn't happen */
elog(ERROR, "cannot create a description for empty results");
desc = CreateTemplateTupleDesc(natts, false);
atttypmod = PQfmod(res, i);
if (PQfsize(res, i) != get_typlen(atttypid))
- elog(ERROR, "Size of remote field \"%s\" does not match size "
- "of local type \"%s\"",
- attname,
- format_type_with_typemod(atttypid, atttypmod));
+ ereport(ERROR,
+ (errcode(ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH),
+ errmsg("field size mismatch"),
+ errdetail("Size of remote field \"%s\" does not match " \
+ "size of local type \"%s\".", attname,
+ format_type_with_typemod(atttypid,
+ atttypmod))));
attdim = 0;
attisset = false;
ObjectIdGetDatum(relid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
- elog(ERROR, "cache lookup of relation %u failed", relid);
+ elog(ERROR, "cache lookup failed for relation %u", relid);
+
reltup = (Form_pg_class) GETSTRUCT(tp);
/* Qualify the name if not visible in search path */
ptr=hash_create("Remote Con hash", NUMCONN, &ctl, HASH_ELEM);
if(!ptr)
- elog(ERROR,"Can not create connections hash table. Out of memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
return(ptr);
}
-static bool
+static void
createNewConnection(const char *name, remoteConn *con)
{
remoteConnHashEnt *hentry;
char key[NAMEDATALEN];
if(!remoteConnHash)
- remoteConnHash=createConnHash();
+ remoteConnHash = createConnHash();
MemSet(key, 0, NAMEDATALEN);
snprintf(key, NAMEDATALEN - 1, "%s", name);
HASH_ENTER, &found);
if(!hentry)
- elog(ERROR, "failed to create connection");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
if(found)
- {
- elog(NOTICE, "cannot use a connection name more than once");
- return false;
- }
+ ereport(ERROR,
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("duplicate connection name")));
hentry->rcon = con;
strncpy(hentry->name, name, NAMEDATALEN - 1);
-
- return true;
}
static void
key, HASH_REMOVE, &found);
if(!hentry)
- elog(WARNING,"Trying to delete a connection that does not exist");
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("undefined connection name")));
+
}
-- contents of dblink.sql.
\set ECHO none
CREATE TABLE foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
+NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
INSERT INTO foo VALUES (0,'a','{"a0","b0","c0"}');
INSERT INTO foo VALUES (1,'b','{"a1","b1","c1"}');
INSERT INTO foo VALUES (2,'c','{"a2","b2","c2"}');
-- retest using a quoted and schema qualified table
CREATE SCHEMA "MySchema";
CREATE TABLE "MySchema"."Foo"(f1 int, f2 text, f3 text[], primary key (f1,f2));
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'Foo_pkey' for table 'Foo'
+NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "Foo_pkey" for table "Foo"
INSERT INTO "MySchema"."Foo" VALUES (0,'a','{"a0","b0","c0"}');
-- list the primary key fields
SELECT *
SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-ERROR: dblink_record: connection not available
+ERROR: connection not available
-- create a persistent connection
SELECT dblink_connect('dbname=regression');
dblink_connect
OK
(1 row)
--- should generate "cursor not found: rmt_foo_cursor" error
+-- should generate 'cursor "rmt_foo_cursor" not found' error
SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
-ERROR: dblink_fetch: cursor not found: rmt_foo_cursor
+ERROR: cursor "rmt_foo_cursor" does not exist
-- close the persistent connection
SELECT dblink_disconnect();
dblink_disconnect
SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-ERROR: dblink: sql error: no connection to the server
+ERROR: sql error
+DETAIL: no connection to the server
-- put more data into our slave table, first using arbitrary connection syntax
-- but truncate the actual return value so we can use diff to check for success
SELECT *
FROM dblink('myconn','SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-ERROR: dblink: connection error: missing "=" after "myconn" in connection info string
+ERROR: could not establish connection
+DETAIL: missing "=" after "myconn" in connection info string
-- create a named persistent connection
SELECT dblink_connect('myconn','dbname=regression');
(3 rows)
-- create a second named persistent connection
--- should error with "cannot save named connection"
+-- should error with "duplicate connection name"
SELECT dblink_connect('myconn','dbname=regression');
-NOTICE: cannot use a connection name more than once
-ERROR: dblink_connect: cannot save named connection
+ERROR: duplicate connection name
-- create a second named persistent connection with a new name
SELECT dblink_connect('myconn2','dbname=regression');
dblink_connect
OK
(1 row)
--- should generate "cursor not found: rmt_foo_cursor" error
+-- should generate 'cursor "rmt_foo_cursor" not found' error
SELECT *
FROM dblink_fetch('myconn','rmt_foo_cursor',4) AS t(a int, b text, c text[]);
-ERROR: dblink_fetch: cursor not found: rmt_foo_cursor
+ERROR: cursor "rmt_foo_cursor" does not exist
-- close the named persistent connection
SELECT dblink_disconnect('myconn');
dblink_disconnect
SELECT *
FROM dblink('myconn','SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-ERROR: dblink: connection error: missing "=" after "myconn" in connection info string
+ERROR: could not establish connection
+DETAIL: missing "=" after "myconn" in connection info string
-- create a named persistent connection
SELECT dblink_connect('myconn','dbname=regression');
(1 row)
-- close the named persistent connection again
--- should get "connection named "myconn" not found" error
+-- should get 'connection "myconn" not available' error
SELECT dblink_disconnect('myconn');
-ERROR: dblink_disconnect: connection named "myconn" not found
+ERROR: connection "myconn" not available
-- close the cursor
SELECT dblink_close('rmt_foo_cursor');
--- should generate "cursor not found: rmt_foo_cursor" error
+-- should generate 'cursor "rmt_foo_cursor" not found' error
SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
WHERE t.a > 7;
-- create a second named persistent connection
--- should error with "cannot save named connection"
+-- should error with "duplicate connection name"
SELECT dblink_connect('myconn','dbname=regression');
-- create a second named persistent connection with a new name
-- close the cursor
SELECT dblink_close('myconn','rmt_foo_cursor');
--- should generate "cursor not found: rmt_foo_cursor" error
+-- should generate 'cursor "rmt_foo_cursor" not found' error
SELECT *
FROM dblink_fetch('myconn','rmt_foo_cursor',4) AS t(a int, b text, c text[]);
SELECT dblink_disconnect('myconn');
-- close the named persistent connection again
--- should get "connection named "myconn" not found" error
+-- should get 'connection "myconn" not available' error
SELECT dblink_disconnect('myconn');
/****************************************************************************
* pending.c
- * $Id: pending.c,v 1.11 2003/03/20 03:58:13 momjian Exp $
+ * $Id: pending.c,v 1.12 2003/07/24 17:52:20 tgl Exp $
*
* This file contains a trigger for Postgresql-7.x to record changes to tables
* to a pending table for mirroring.
if (storePending(fullyqualtblname, beforeTuple, afterTuple, tupdesc, trigdata, op))
{
/* An error occoured. Skip the operation. */
- elog(ERROR, "Operation could not be mirrored");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("operation could not be mirrored")));
+
return PointerGetDatum(NULL);
}
#if defined DEBUG_OUTPUT
- elog(NOTICE, "Returning on success");
+ elog(NOTICE, "returning on success");
#endif
SPI_pfree(fullyqualtblname);
SPI_finish();
vpPlan = SPI_prepare(cpQueryBase, 3, taPlanArgTypes);
if (vpPlan == NULL)
- elog(NOTICE, "Error creating plan");
+ elog(NOTICE, "error creating plan");
/* SPI_saveplan(vpPlan); */
saPlanData[0] = PointerGetDatum(cpTableName);
}
#if defined DEBUG_OUTPUT
- elog(NOTICE, "Done storing keyinfo");
+ elog(NOTICE, "done storing keyinfo");
#endif
return iResult;
pplan = SPI_prepare(insQuery, 1, saPlanArgTypes);
if (pplan == NULL)
{
- elog(NOTICE, "Could not prepare INSERT plan");
+ elog(NOTICE, "could not prepare INSERT plan");
return -1;
}
/* pplan = SPI_saveplan(pplan); */
cpKeyData = packageData(tTupleData, tTupleDesc, tpTrigData, PRIMARY);
if (cpKeyData == NULL)
- {
- elog(ERROR,"Could not determine primary key data");
- return -1;
- }
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ /* cpTableName already contains quotes... */
+ errmsg("there is no PRIMARY KEY for table %s",
+ cpTableName)));
+
#if defined DEBUG_OUTPUT
- elog(NOTICE, "KeyData: %s", cpKeyData);
+ elog(NOTICE, "key data: %s", cpKeyData);
#endif
saPlanData[0] = PointerGetDatum(cpKeyData);
if (iRetCode != SPI_OK_INSERT)
{
- elog(NOTICE, "Error inserting row in pendingDelete");
+ elog(NOTICE, "error inserting row in pendingDelete");
return -1;
}
#if defined DEBUG_OUTPUT
- elog(NOTICE, "Insert successful");
+ elog(NOTICE, "insert successful");
#endif
return 0;
query = SPI_palloc(strlen(queryBase) + MAX_OID_LEN + 1);
sprintf(query, "%s%d", queryBase, tblOid);
ret = SPI_exec(query, 1);
+ SPI_pfree(query);
if (ret != SPI_OK_SELECT || SPI_processed != 1)
- {
- elog(NOTICE, "Could not select primary index key");
return NULL;
- }
resTuple = SPI_tuptable->vals[0];
resDatum = SPI_getbinval(resTuple, SPI_tuptable->tupdesc, 1, &isNull);
resultKey = SPI_palloc(sizeof(int2vector));
memcpy(resultKey, tpResultKey, sizeof(int2vector));
- SPI_pfree(query);
return resultKey;
}
pplan = SPI_prepare(insQuery, 1, planArgTypes);
if (pplan == NULL)
{
- elog(NOTICE, "Could not prepare INSERT plan");
+ elog(NOTICE, "could not prepare INSERT plan");
return -1;
}
if (iRetValue != SPI_OK_INSERT)
{
- elog(NOTICE, "Error inserting row in pendingDelete");
+ elog(NOTICE, "error inserting row in pendingDelete");
return -1;
}
#if defined DEBUG_OUTPUT
- elog(NOTICE, "Insert successful");
+ elog(NOTICE, "insert successful");
#endif
return 0;
}
#if defined DEBUG_OUTPUT
if (tpPKeys != NULL)
- elog(NOTICE, "Have primary keys");
+ elog(NOTICE, "have primary keys");
#endif
cpDataBlock = SPI_palloc(BUFFER_SIZE);
iDataBlockSize = BUFFER_SIZE;
* Don't use.
*/
#if defined DEBUG_OUTPUT
- elog(NOTICE, "Skipping column");
+ elog(NOTICE, "skipping column");
#endif
continue;
}
cpFieldName = DatumGetPointer(NameGetDatum(&tTupleDesc->attrs
[iColumnCounter - 1]->attname));
#if defined DEBUG_OUTPUT
- elog(NOTICE, "FieldName: %s", cpFieldName);
+ elog(NOTICE, "field name: %s", cpFieldName);
#endif
while (iDataBlockSize - iUsedDataBlock < strlen(cpFieldName) + 6)
{
}
#if defined DEBUG_OUTPUT
- elog(NOTICE, "FieldData: %s", cpFieldData);
- elog(NOTICE, "Starting format loop");
+ elog(NOTICE, "field data: \"%s\"", cpFieldData);
+ elog(NOTICE, "starting format loop");
#endif
while (*cpUnFormatedPtr != 0)
{
sprintf(cpFormatedPtr, "' ");
iUsedDataBlock = iUsedDataBlock + 2;
#if defined DEBUG_OUTPUT
- elog(NOTICE, "DataBlock: %s", cpDataBlock);
+ elog(NOTICE, "data block: \"%s\"", cpDataBlock);
#endif
} /* for iColumnCounter */
if (tpPKeys != NULL)
SPI_pfree(tpPKeys);
#if defined DEBUG_OUTPUT
- elog(NOTICE, "Returning: DataBlockSize:%d iUsedDataBlock:%d",iDataBlockSize,
+ elog(NOTICE, "returning DataBlockSize:%d iUsedDataBlock:%d",iDataBlockSize,
iUsedDataBlock);
#endif
memset(cpDataBlock + iUsedDataBlock, 0, iDataBlockSize - iUsedDataBlock);
dbid = get_database_oid(NameStr(*dbname));
if (!OidIsValid(dbid))
- elog(ERROR, "database %s does not exist", NameStr(*dbname));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_DATABASE),
+ errmsg("database \"%s\" does not exist", NameStr(*dbname))));
dbpath = GetDatabasePath(dbid);
dirdesc = opendir(dbpath);
if (!dirdesc)
- elog(ERROR, "could not open directory %s: %s", dbpath, strerror(errno));
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not open directory \"%s\": %m", dbpath)));
totalsize = 0;
for (;;)
if (!direntry)
{
if (errno)
- elog(ERROR, "error reading directory: %s", strerror(errno));
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("error reading directory: %m")));
else
break;
}
fullname = psnprintf(strlen(dbpath) + 1 + strlen(direntry->d_name) + 1,
"%s/%s", dbpath, direntry->d_name);
if (stat(fullname, &statbuf) == -1)
- elog(ERROR, "could not stat %s: %s", fullname, strerror(errno));
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not stat \"%s\": %m", fullname)));
+
totalsize += statbuf.st_size;
pfree(fullname);
}
if (errno == ENOENT)
break;
else
- elog(ERROR, "could not stat %s: %m", fullname);
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not stat \"%s\": %m", fullname)));
}
totalsize += statbuf.st_size;
pfree(fullname);
RETURNS earth
LANGUAGE 'sql'
IMMUTABLE STRICT
-AS 'SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))';
+AS 'SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))::earth';
CREATE OR REPLACE FUNCTION latitude(earth)
RETURNS float8
-- does not depend on contents of earthdistance.sql or cube.sql.
--
\set ECHO none
-psql:../cube/cube.sql:10: NOTICE: ProcedureCreate: type cube is not yet defined
-psql:../cube/cube.sql:15: NOTICE: Argument type "cube" is only a shell
+psql:../cube/cube.sql:10: NOTICE: type cube is not yet defined
+DETAIL: Creating a shell type definition.
+psql:../cube/cube.sql:15: NOTICE: argument type cube is only a shell
--
-- The radius of the Earth we are using.
--
-- Test the recommended constraints.
--
SELECT is_point(ll_to_earth(0,0));
-ERROR: Function is_point(earth) does not exist
- Unable to identify a function that satisfies the given argument types
- You may need to add explicit typecasts
+ERROR: function is_point(earth) does not exist
+HINT: No function matches the given name and argument types. You may need to add explicit typecasts.
SELECT cube_dim(ll_to_earth(0,0)) <= 3;
?column?
----------
(1 row)
SELECT is_point(ll_to_earth(30,60));
-ERROR: Function is_point(earth) does not exist
- Unable to identify a function that satisfies the given argument types
- You may need to add explicit typecasts
+ERROR: function is_point(earth) does not exist
+HINT: No function matches the given name and argument types. You may need to add explicit typecasts.
SELECT cube_dim(ll_to_earth(30,60)) <= 3;
?column?
----------
(1 row)
SELECT is_point(ll_to_earth(60,90));
-ERROR: Function is_point(earth) does not exist
- Unable to identify a function that satisfies the given argument types
- You may need to add explicit typecasts
+ERROR: function is_point(earth) does not exist
+HINT: No function matches the given name and argument types. You may need to add explicit typecasts.
SELECT cube_dim(ll_to_earth(60,90)) <= 3;
?column?
----------
(1 row)
SELECT is_point(ll_to_earth(-30,-90));
-ERROR: Function is_point(earth) does not exist
- Unable to identify a function that satisfies the given argument types
- You may need to add explicit typecasts
+ERROR: function is_point(earth) does not exist
+HINT: No function matches the given name and argument types. You may need to add explicit typecasts.
SELECT cube_dim(ll_to_earth(-30,-90)) <= 3;
?column?
----------
*/
if (!CALLED_AS_TRIGGER(fcinfo))
- elog(ERROR, "Full Text Indexing: Not fired by trigger manager");
+ /* internal error */
+ elog(ERROR, "not fired by trigger manager");
/* It's safe to cast now that we've checked */
trigdata = (TriggerData *) fcinfo->context;
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
- elog(ERROR, "Full Text Indexing: Can't process STATEMENT events");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("can't process STATEMENT events")));
+
if (TRIGGER_FIRED_BEFORE(trigdata->tg_event))
- elog(ERROR, "Full Text Indexing: Must be fired AFTER event");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("must be fired AFTER event")));
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
isinsert = true;
rettuple = trigdata->tg_newtuple;
if ((ret = SPI_connect()) < 0)
- elog(ERROR, "Full Text Indexing: SPI_connect: Failed, returned %d\n", ret);
+ /* internal error */
+ elog(ERROR, "SPI_connect failed, returned %d", ret);
nargs = trigger->tgnargs;
if (nargs < 2)
- elog(ERROR, "Full Text Indexing: Trigger must have at least 2 arguments\n");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("fti trigger must have at least 2 arguments")));
args = trigger->tgargs;
indexname = args[0];
/* get oid of current tuple, needed by all, so place here */
oid = HeapTupleGetOid(rettuple);
if (!OidIsValid(oid))
- elog(ERROR, "Full Text Indexing: Oid of current tuple is invalid");
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("OID is not present"),
+ errhint("Full Text Index requires indexed tables be created WITH OIDS.")));
if (isdelete)
{
snprintf(query, MAX_FTI_QUERY_LENGTH, "DELETE FROM %s WHERE id = $1", indexname);
pplan = SPI_prepare(query, 1, argtypes);
if (!pplan)
- elog(ERROR, "Full Text Indexing: SPI_prepare: Returned NULL in delete");
+ /* internal error */
+ elog(ERROR, "SPI_prepare returned NULL in delete");
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
- elog(ERROR, "Full Text Indexing: SPI_saveplan: Returned NULL in delete");
+ /* internal error */
+ elog(ERROR, "SPI_saveplan returned NULL in delete");
plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan;
ret = SPI_execp(*(plan->splan), values, NULL, 0);
if (ret != SPI_OK_DELETE)
- elog(ERROR, "Full Text Indexing: SPI_execp: Error executing plan in delete");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("error executing delete")));
}
if (isinsert)
indexname);
pplan = SPI_prepare(query, 2, argtypes);
if (!pplan)
- elog(ERROR, "Full Text Indexing: SPI_prepare: Returned NULL in insert");
+ /* internal error */
+ elog(ERROR, "SPI_prepare returned NULL in insert");
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
- elog(ERROR, "Full Text Indexing: SPI_saveplan: Returned NULL in insert");
+ /* internal error */
+ elog(ERROR, "SPI_saveplan returned NULL in insert");
plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan;
{
colnum = SPI_fnumber(tupdesc, args[i + 1]);
if (colnum == SPI_ERROR_NOATTRIBUTE)
- elog(ERROR, "Full Text Indexing: SPI_fnumber: Column '%s' of '%s' not found", args[i + 1], indexname);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("column \"%s\" of \"%s\" does not exist",
+ args[i + 1], indexname)));
/* Get the char* representation of the column */
column = SPI_getvalue(rettuple, tupdesc, colnum);
ret = SPI_execp(*(plan->splan), values, NULL, 0);
if (ret != SPI_OK_INSERT)
- elog(ERROR, "Full Text Indexing: SPI_execp: Error executing plan in insert");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("error executing insert")));
}
pfree(buff);
pfree(data);
* and memory usage).
*/
if ((cols > MAX_LEVENSHTEIN_STRLEN + 1) || (rows > MAX_LEVENSHTEIN_STRLEN + 1))
- elog(ERROR, "levenshtein: Arguments may not exceed %d characters in length", MAX_LEVENSHTEIN_STRLEN);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("argument exceeds max length: %d",
+ MAX_LEVENSHTEIN_STRLEN)));
/*
* If either rows or cols is 0, the answer is the other value. This
str_i_len = strlen(str_i);
if (str_i_len > MAX_METAPHONE_STRLEN)
- elog(ERROR, "metaphone: Input string must not exceed %d characters", MAX_METAPHONE_STRLEN);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("argument exceeds max length: %d",
+ MAX_METAPHONE_STRLEN)));
+
if (!(str_i_len > 0))
- elog(ERROR, "metaphone: Input string length must be > 0");
+ ereport(ERROR,
+ (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
+ errmsg("argument is empty string")));
reqlen = PG_GETARG_INT32(1);
if (reqlen > MAX_METAPHONE_STRLEN)
- elog(ERROR, "metaphone: Requested Metaphone output length must not exceed %d characters", MAX_METAPHONE_STRLEN);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("output length exceeds max length: %d",
+ MAX_METAPHONE_STRLEN)));
+
if (!(reqlen > 0))
- elog(ERROR, "metaphone: Requested Metaphone output length must be > 0");
+ ereport(ERROR,
+ (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
+ errmsg("output cannot be empty string")));
+
retval = _metaphone(str_i, reqlen, &metaph);
if (retval == META_SUCCESS)
}
else
{
+ /* internal error */
elog(ERROR, "metaphone: failure");
/*
/* Negative phoneme length is meaningless */
if (!(max_phonemes > 0))
+ /* internal error */
elog(ERROR, "metaphone: Requested output length must be > 0");
/* Empty/null string is meaningless */
if ((word == NULL) || !(strlen(word) > 0))
+ /* internal error */
elog(ERROR, "metaphone: Input string length must be > 0");
/*-- Allocate memory for our phoned_phrase --*/
PGARRAY *p = GetPGArray(state, 1);
if (!p)
- elog(ERROR, "No aggregate storage");
+ /* internal error */
+ elog(ERROR, "no aggregate storage");
else if (p->items >= p->lower)
+ /* internal error */
elog(ERROR, "aggregate storage too small");
else
p->array[p->items++] = value;
ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo;
if (!rsi || !IsA(rsi, ReturnSetInfo))
- elog(ERROR, "No ReturnSetInfo sent! function must be declared returning a 'setof' integer");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("int_enum called in context that cannot accept a set")));
if (!p)
{
- elog(WARNING, "No data sent");
+ elog(WARNING, "no data sent");
PG_RETURN_NULL();
}
pc->flags = TOASTED;
if (!pc->p)
{
- elog(ERROR, "Error in toaster!!! no detoasting");
+ /* internal error */
+ elog(ERROR, "error in toaster; not detoasting");
PG_RETURN_NULL();
}
}
#include "access/itup.h"
#include "access/rtree.h"
#include "catalog/pg_type.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
#define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) )
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
-#define ARRISVOID(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : ( ( ARR_NDIM(x) ) ? (elog(ERROR,"Array is not one-dimensional: %d dimensions",ARRNELEMS( x )),1) : 0 ) ) : 0 )
+#define ARRISVOID(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : ( ( ARR_NDIM(x) ) ? ( \
+ ereport(ERROR, \
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), \
+ errmsg("array must be one-dimensional, not %d dimensions", ARRNELEMS( x )))) \
+ ,1) : 0 ) ) : 0 )
#define SORT(x) \
do { \
else
{
if (lenstack == STACKDEPTH)
- elog(ERROR, "Stack too short");
+ ereport(ERROR,
+ (errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
+ errmsg("statement too complex")));
stack[lenstack] = val;
lenstack++;
}
break;
case ERR:
default:
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
return ERR;
}
{
#ifdef BS_DEBUG
elog(DEBUG3, (ptr[*pos].type == OPR) ?
- "%d %c" : "%d %d ", *pos, ptr[*pos].val);
+ "%d %c" : "%d %d", *pos, ptr[*pos].val);
#endif
if (ptr[*pos].type == VAL)
{
/* make polish notation (postfix, but in reverse order) */
makepol(&state);
if (!state.num)
- elog(ERROR, "Empty query");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("empty query")));
commonlen = COMPUTESIZE(state.num);
query = (QUERYTYPE *) palloc(commonlen);
INFIX nrm;
if (query->size == 0)
- elog(ERROR, "Empty");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("empty query")));
+
nrm.curpol = GETQUERY(query) + query->size - 1;
nrm.buflen = 32;
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
int4 len;
if (query->size == 0)
- elog(ERROR, "Empty");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("empty query")));
q = (ITEM *) palloc(sizeof(ITEM) * query->size);
memcpy((void *) q, GETQUERY(query), sizeof(ITEM) * query->size);
&& (d[3] == 'C' || d[3] == 'c'))
dir = 0;
if (dir == -1)
- elog(ERROR, "Invalid second parameter in function sort. It must be 'ASC' or 'DESC'.");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("second parameter must be \"ASC\" or \"DESC\"")));
QSORT(a, dir);
PG_RETURN_POINTER(a);
}
Datum
_intbig_in(PG_FUNCTION_ARGS) {
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("_intbig_in() not implemented")));
PG_RETURN_DATUM(0);
}
Datum
_intbig_out(PG_FUNCTION_ARGS) {
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("_intbig_out() not implemented")));
PG_RETURN_DATUM(0);
}
--
-- first, define the datatype. Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of _int.sql.
--
\set ECHO none
-psql:_int.sql:13: NOTICE: ProcedureCreate: type query_int is not yet defined
-psql:_int.sql:18: NOTICE: Argument type "query_int" is only a shell
-psql:_int.sql:367: NOTICE: ProcedureCreate: type intbig_gkey is not yet defined
-psql:_int.sql:372: NOTICE: Argument type "intbig_gkey" is only a shell
+psql:_int.sql:13: NOTICE: type query_int is not yet defined
+DETAIL: Creating a shell type definition.
+psql:_int.sql:18: NOTICE: argument type query_int is only a shell
+psql:_int.sql:367: NOTICE: type intbig_gkey is not yet defined
+DETAIL: Creating a shell type definition.
+psql:_int.sql:372: NOTICE: argument type intbig_gkey is only a shell
SELECT intset(1234);
intset
--------
--
-- first, define the datatype. Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of _int.sql.
--
\set ECHO none
\i _int.sql
/*
* PostgreSQL type definitions for ISBNs.
*
- * $Id: isbn_issn.c,v 1.5 2002/11/04 17:14:29 tgl Exp $
+ * $Id: isbn_issn.c,v 1.6 2003/07/24 17:52:29 tgl Exp $
*/
#include "postgres.h"
if (strlen(str) != 13)
{
- elog(ERROR, "isbn_in: invalid ISBN \"%s\"", str);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid ISBN: \"%s\"", str),
+ errdetail("incorrect length")));
+
return (NULL);
}
if (isbn_sum(str) != 0)
{
- elog(ERROR, "isbn_in: purported ISBN \"%s\" failed checksum",
- str);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid ISBN: \"%s\"", str),
+ errdetail("failed checksum")));
return (NULL);
}
if (strlen(str) != 9)
{
- elog(ERROR, "issn_in: invalid ISSN \"%s\"", str);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid ISSN: \"%s\"", str),
+ errdetail("incorrect length")));
+
return (NULL);
}
if (issn_sum(str) != 0)
{
- elog(ERROR, "issn_in: purported ISSN \"%s\" failed checksum",
- str);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid ISSN: \"%s\"", str),
+ errdetail("failed checksum")));
return (NULL);
}
/*
* PostgreSQL type definitions for managed LargeObjects.
*
- * $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.12 2002/08/15 02:58:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.13 2003/07/24 17:52:30 tgl Exp $
*
*/
count = sscanf(str, "%u", &oid);
if (count < 1)
- elog(ERROR, "lo_in: error in parsing \"%s\"", str);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("error in parsing \"%s\"", str)));
if (oid == InvalidOid)
- elog(ERROR, "lo_in: illegal oid \"%s\"", str);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("illegal oid: \"%s\"", str)));
}
else
{
oid = DatumGetObjectId(DirectFunctionCall1(lo_creat,
Int32GetDatum(INV_READ | INV_WRITE)));
if (oid == InvalidOid)
- elog(ERROR, "lo_in: InvalidOid returned from lo_creat");
+ /* internal error */
+ elog(ERROR, "InvalidOid returned from lo_creat");
}
result = (Blob *) palloc(sizeof(Blob));
HeapTuple trigtuple; /* The original value of tuple */
if (!CALLED_AS_TRIGGER(fcinfo))
- elog(ERROR, "lo: not fired by trigger manager");
+ /* internal error */
+ elog(ERROR, "not fired by trigger manager");
/*
* Fetch some values from trigdata
ltree *item = (ltree *) ARR_DATA_PTR(val);
if (ARR_NDIM(val) != 1)
- elog(ERROR, "Dimension of array != 1");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array must be one-dimensional")));
key = (ltree_gist *) palloc(len);
key->len = len;
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
if (ARR_NDIM(_query) != 1)
- elog(ERROR, "Dimension of array != 1");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array must be one-dimensional")));
while (num > 0) {
if ( gist_qe(key, query) )
res = _arrq_cons(key, (ArrayType *) query);
break;
default:
- elog(ERROR, "Unknown StrategyNumber: %d", strategy);
+ /* internal error */
+ elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
}
PG_RETURN_BOOL(res);
}
ltree *item = (ltree *) ARR_DATA_PTR(la);
if (ARR_NDIM(la) != 1)
- elog(ERROR, "Dimension of array != 1");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array must be one-dimensional")));
if (found)
*found = NULL;
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
if (ARR_NDIM(_query) != 1)
- elog(ERROR, "Dimension of array != 1");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array must be one-dimensional")));
while (num > 0) {
if ( array_iterator(_tree, ltq_regex, (void*)query, NULL) ) {
\set ECHO none
-psql:ltree.sql:7: NOTICE: ProcedureCreate: type ltree is not yet defined
-psql:ltree.sql:12: NOTICE: Argument type "ltree" is only a shell
-psql:ltree.sql:299: NOTICE: ProcedureCreate: type lquery is not yet defined
-psql:ltree.sql:304: NOTICE: Argument type "lquery" is only a shell
-psql:ltree.sql:410: NOTICE: ProcedureCreate: type ltxtquery is not yet defined
-psql:ltree.sql:415: NOTICE: Argument type "ltxtquery" is only a shell
-psql:ltree.sql:477: NOTICE: ProcedureCreate: type ltree_gist is not yet defined
-psql:ltree.sql:482: NOTICE: Argument type "ltree_gist" is only a shell
+psql:ltree.sql:7: NOTICE: type ltree is not yet defined
+DETAIL: Creating a shell type definition.
+psql:ltree.sql:12: NOTICE: argument type ltree is only a shell
+psql:ltree.sql:299: NOTICE: type lquery is not yet defined
+DETAIL: Creating a shell type definition.
+psql:ltree.sql:304: NOTICE: argument type lquery is only a shell
+psql:ltree.sql:410: NOTICE: type ltxtquery is not yet defined
+DETAIL: Creating a shell type definition.
+psql:ltree.sql:415: NOTICE: argument type ltxtquery is only a shell
+psql:ltree.sql:477: NOTICE: type ltree_gist is not yet defined
+DETAIL: Creating a shell type definition.
+psql:ltree.sql:482: NOTICE: argument type ltree_gist is only a shell
SELECT ''::ltree;
ltree
-------
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
if (ARR_NDIM(_query) != 1)
- elog(ERROR, "Dimension of array != 1");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array must be one-dimensional")));
while (num > 0) {
if (DatumGetBool(DirectFunctionCall2(ltq_regex,
Datum
ltree_gist_in(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Unimplemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("ltree_gist_in() not implemented")));
PG_RETURN_DATUM(0);
}
Datum
ltree_gist_out(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Unimplemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("ltree_gist_out() not implemented")));
PG_RETURN_DATUM(0);
}
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
if (ARR_NDIM(_query) != 1)
- elog(ERROR, "Dimension of array != 1");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array must be one-dimensional")));
while (num > 0) {
if ( gist_qe(key, query) && gist_between(key, query) )
res = arrq_cons(key, (ArrayType *) query);
break;
default:
- elog(ERROR, "Unknown StrategyNumber: %d", strategy);
+ /* internal error */
+ elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
}
PG_RETURN_BOOL(res);
}
Datum lquery_out(PG_FUNCTION_ARGS);
-#define UNCHAR elog(ERROR,"Syntax error in position %d near '%c'", (int)(ptr-buf), *ptr)
+#define UNCHAR ereport(ERROR, \
+ (errcode(ERRCODE_SYNTAX_ERROR), \
+ errmsg("syntax error at position %d near \"%c\"", \
+ (int)(ptr-buf), *ptr)));
+
typedef struct
{
{
lptr->len = ptr - lptr->start;
if (lptr->len > 255)
- elog(ERROR, "Name of level is too long (%d, must be < 256) in position %d",
- lptr->len, (int) (lptr->start - buf));
+ ereport(ERROR,
+ (errcode(ERRCODE_NAME_TOO_LONG),
+ errmsg("name of level is too long"),
+ errdetail("name length is %d, must " \
+ "be < 256, in position %d",
+ lptr->len, (int) (lptr->start - buf))));
+
totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE);
lptr++;
state = LTPRS_WAITNAME;
UNCHAR;
}
else
- elog(ERROR, "Inner error in parser");
+ /* internal error */
+ elog(ERROR, "internal error in parser");
ptr++;
}
{
lptr->len = ptr - lptr->start;
if (lptr->len > 255)
- elog(ERROR, "Name of level is too long (%d, must be < 256) in position %d",
- lptr->len, (int) (lptr->start - buf));
+ ereport(ERROR,
+ (errcode(ERRCODE_NAME_TOO_LONG),
+ errmsg("name of level is too long"),
+ errdetail("name length is %d, must " \
+ "be < 256, in position %d",
+ lptr->len, (int) (lptr->start - buf))));
+
totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE);
lptr++;
}
else if (!(state == LTPRS_WAITNAME && lptr == list))
- elog(ERROR, "Unexpected end of line");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Unexpected end of line.")));
result = (ltree *) palloc(LTREE_HDRSIZE + totallen);
result->len = LTREE_HDRSIZE + totallen;
((lptr->flag & LVAR_INCASE) ? 1 : 0) -
((lptr->flag & LVAR_ANYEND) ? 1 : 0);
if (lptr->len > 255)
- elog(ERROR, "Name of level is too long (%d, must be < 256) in position %d",
- lptr->len, (int) (lptr->start - buf));
+ ereport(ERROR,
+ (errcode(ERRCODE_NAME_TOO_LONG),
+ errmsg("name of level is too long"),
+ errdetail("name length is %d, must " \
+ "be < 256, in position %d",
+ lptr->len, (int) (lptr->start - buf))));
+
state = LQPRS_WAITVAR;
}
else if (*ptr == '.')
((lptr->flag & LVAR_INCASE) ? 1 : 0) -
((lptr->flag & LVAR_ANYEND) ? 1 : 0);
if (lptr->len > 255)
- elog(ERROR, "Name of level is too long (%d, must be < 256) in position %d",
- lptr->len, (int) (lptr->start - buf));
+ ereport(ERROR,
+ (errcode(ERRCODE_NAME_TOO_LONG),
+ errmsg("name of level is too long"),
+ errdetail("name length is %d, must " \
+ "be < 256, in position %d",
+ lptr->len, (int) (lptr->start - buf))));
+
state = LQPRS_WAITLEVEL;
curqlevel = NEXTLEV(curqlevel);
}
UNCHAR;
}
else
- elog(ERROR, "Inner error in parser");
+ /* internal error */
+ elog(ERROR, "internal error in parser");
ptr++;
}
if (state == LQPRS_WAITDELIM)
{
if (lptr->start == ptr)
- elog(ERROR, "Unexpected end of line");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Unexpected end of line.")));
+
lptr->len = ptr - lptr->start -
((lptr->flag & LVAR_SUBLEXEM) ? 1 : 0) -
((lptr->flag & LVAR_INCASE) ? 1 : 0) -
((lptr->flag & LVAR_ANYEND) ? 1 : 0);
if (lptr->len == 0)
- elog(ERROR, "Unexpected end of line");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Unexpected end of line.")));
+
if (lptr->len > 255)
- elog(ERROR, "Name of level is too long (%d, must be < 256) in position %d",
- lptr->len, (int) (lptr->start - buf));
+ ereport(ERROR,
+ (errcode(ERRCODE_NAME_TOO_LONG),
+ errmsg("name of level is too long"),
+ errdetail("name length is %d, must " \
+ "be < 256, in position %d",
+ lptr->len, (int) (lptr->start - buf))));
}
else if (state == LQPRS_WAITOPEN)
curqlevel->high = 0xffff;
else if (state != LQPRS_WAITEND)
- elog(ERROR, "Unexpected end of line");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Unexpected end of line.")));
curqlevel = tmpql;
totallen = LQUERY_HDRSIZE;
}
}
else if (curqlevel->low > curqlevel->high)
- elog(ERROR, "Low limit(%d) is greater than upper(%d)", curqlevel->low, curqlevel->high);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Low limit(%d) is greater than upper(%d).",
+ curqlevel->low, curqlevel->high)));
+
curqlevel = NEXTLEV(curqlevel);
}
int i;
if (startpos < 0 || endpos < 0 || startpos >= t->numlevel || startpos > endpos)
- elog(ERROR, "Wrong positions");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid positions")));
if (endpos > t->numlevel)
endpos = t->numlevel;
*flag = 0;
}
else if (!isspace((unsigned int) *(state->buf)))
- elog(ERROR, "Operand syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("operand syntax error")));
break;
case INOPERAND:
if (ISALNUM(*(state->buf)))
{
if (*flag)
- elog(ERROR, "Modificators syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("modificators syntax error")));
(*lenval)++;
}
else if (*(state->buf) == '%')
tmp->val = val;
tmp->flag = flag;
if (distance > 0xffff)
- elog(ERROR, "Value is too big");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("value is too big")));
if (lenval > 0xff)
- elog(ERROR, "Operand is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("operand is too long")));
tmp->distance = distance;
tmp->length = lenval;
tmp->next = state->str;
pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag)
{
if (lenval > 0xffff)
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("word is too long")));
pushquery(state, type, ltree_crc32_sz((uint8 *) strval, lenval),
state->curop - state->op, lenval, flag);
else
{
if (lenstack == STACKDEPTH)
- elog(ERROR, "Stack too short");
+ /* internal error */
+ elog(ERROR, "stack too short");
stack[lenstack] = val;
lenstack++;
}
break;
case ERR:
default:
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
+
return ERR;
}
/* parse query & make polish notation (postfix, but in reverse order) */
makepol(&state);
if (!state.num)
- elog(ERROR, "Empty query");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Empty query.")));
+
/* make finish struct */
commonlen = COMPUTESIZE(state.num, state.sumlen);
query = (ltxtquery *) palloc(commonlen);
INFIX nrm;
if (query->size == 0)
- elog(ERROR, "Empty");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Empty query.")));
+
nrm.curpol = GETQUERY(query);
nrm.buflen = 32;
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
/* Called by trigger manager ? */
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "noup: not fired by trigger manager");
/* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "noup: can't process STATEMENT events");
- /* Not should be called for INSERT */
+ /* Should not be called for INSERT */
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "noup: can't process INSERT events");
- /* Not should be called for DELETE */
+ /* Should not be called for DELETE */
else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "noup: can't process DELETE events");
/* check new Tuple */
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "noup: SPI_connect returned %d", ret);
/*
/* Bad guys may give us un-existing column in CREATE TRIGGER */
if (fnumber < 0)
+ /* internal error */
elog(ERROR, "noup: there is no attribute %s in relation %s",
args[i], SPI_getrelname(rel));
*/
if (!isnull)
{
-
elog(WARNING, "%s: update not allowed", args[i]);
SPI_finish();
return PointerGetDatum(NULL);
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mhash.c,v 1.7 2001/11/20 18:54:07 momjian Exp $
+ * $Id: mhash.c,v 1.8 2003/07/24 17:52:33 tgl Exp $
*/
#include <postgres.h>
err = mcrypt_generic_init(ctx, (char *) key, klen, (char *) iv);
if (err < 0)
- elog(ERROR, "mcrypt_generic_init error: %s", mcrypt_strerror(err));
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("mcrypt_generic_init error"),
+ errdetail("%s", mcrypt_strerror(err))));
c->pstat = 1;
return 0;
err = mcrypt_generic(ctx, res, dlen);
if (err < 0)
- elog(ERROR, "mcrypt_generic error: %s", mcrypt_strerror(err));
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("mcrypt_generic error"),
+ errdetail("%s", mcrypt_strerror(err))));
return 0;
}
err = mdecrypt_generic(ctx, res, dlen);
if (err < 0)
- elog(ERROR, "mdecrypt_generic error: %s", mcrypt_strerror(err));
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("mdecrypt_generic error"),
+ errdetail("%s", mcrypt_strerror(err))));
return 0;
}
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: pgcrypto.c,v 1.12 2001/12/30 23:09:41 tgl Exp $
+ * $Id: pgcrypto.c,v 1.13 2003/07/24 17:52:33 tgl Exp $
*/
#include <postgres.h>
buf[len] = 0;
len = px_gen_salt(buf, buf, 0);
if (len == 0)
- elog(ERROR, "No such crypt algorithm");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("no such crypt algorithm")));
res = (text *) palloc(len + VARHDRSZ);
VARATT_SIZEP(res) = len + VARHDRSZ;
buf[len] = 0;
len = px_gen_salt(buf, buf, rounds);
if (len == 0)
- elog(ERROR, "No such crypt algorithm or bad number of rounds");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("no such crypt algorithm or bad number of rounds")));
res = (text *) palloc(len + VARHDRSZ);
VARATT_SIZEP(res) = len + VARHDRSZ;
pfree(buf1);
if (cres == NULL)
- elog(ERROR, "crypt(3) returned NULL");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("crypt(3) returned NULL")));
clen = strlen(cres);
if (err)
{
pfree(res);
- elog(ERROR, "encrypt error: %d", err);
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("encrypt error: %d", err)));
}
VARATT_SIZEP(res) = VARHDRSZ + rlen;
px_combo_free(c);
if (err)
- elog(ERROR, "decrypt error: %d", err);
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("decrypt error: %d", err)));
VARATT_SIZEP(res) = VARHDRSZ + rlen;
px_combo_free(c);
if (err)
- elog(ERROR, "encrypt_iv error: %d", err);
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("encrypt_iv error: %d", err)));
VARATT_SIZEP(res) = VARHDRSZ + rlen;
px_combo_free(c);
if (err)
- elog(ERROR, "decrypt_iv error: %d", err);
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
+ errmsg("decrypt_iv error: %d", err)));
VARATT_SIZEP(res) = VARHDRSZ + rlen;
{
if (silent)
return NULL;
- elog(ERROR, "%s type does not exist (name too long)", desc);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("%s type does not exist (name too long)", desc)));
}
p = VARDATA(name);
err = provider_lookup(buf, &res);
if (err && !silent)
- elog(ERROR, "%s type does not exist: '%s'", desc, buf);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("%s type does not exist: \"%s\"", desc, buf)));
return err ? NULL : res;
}
/* Called by trigger manager ? */
if (!CurrentTriggerData)
+ /* internal error */
elog(ERROR, "_rserv_log_: triggers are not initialized");
/* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event))
+ /* internal error */
elog(ERROR, "_rserv_log_: can't process STATEMENT events");
tuple = CurrentTriggerData->tg_trigtuple;
args = trigger->tgargs;
if (nargs != 1) /* odd number of arguments! */
+ /* internal error */
elog(ERROR, "_rserv_log_: need in *one* argument");
keynum = atoi(args[0]);
if (keynum < 0 && keynum != ObjectIdAttributeNumber)
+ /* internal error */
elog(ERROR, "_rserv_log_: invalid keynum %d", keynum);
rel = CurrentTriggerData->tg_relation;
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "_rserv_log_: SPI_connect returned %d", ret);
if (keynum == ObjectIdAttributeNumber)
key = SPI_getvalue(tuple, tupdesc, keynum);
if (key == NULL)
- elog(ERROR, "_rserv_log_: key must be not null");
+ ereport(ERROR,
+ (errcode(ERRCODE_NOT_NULL_VIOLATION),
+ errmsg("key must be not null")));
if (newtuple && keynum != ObjectIdAttributeNumber)
{
newkey = SPI_getvalue(newtuple, tupdesc, keynum);
if (newkey == NULL)
- elog(ERROR, "_rserv_log_: key must be not null");
+ ereport(ERROR,
+ (errcode(ERRCODE_NOT_NULL_VIOLATION),
+ errmsg("key must be not null")));
if (strcmp(newkey, key) == 0)
newkey = NULL;
else
ret = SPI_exec(sql, 0);
if (ret < 0)
- elog(ERROR, "_rserv_log_: SPI_exec(update) returned %d", ret);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("SPI_exec(update) returned %d", ret)));
/*
* If no tuple was UPDATEd then do INSERT...
*/
if (SPI_processed > 1)
- elog(ERROR, "_rserv_log_: duplicate tuples");
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("duplicate tuples")));
+
else if (SPI_processed == 0)
{
snprintf(sql, 8192, "insert into _RSERV_LOG_ "
ret = SPI_exec(sql, 0);
if (ret < 0)
- elog(ERROR, "_rserv_log_: SPI_exec(insert) returned %d", ret);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("SPI_exec(insert) returned %d", ret)));
}
if (okey != key && okey != outbuf)
ret = SPI_exec(sql, 0);
if (ret < 0)
- elog(ERROR, "_rserv_log_: SPI_exec returned %d", ret);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("SPI_exec returned %d", ret)));
if (okey != newkey && okey != outbuf)
pfree(okey);
int ret;
if (SerializableSnapshot == NULL)
+ /* internal error */
elog(ERROR, "_rserv_sync_: SerializableSnapshot is NULL");
buf[0] = 0;
}
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "_rserv_sync_: SPI_connect returned %d", ret);
snprintf(sql, 8192, "insert into _RSERV_SYNC_ "
ret = SPI_exec(sql, 0);
if (ret < 0)
- elog(ERROR, "_rserv_sync_: SPI_exec returned %d", ret);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("SPI_exec returned %d", ret)));
SPI_finish();
#include "postgres.h"
-#include "utils/elog.h"
-
static char *PARSE_BUFFER;
static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE;
PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s);
if (PARSE_BUFFER_SIZE == 0)
- elog(ERROR, "seg_in: can't parse an empty string");
+ ereport(ERROR,
+ (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
+ errmsg("can't parse an empty string")));
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
}
-- does not depend on contents of seg.sql.
--
\set ECHO none
-psql:seg.sql:10: NOTICE: ProcedureCreate: type seg is not yet defined
-psql:seg.sql:15: NOTICE: Argument type "seg" is only a shell
+psql:seg.sql:10: NOTICE: type seg is not yet defined
+DETAIL: Creating a shell type definition.
+psql:seg.sql:15: NOTICE: argument type seg is only a shell
--
-- testing the input and output functions
--
-- invalid input
SELECT ''::seg AS seg;
-ERROR: seg_in: can't parse an empty string
+ERROR: can't parse an empty string
SELECT 'ABC'::seg AS seg;
-ERROR: syntax error at or near position 1, character ('A', \101), input: 'ABC'
+ERROR: syntax error
+DETAIL: syntax error at or near position 1, character ('A', \101), input: 'ABC'
SELECT '1ABC'::seg AS seg;
-ERROR: syntax error at or near position 2, character ('A', \101), input: '1ABC'
+ERROR: syntax error
+DETAIL: syntax error at or near position 2, character ('A', \101), input: '1ABC'
SELECT '1.'::seg AS seg;
-ERROR: syntax error at or near position 2, character ('.', \056), input: '1.'
+ERROR: syntax error
+DETAIL: syntax error at or near position 2, character ('.', \056), input: '1.'
SELECT '1.....'::seg AS seg;
-ERROR: syntax error at or near position 6, character ('.', \056), input: '1.....'
+ERROR: syntax error
+DETAIL: syntax error at or near position 6, character ('.', \056), input: '1.....'
SELECT '.1'::seg AS seg;
-ERROR: syntax error at or near position 2, character ('1', \061), input: '.1'
+ERROR: syntax error
+DETAIL: syntax error at or near position 2, character ('1', \061), input: '.1'
SELECT '1..2.'::seg AS seg;
-ERROR: syntax error at or near position 5, character ('.', \056), input: '1..2.'
+ERROR: syntax error
+DETAIL: syntax error at or near position 5, character ('.', \056), input: '1..2.'
SELECT '1 e7'::seg AS seg;
-ERROR: syntax error at or near position 3, character ('e', \145), input: '1 e7'
+ERROR: syntax error
+DETAIL: syntax error at or near position 3, character ('e', \145), input: '1 e7'
SELECT '1e700'::seg AS seg;
-ERROR: numeric value 1e700 unrepresentable
+ERROR: syntax error
+DETAIL: numeric value 1e700 unrepresentable
--
-- testing the operators
--
#include "access/gist.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "segdata.h"
if (b->l_ext == '~')
return 1;
/* can't get here unless data is corrupt */
- elog(ERROR, "seg_cmp: bogus lower boundary types %d %d",
+ elog(ERROR, "bogus lower boundary types %d %d",
(int) a->l_ext, (int) b->l_ext);
}
if (b->u_ext == '~')
return -1;
/* can't get here unless data is corrupt */
- elog(ERROR, "seg_cmp: bogus upper boundary types %d %d",
+ elog(ERROR, "bogus upper boundary types %d %d",
(int) a->u_ext, (int) b->u_ext);
}
#include "postgres.h"
#include <math.h>
-
-#include "utils/elog.h"
#include "segdata.h"
#include "buffer.h"
((SEG *)result)->upper = $3.val;
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
reset_parse_buffer();
- elog(ERROR, "swapped boundaries: %g is greater than %g", ((SEG *)result)->lower, ((SEG *)result)->upper );
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("swapped boundaries: %g is greater than %g",
+ ((SEG *)result)->lower, ((SEG *)result)->upper)));
+
YYERROR;
}
((SEG *)result)->l_sigd = $1.sigd;
if ( errno ) {
snprintf(buf, 256, "numeric value %s unrepresentable", value);
reset_parse_buffer();
- elog(ERROR, "%s", buf);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("%s", buf)));
}
return result;
);
reset_parse_buffer();
- elog(ERROR, "%s", buf);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("%s", buf)));
return 0;
}
int i;
if (!CALLED_AS_TRIGGER(fcinfo))
- elog(ERROR, "autoinc: not fired by trigger manager");
+ /* internal error */
+ elog(ERROR, "not fired by trigger manager");
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
- elog(ERROR, "autoinc: can't process STATEMENT events");
+ /* internal error */
+ elog(ERROR, "can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
- elog(ERROR, "autoinc: must be fired before event");
+ /* internal error */
+ elog(ERROR, "must be fired before event");
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
rettuple = trigdata->tg_trigtuple;
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
rettuple = trigdata->tg_newtuple;
else
- elog(ERROR, "autoinc: can't process DELETE events");
+ /* internal error */
+ elog(ERROR, "can't process DELETE events");
rel = trigdata->tg_relation;
relname = SPI_getrelname(rel);
nargs = trigger->tgnargs;
if (nargs <= 0 || nargs % 2 != 0)
+ /* internal error */
elog(ERROR, "autoinc (%s): even number gt 0 of arguments was expected", relname);
args = trigger->tgargs;
Datum seqname;
if (attnum < 0)
- elog(ERROR, "autoinc (%s): there is no attribute %s",
- relname, args[i]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("\"%s\" has no attribute \"%s\"",
+ relname, args[i])));
+
if (SPI_gettypeid(tupdesc, attnum) != INT4OID)
- elog(ERROR, "autoinc (%s): attribute %s must be of INT4 type",
- relname, args[i]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("attribute \"%s\" of \"%s\" must be type INT4",
+ args[i], relname)));
val = DatumGetInt32(SPI_getbinval(rettuple, tupdesc, attnum, &isnull));
{
rettuple = SPI_modifytuple(rel, rettuple, chnattrs, chattrs, newvals, NULL);
if (rettuple == NULL)
+ /* internal error */
elog(ERROR, "autoinc (%s): %d returned by SPI_modifytuple",
relname, SPI_result);
}
/* sanity checks from autoinc.c */
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "insert_username: not fired by trigger manager");
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "insert_username: can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "insert_username: must be fired before event");
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
rettuple = trigdata->tg_newtuple;
else
+ /* internal error */
elog(ERROR, "insert_username: can't process DELETE events");
rel = trigdata->tg_relation;
nargs = trigger->tgnargs;
if (nargs != 1)
+ /* internal error */
elog(ERROR, "insert_username (%s): one argument was expected", relname);
args = trigger->tgargs;
attnum = SPI_fnumber(tupdesc, args[0]);
if (attnum < 0)
- elog(ERROR, "insert_username (%s): there is no attribute %s", relname, args[0]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("\"%s\" has no attribute \"%s\"", relname, args[0])));
+
if (SPI_gettypeid(tupdesc, attnum) != TEXTOID)
- elog(ERROR, "insert_username (%s): attribute %s must be of TEXT type",
- relname, args[0]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("attribute \"%s\" of \"%s\" must be type TEXT",
+ args[0], relname)));
/* create fields containing name */
newval = DirectFunctionCall1(textin,
/* construct new tuple */
rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL);
if (rettuple == NULL)
- elog(ERROR, "insert_username (%s): %d returned by SPI_modifytuple",
+ /* internal error */
+ elog(ERROR, "insert_username (\"%s\"): %d returned by SPI_modifytuple",
relname, SPI_result);
pfree(relname);
TupleDesc tupdesc; /* tuple description */
if (!CALLED_AS_TRIGGER(fcinfo))
- elog(ERROR, "moddatetime: not fired by trigger manager.");
+ /* internal error */
+ elog(ERROR, "moddatetime: not fired by trigger manager");
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
- elog(ERROR, "moddatetime: can't process STATEMENT events.");
+ /* internal error */
+ elog(ERROR, "moddatetime: can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
- elog(ERROR, "moddatetime: must be fired before event.");
+ /* internal error */
+ elog(ERROR, "moddatetime: must be fired before event");
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
- elog(ERROR, "moddatetime: must be fired before event.");
+ /* internal error */
+ elog(ERROR, "moddatetime: must be fired before event");
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
rettuple = trigdata->tg_newtuple;
else
- elog(ERROR, "moddatetime: can't process DELETE events.");
+ /* internal error */
+ elog(ERROR, "moddatetime: can't process DELETE events");
rel = trigdata->tg_relation;
relname = SPI_getrelname(rel);
nargs = trigger->tgnargs;
if (nargs != 1)
- elog(ERROR, "moddatetime (%s): A single argument was expected.", relname);
+ /* internal error */
+ elog(ERROR, "moddatetime (%s): A single argument was expected", relname);
args = trigger->tgargs;
/* must be the field layout? */
* even exits. The above function must return -1 if name not found?
*/
if (attnum < 0)
- elog(ERROR, "moddatetime (%s): there is no attribute %s", relname,
- args[0]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("\"%s\" has no attribute \"%s\"",
+ relname, args[0])));
/*
* OK, this is where we make sure the timestamp field that we are
* novel idea !-)
*/
if (SPI_gettypeid(tupdesc, attnum) != TIMESTAMPOID)
- elog(ERROR, "moddatetime (%s): attribute %s must be of TIMESTAMP type",
- relname, args[0]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("attribute \"%s\" of \"%s\" must be type TIMESTAMP",
+ args[0], relname)));
/* 1 is the number of items in the arrays attnum and newdt.
attnum is the positional number of the field to be updated.
rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newdt, NULL);
if (rettuple == NULL)
+ /* internal error */
elog(ERROR, "moddatetime (%s): %d returned by SPI_modifytuple",
relname, SPI_result);
int i;
#ifdef DEBUG_QUERY
- elog(DEBUG4, "Check_primary_key Enter Function");
+ elog(DEBUG4, "check_primary_key: Enter Function");
#endif
/*
/* Called by trigger manager ? */
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "check_primary_key: not fired by trigger manager");
/* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "check_primary_key: can't process STATEMENT events");
/* If INSERTion then must check Tuple to being inserted */
/* Not should be called for DELETE */
else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "check_primary_key: can't process DELETE events");
/* If UPDATion the must check new Tuple, not old one */
args = trigger->tgargs;
if (nargs % 2 != 1) /* odd number of arguments! */
+ /* internal error */
elog(ERROR, "check_primary_key: odd number of arguments should be specified");
nkeys = nargs / 2;
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "check_primary_key: SPI_connect returned %d", ret);
/*
/* Bad guys may give us un-existing column in CREATE TRIGGER */
if (fnumber < 0)
- elog(ERROR, "check_primary_key: there is no attribute %s in relation %s",
- args[i], SPI_getrelname(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("there is no attribute \"%s\" in relation \"%s\"",
+ args[i], SPI_getrelname(rel))));
/* Well, get binary (in internal format) value of column */
kvals[i] = SPI_getbinval(tuple, tupdesc, fnumber, &isnull);
/* Prepare plan for query */
pplan = SPI_prepare(sql, nkeys, argtypes);
if (pplan == NULL)
+ /* internal error */
elog(ERROR, "check_primary_key: SPI_prepare returned %d", SPI_result);
/*
*/
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
+ /* internal error */
elog(ERROR, "check_primary_key: SPI_saveplan returned %d", SPI_result);
plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan;
/* we have no NULLs - so we pass ^^^^ here */
if (ret < 0)
+ /* internal error */
elog(ERROR, "check_primary_key: SPI_execp returned %d", ret);
/*
* If there are no tuples returned by SELECT then ...
*/
if (SPI_processed == 0)
- elog(ERROR, "%s: tuple references non-existing key in %s",
- trigger->tgname, relname);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("tuple references non-existent key"),
+ errdetail("Trigger \"%s\" found tuple referencing non-existent key in \"%s\".", trigger->tgname, relname)));
SPI_finish();
r;
#ifdef DEBUG_QUERY
- elog(DEBUG4, "Check_foreign_key Enter Function");
+ elog(DEBUG4, "check_foreign_key: Enter Function");
#endif
/*
/* Called by trigger manager ? */
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "check_foreign_key: not fired by trigger manager");
/* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "check_foreign_key: can't process STATEMENT events");
/* Not should be called for INSERT */
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "check_foreign_key: can't process INSERT events");
/* Have to check tg_trigtuple - tuple being deleted */
if (nargs < 5) /* nrefs, action, key, Relation, key - at
* least */
+ /* internal error */
elog(ERROR, "check_foreign_key: too short %d (< 5) list of arguments", nargs);
nrefs = pg_atoi(args[0], sizeof(int), 0);
if (nrefs < 1)
+ /* internal error */
elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs);
action = tolower((unsigned char) *(args[1]));
if (action != 'r' && action != 'c' && action != 's')
+ /* internal error */
elog(ERROR, "check_foreign_key: invalid action %s", args[1]);
nargs -= 2;
args += 2;
nkeys = (nargs - nrefs) / (nrefs + 1);
if (nkeys <= 0 || nargs != (nrefs + nkeys * (nrefs + 1)))
+ /* internal error */
elog(ERROR, "check_foreign_key: invalid number of arguments %d for %d references",
nargs + 2, nrefs);
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "check_foreign_key: SPI_connect returned %d", ret);
/*
* else - check that we have exactly nrefs plan(s) ready
*/
else if (plan->nplans != nrefs)
+ /* internal error */
elog(ERROR, "%s: check_foreign_key: # of plans changed in meantime",
trigger->tgname);
/* Bad guys may give us un-existing column in CREATE TRIGGER */
if (fnumber < 0)
- elog(ERROR, "check_foreign_key: there is no attribute %s in relation %s",
- args[i], SPI_getrelname(rel));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("there is no attribute \"%s\" in relation \"%s\"",
+ args[i], SPI_getrelname(rel))));
/* Well, get binary (in internal format) value of column */
kvals[i] = SPI_getbinval(trigtuple, tupdesc, fnumber, &isnull);
/* this shouldn't happen! SPI_ERROR_NOOUTFUNC ? */
if (oldval == NULL)
+ /* internal error */
elog(ERROR, "check_foreign_key: SPI_getvalue returned %d", SPI_result);
newval = SPI_getvalue(newtuple, tupdesc, fnumber);
if (newval == NULL || strcmp(oldval, newval) != 0)
strcmp(type, "date") && strcmp(type, "timestamp")) == 0)
is_char_type = 1;
#ifdef DEBUG_QUERY
- elog(DEBUG4, "Check_foreign_key Debug value %s type %s %d",
+ elog(DEBUG4, "check_foreign_key Debug value %s type %s %d",
nv, type, is_char_type);
#endif
/* Prepare plan for query */
pplan = SPI_prepare(sql, nkeys, argtypes);
if (pplan == NULL)
+ /* internal error */
elog(ERROR, "check_foreign_key: SPI_prepare returned %d", SPI_result);
/*
*/
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
+ /* internal error */
elog(ERROR, "check_foreign_key: SPI_saveplan returned %d", SPI_result);
plan->splan[r] = pplan;
}
plan->nplans = nrefs;
#ifdef DEBUG_QUERY
- elog(DEBUG4, "Check_foreign_key Debug Query is : %s ", sql);
+ elog(DEBUG4, "check_foreign_key Debug Query is : %s ", sql);
#endif
}
/* we have no NULLs - so we pass ^^^^ here */
if (ret < 0)
- elog(ERROR, "check_foreign_key: SPI_execp returned %d", ret);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("SPI_execp returned %d", ret)));
/* If action is 'R'estrict ... */
if (action == 'r')
{
/* If there is tuple returned by SELECT then ... */
if (SPI_processed > 0)
- elog(ERROR, "%s: tuple referenced in %s",
- trigger->tgname, relname);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("\"%s\": tuple is referenced in \"%s\"",
+ trigger->tgname, relname)));
}
else
{
#ifdef REFINT_VERBOSE
elog(NOTICE, "%s: %d tuple(s) of %s are %s",
trigger->tgname, SPI_processed, relname,
- (action == 'c') ? "deleted" : "setted to null");
+ (action == 'c') ? "deleted" : "set to null");
#endif
}
args += nkeys + 1; /* to the next relation */
/* Called by trigger manager ? */
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "timetravel: not fired by trigger manager");
/* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "timetravel: can't process STATEMENT events");
/* Should be called BEFORE */
if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "timetravel: must be fired before event");
/* INSERT ? */
trigger = trigdata->tg_trigger;
if (trigger->tgnargs != 2)
+ /* internal error */
elog(ERROR, "timetravel (%s): invalid (!= 2) number of arguments %d",
relname, trigger->tgnargs);
{
attnum[i] = SPI_fnumber(tupdesc, args[i]);
if (attnum[i] < 0)
- elog(ERROR, "timetravel (%s): there is no attribute %s", relname, args[i]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("\"%s\" has no attribute \"%s\"",
+ relname, args[i])));
if (SPI_gettypeid(tupdesc, attnum[i]) != ABSTIMEOID)
- elog(ERROR, "timetravel (%s): attributes %s and %s must be of abstime type",
- relname, args[0], args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("attribute \"%s\" of \"%s\" must be type ABSTIME",
+ args[i], relname)));
}
if (isinsert) /* INSERT */
{
if ((chnattrs == 0 && DatumGetInt32(oldon) >= NOEND_ABSTIME) ||
(chnattrs > 0 && DatumGetInt32(newvals[0]) >= NOEND_ABSTIME))
- elog(ERROR, "timetravel (%s): %s ge %s",
- relname, args[0], args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("timetravel (%s): %s ge %s",
+ relname, args[0], args[1])));
newvals[chnattrs] = NOEND_ABSTIME;
chattrs[chnattrs] = attnum[1];
chnattrs++;
DatumGetInt32(oldoff)) ||
(chnattrs > 0 && DatumGetInt32(newvals[0]) >=
DatumGetInt32(oldoff)))
- elog(ERROR, "timetravel (%s): %s ge %s",
- relname, args[0], args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("timetravel (%s): %s ge %s",
+ relname, args[0], args[1])));
}
pfree(relname);
oldon = SPI_getbinval(trigtuple, tupdesc, attnum[0], &isnull);
if (isnull)
- elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]);
-
+ ereport(ERROR,
+ (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
+ errmsg("\"%s\" must be NOT NULL in \"%s\"",
+ args[0],relname)));
oldoff = SPI_getbinval(trigtuple, tupdesc, attnum[1], &isnull);
if (isnull)
- elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
+ errmsg("\"%s\" must be NOT NULL in \"%s\"",
+ args[1],relname)));
/*
* If DELETE/UPDATE of tuple with stop_date neq INFINITY then say
{
newon = SPI_getbinval(newtuple, tupdesc, attnum[0], &isnull);
if (isnull)
- elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]);
+ ereport(ERROR,
+ (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
+ errmsg("\"%s\" must be NOT NULL in \"%s\"",
+ args[0],relname)));
newoff = SPI_getbinval(newtuple, tupdesc, attnum[1], &isnull);
if (isnull)
- elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
+ errmsg("\"%s\" must be NOT NULL in \"%s\"",
+ args[1],relname)));
if (oldon != newon || oldoff != newoff)
- elog(ERROR, "timetravel (%s): you can't change %s and/or %s columns (use set_timetravel)",
- relname, args[0], args[1]);
+ ereport(ERROR,
+ (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
+ errmsg("cannot change columns \"%s\" or \"%s\" in \"%s\"",
+ args[0], args[1], relname),
+ errhint("Use set_timetravel() instead.")));
if (newoff != NOEND_ABSTIME)
{
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "timetravel (%s): SPI_connect returned %d", relname, ret);
/* Fetch tuple values and nulls */
/* Prepare plan for query */
pplan = SPI_prepare(sql, natts, ctypes);
if (pplan == NULL)
+ /* internal error */
elog(ERROR, "timetravel (%s): SPI_prepare returned %d", relname, SPI_result);
/*
*/
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
+ /* internal error */
elog(ERROR, "timetravel (%s): SPI_saveplan returned %d", relname, SPI_result);
plan->splan = pplan;
ret = SPI_execp(plan->splan, cvals, cnulls, 0);
if (ret < 0)
+ /* internal error */
elog(ERROR, "timetravel (%s): SPI_execp returned %d", relname, ret);
/* Tuple to return to upper Executor ... */
-- hash based crosstab
--
create table cth(id serial, rowid text, rowdt timestamp, attribute text, val text);
-NOTICE: CREATE TABLE will create implicit sequence 'cth_id_seq' for SERIAL column 'cth.id'
+NOTICE: CREATE TABLE will create implicit sequence "cth_id_seq" for SERIAL column "cth.id"
insert into cth values(DEFAULT,'test1','01 March 2003','temperature','42');
insert into cth values(DEFAULT,'test1','01 March 2003','test_result','PASS');
-- the next line is intentionally left commented and is therefore a "missing" attribute
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT DISTINCT attribute FROM cth WHERE attribute = ''a'' ORDER BY 1')
AS c(rowid text, rowdt timestamp, temperature int4, test_result text, test_startdate timestamp, volts float8);
-ERROR: load_categories_hash: provided categories SQL must return 1 column of at least one row
+ERROR: provided "categories" SQL must return 1 column of at least one row
-- if category query generates more than one column, get expected error
SELECT * FROM crosstab(
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT DISTINCT rowdt, attribute FROM cth ORDER BY 2')
AS c(rowid text, rowdt timestamp, temperature int4, test_result text, test_startdate timestamp, volts float8);
-ERROR: load_categories_hash: provided categories SQL must return 1 column of at least one row
+ERROR: provided "categories" SQL must return 1 column of at least one row
--
-- connectby
--
hentry = (crosstab_HashEnt*) hash_search(crosstab_HashTable, \
key, HASH_ENTER, &found); \
if (hentry == NULL) \
- elog(ERROR, "out of memory in crosstab_HashTable"); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_OUT_OF_MEMORY), \
+ errmsg("out of memory"))); \
if (found) \
- elog(ERROR, "trying to use a category name more than once"); \
+ ereport(ERROR, \
+ (errcode(ERRCODE_DUPLICATE_OBJECT), \
+ errmsg("duplicate category name"))); \
hentry->catdesc = CATDESC; \
} while(0)
-#define crosstab_HashTableDelete(CATNAME) \
-do { \
- crosstab_HashEnt *hentry; char key[MAX_CATNAME_LEN]; \
- \
- MemSet(key, 0, MAX_CATNAME_LEN); \
- snprintf(key, MAX_CATNAME_LEN - 1, "%s", CATNAME); \
- hentry = (crosstab_HashEnt*) hash_search(crosstab_HashTable, \
- key, HASH_REMOVE, NULL); \
- if (hentry == NULL) \
- elog(WARNING, "trying to delete function name that does not exist."); \
-} while(0)
-
/* hash table */
typedef struct crosstab_hashent
{
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "crosstab: SPI_connect returned %d", ret);
/* Retrieve the desired rows */
* in the final result
*/
if (spi_tupdesc->natts != 3)
- elog(ERROR, "crosstab: provided SQL must return 3 columns;"
- " a rowid, a category, and a values column");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid source data SQL statement"),
+ errdetail("The provided SQL must return 3 " \
+ " columns; rowid, category, and values.")));
}
else
{
else if (functyptype == 'p' && functypeid == RECORDOID)
{
if (fcinfo->nargs != 2)
- elog(ERROR, "Wrong number of arguments specified for function");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("wrong number of arguments")));
else
{
int num_categories = PG_GETARG_INT32(1);
}
}
else
- elog(ERROR, "crosstab: return type must be a row type");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("return type must be a row type")));
/*
* Check that return tupdesc is compatible with the one we got
* attributes
*/
if (!compatCrosstabTupleDescs(tupdesc, spi_tupdesc))
- elog(ERROR, "crosstab: return and sql tuple descriptions are"
- " incompatible");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("return and sql tuple descriptions are " \
+ "incompatible")));
/* allocate a slot for a tuple with this tupdesc */
slot = TupleDescGetSlot(tupdesc);
/* check to see if caller supports us returning a tuplestore */
if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
- elog(ERROR, "crosstab: materialize mode required, but it is not "
- "allowed in this context");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("materialize mode required, but it is not " \
+ "allowed in this context")));
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
oldcontext = MemoryContextSwitchTo(per_query_ctx);
* function to complain if needed.
*/
if (tupdesc->natts < 2)
- elog(ERROR, "crosstab: query-specified return tuple and " \
- "crosstab function are not compatible");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("query-specified return tuple and " \
+ "crosstab function are not compatible")));
/* load up the categories hash table */
num_categories = load_categories_hash(cats_sql, per_query_ctx);
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "load_categories_hash: SPI_connect returned %d", ret);
/* Retrieve the category name rows */
* category - the label or identifier for each column
*/
if (spi_tupdesc->natts != 1)
- elog(ERROR, "load_categories_hash: provided categories SQL must " \
- "return 1 column of at least one row");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("provided \"categories\" SQL must " \
+ "return 1 column of at least one row")));
for (i = 0; i < proc; i++)
{
{
/* no qualifying tuples */
SPI_finish();
- elog(ERROR, "load_categories_hash: provided categories SQL must " \
- "return 1 column of at least one row");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("provided \"categories\" SQL must " \
+ "return 1 column of at least one row")));
}
if (SPI_finish() != SPI_OK_FINISH)
+ /* internal error */
elog(ERROR, "load_categories_hash: SPI_finish() failed");
return num_categories;
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "get_crosstab_tuplestore: SPI_connect returned %d", ret);
/* Now retrieve the crosstab source rows */
* time we encounter a particular rowname.
*/
if (ncols < 3)
- elog(ERROR, "get_crosstab_tuplestore: provided source SQL must " \
- "return at least 3 columns; a rowid, a category, " \
- "and a values column");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid source data SQL statement"),
+ errdetail("The provided SQL must return 3 " \
+ " columns; rowid, category, and values.")));
result_ncols = (ncols - 2) + num_categories;
/* Recheck to make sure we tuple descriptor still looks reasonable */
if (tupdesc->natts != result_ncols)
- elog(ERROR, "get_crosstab_tuplestore: query-specified return " \
- "tuple has %d columns but crosstab returns %d",
- tupdesc->natts, result_ncols);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("query-specified return " \
+ "tuple has %d columns but crosstab " \
+ "returns %d", tupdesc->natts, result_ncols)));
/* allocate space */
values = (char **) palloc(result_ncols * sizeof(char *));
}
if (SPI_finish() != SPI_OK_FINISH)
+ /* internal error */
elog(ERROR, "get_crosstab_tuplestore: SPI_finish() failed");
tuplestore_donestoring(tupstore);
/* check to see if caller supports us returning a tuplestore */
if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
- elog(ERROR, "connectby: materialize mode required, but it is not "
- "allowed in this context");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("materialize mode required, but it is not " \
+ "allowed in this context")));
if (fcinfo->nargs == 6)
{
/* check to see if caller supports us returning a tuplestore */
if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
- elog(ERROR, "connectby requires Materialize mode, but it is not "
- "allowed in this context");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("materialize mode required, but it is not " \
+ "allowed in this context")));
/* OK, go to work */
rsinfo->returnMode = SFRM_Materialize;
/* Connect to SPI manager */
if ((ret = SPI_connect()) < 0)
+ /* internal error */
elog(ERROR, "connectby: SPI_connect returned %d", ret);
/* switch to longer term context to create the tuple store */
*/
if (!compatConnectbyTupleDescs(tupdesc, spi_tupdesc))
- elog(ERROR, "connectby: return and sql tuple descriptions are "
- "incompatible");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("Return and SQL tuple descriptions are " \
+ "incompatible.")));
/* root value is the one we initially start with */
values[0] = start_with;
if (show_branch)
{
if (tupdesc->natts != CONNECTBY_NCOLS)
- elog(ERROR, "Query-specified return tuple not valid for Connectby: "
- "wrong number of columns");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("Query-specified return tuple has " \
+ "wrong number of columns.")));
}
else
{
if (tupdesc->natts != CONNECTBY_NCOLS_NOBRANCH)
- elog(ERROR, "Query-specified return tuple not valid for Connectby: "
- "wrong number of columns");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ 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)
- elog(ERROR, "Query-specified return tuple not valid for Connectby: "
- "first two columns must be the same type");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ 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)
- elog(ERROR, "Query-specified return tuple not valid for Connectby: "
- "third column must be type %s", format_type_be(INT4OID));
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ 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)
- elog(ERROR, "Query-specified return tuple not valid for Connectby: "
- "fourth column must be type %s", format_type_be(TEXTOID));
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("Fourth column must be type %s.",
+ format_type_be(TEXTOID))));
/* OK, the tupdesc is valid for our purposes */
}
ret_atttypid = ret_tupdesc->attrs[0]->atttypid;
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
if (ret_atttypid != sql_atttypid)
- elog(ERROR, "compatConnectbyTupleDescs: SQL key field datatype does "
- "not match return key field datatype");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("SQL key field datatype does " \
+ "not match return key field datatype.")));
/* check the parent_key_fld types match */
ret_atttypid = ret_tupdesc->attrs[1]->atttypid;
sql_atttypid = sql_tupdesc->attrs[1]->atttypid;
if (ret_atttypid != sql_atttypid)
- elog(ERROR, "compatConnectbyTupleDescs: SQL parent key field datatype "
- "does not match return parent key field datatype");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("SQL parent key field datatype does " \
+ "not match return parent key field datatype.")));
/* OK, the two tupdescs are compatible for our purposes */
return true;
ret_atttypid = ret_tupdesc->attrs[0]->atttypid;
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
if (ret_atttypid != sql_atttypid)
- elog(ERROR, "compatCrosstabTupleDescs: SQL rowid datatype does not match"
- " return rowid datatype");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid return type"),
+ errdetail("SQL rowid datatype does not match " \
+ "return rowid datatype.")));
/*
* - attribute [1] of the sql tuple is the category; no need to check
-- does not depend on contents of seg.sql.
--
\set ECHO none
-psql:tsearch.sql:9: NOTICE: ProcedureCreate: type txtidx is not yet defined
-psql:tsearch.sql:14: NOTICE: Argument type "txtidx" is only a shell
-psql:tsearch.sql:38: NOTICE: ProcedureCreate: type query_txt is not yet defined
-psql:tsearch.sql:43: NOTICE: Argument type "query_txt" is only a shell
-psql:tsearch.sql:55: NOTICE: ProcedureCreate: type mquery_txt is not yet defined
-psql:tsearch.sql:61: NOTICE: Argument type "mquery_txt" is only a shell
-psql:tsearch.sql:156: NOTICE: ProcedureCreate: type gtxtidx is not yet defined
-psql:tsearch.sql:161: NOTICE: Argument type "gtxtidx" is only a shell
+psql:tsearch.sql:9: NOTICE: type txtidx is not yet defined
+DETAIL: Creating a shell type definition.
+psql:tsearch.sql:14: NOTICE: argument type txtidx is only a shell
+psql:tsearch.sql:38: NOTICE: type query_txt is not yet defined
+DETAIL: Creating a shell type definition.
+psql:tsearch.sql:43: NOTICE: argument type query_txt is only a shell
+psql:tsearch.sql:55: NOTICE: type mquery_txt is not yet defined
+DETAIL: Creating a shell type definition.
+psql:tsearch.sql:61: NOTICE: argument type mquery_txt is only a shell
+psql:tsearch.sql:156: NOTICE: type gtxtidx is not yet defined
+DETAIL: Creating a shell type definition.
+psql:tsearch.sql:161: NOTICE: argument type gtxtidx is only a shell
--txtidx
SELECT '1'::txtidx;
txtidx
#include "access/gist.h"
#include "access/itup.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
Datum
gtxtidx_in(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("gtxtidx_in not implemented")));
PG_RETURN_DATUM(0);
}
Datum
gtxtidx_out(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("gtxtidx_out not implemented")));
PG_RETURN_DATUM(0);
}
#include "access/gist.h"
#include "access/itup.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
return VAL;
}
else
- elog(ERROR, "No operand");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("no operand")));
}
break;
case WAITOPERATOR:
tmp->type = type;
tmp->val = val;
if (distance > 0xffff)
- elog(ERROR, "Value is too big");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("value is too big")));
if (lenval > 0xffff)
- elog(ERROR, "Operand is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("operand is too long")));
tmp->distance = distance;
tmp->length = lenval;
tmp->next = state->str;
pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval)
{
if (lenval > 0xffff)
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
pushquery(state, type, crc32_sz((uint8 *) strval, lenval),
state->curop - state->op, lenval);
if (tokenlen > 0xffff)
{
end_parse();
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
}
lenlemm = tokenlen;
lemm = lemmatize(token, &lenlemm, type);
else
{
if (lenstack == STACKDEPTH)
- elog(ERROR, "Stack too short");
+ /* internal error */
+ elog(ERROR, "stack too short");
stack[lenstack] = val;
lenstack++;
}
break;
case ERR:
default:
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
+
return ERR;
}
{
#ifdef BS_DEBUG
elog(DEBUG4, (ptr[*pos].type == OPR) ?
- "%d %c" : "%d %d ", *pos, ptr[*pos].val);
+ "%d %c" : "%d %d", *pos, ptr[*pos].val);
#endif
if (ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE)
{
makepol(&state, pushval);
pfree(state.valstate.word);
if (!state.num)
- elog(ERROR, "Empty query");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("empty query")));
/* make finish struct */
commonlen = COMPUTESIZE(state.num, state.sumlen);
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
#include "executor/spi.h"
oldstate = WAITENDWORD;
}
else if (state->oprisdelim && ISOPERATOR(*(state->prsbuf)))
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
else if (*(state->prsbuf) != ' ')
{
*(state->curpos) = *(state->prsbuf);
else if (state->state == WAITNEXTCHAR)
{
if (*(state->prsbuf) == '\0')
- elog(ERROR, "There is no escaped character");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("there is no escaped character")));
else
{
RESIZEPRSBUF;
{
RESIZEPRSBUF;
if (state->curpos == state->word)
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
*(state->curpos) = '\0';
return 1;
}
RESIZEPRSBUF;
*(state->curpos) = '\0';
if (state->curpos == state->word)
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
state->prsbuf++;
return 1;
}
oldstate = WAITENDCMPLX;
}
else if (*(state->prsbuf) == '\0')
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
else
{
RESIZEPRSBUF;
}
}
else
- elog(ERROR, "Inner bug :(");
+ /* internal error */
+ elog(ERROR, "internal error");
state->prsbuf++;
}
cur = tmpbuf + dist;
}
if (state.curpos - state.word > 0xffff)
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
arr[len].len = state.curpos - state.word;
if (cur - tmpbuf > 0xffff)
- elog(ERROR, "Too long value");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("too long value")));
arr[len].pos = cur - tmpbuf;
memcpy((void *) cur, (void *) state.word, arr[len].len);
cur += arr[len].len;
pfree(state.word);
if (!len)
- elog(ERROR, "Void value");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("void value")));
len = uniqueentry(arr, len, tmpbuf, &buflen);
totallen = CALCDATASIZE(len, buflen);
if (tokenlen > 0xffff)
{
end_parse();
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
}
lenlemm = tokenlen;
{
ptr->len = prs->words[i].len;
if (cur - str > 0xffff)
- elog(ERROR, "Value is too big");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("value is too big")));
ptr->pos = cur - str;
ptr++;
memcpy((void *) cur, (void *) prs->words[i].word, prs->words[i].len);
Datum datum = (Datum) 0;
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "TSearch: Not fired by trigger manager");
trigdata = (TriggerData *) fcinfo->context;
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "TSearch: Can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "TSearch: Must be fired BEFORE event");
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
rettuple = trigdata->tg_newtuple;
else
+ /* internal error */
elog(ERROR, "TSearch: Unknown event");
trigger = trigdata->tg_trigger;
rel = trigdata->tg_relation;
if (trigger->tgnargs < 2)
+ /* internal error */
elog(ERROR, "TSearch: format tsearch(txtidx_field, text_field1,...)");
numidxattr = SPI_fnumber(rel->rd_att, trigger->tgargs[0]);
if (numidxattr == SPI_ERROR_NOATTRIBUTE)
- elog(ERROR, "TSearch: Can not find txtidx_field");
-
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("could not find txtidx_field")));
prs.lenwords = 32;
prs.curwords = 0;
prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
}
if (rettuple == NULL)
+ /* internal error */
elog(ERROR, "TSearch: %d returned by SPI_modifytuple", SPI_result);
return PointerGetDatum(rettuple);
}
va_end(args);
- elog(state,buf);
+ /* ?? internal error ?? */
+ elog(state, "%s", buf);
pfree(buf);
}
lexize_bycurrent(PG_FUNCTION_ARGS) {
Datum res;
if ( currect_dictionary_id == 0 )
- elog(ERROR, "No currect dictionary. Execute select set_curdict().");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("no currect dictionary"),
+ errhint("Execute select set_curdict().")));
res = DirectFunctionCall3(
lexize,
DictExample *d = (DictExample*)malloc( sizeof(DictExample) );
if ( !d )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
memset(d,0,sizeof(DictExample));
d->stoplist.wordop=lowerstr;
bool affloaded=false, dictloaded=false, stoploaded=false;
if ( PG_ARGISNULL(0) || PG_GETARG_POINTER(0)==NULL )
- elog(ERROR,"ISpell confguration error");
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("ISpell confguration error")));
d = (DictISpell*)malloc( sizeof(DictISpell) );
if ( !d )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
memset(d,0,sizeof(DictISpell));
d->stoplist.wordop=lowerstr;
if ( strcasecmp("DictFile", pcfg->key) == 0 ) {
if ( dictloaded ) {
freeDictISpell(d);
- elog(ERROR,"Dictionary already loaded");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("dictionary already loaded")));
}
if ( ImportDictionary(&(d->obj), pcfg->value) ) {
freeDictISpell(d);
- elog(ERROR,"Can't load dictionary file (%s)", pcfg->value);
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("could not load dictionary file \"%s\"",
+ pcfg->value)));
}
dictloaded=true;
} else if ( strcasecmp("AffFile", pcfg->key) == 0 ) {
if ( affloaded ) {
freeDictISpell(d);
- elog(ERROR,"Affixes already loaded");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("affixes already loaded")));
}
if ( ImportAffixes(&(d->obj), pcfg->value) ) {
freeDictISpell(d);
- elog(ERROR,"Can't load affix file (%s)", pcfg->value);
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("could not load affix file \"%s\"",
+ pcfg->value)));
}
affloaded=true;
} else if ( strcasecmp("StopFile", pcfg->key) == 0 ) {
text *tmp=char2text(pcfg->value);
if ( stoploaded ) {
freeDictISpell(d);
- elog(ERROR,"Stop words already loaded");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("stop words already loaded")));
}
readstoplist(tmp, &(d->stoplist));
sortstoplist(&(d->stoplist));
stoploaded=true;
} else {
freeDictISpell(d);
- elog(ERROR,"Unknown option: %s => %s", pcfg->key, pcfg->value);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("unrecognized option: %s => %s",
+ pcfg->key, pcfg->value)));
}
pfree(pcfg->key);
pfree(pcfg->value);
SortAffixes(&(d->obj));
} else if ( !affloaded ) {
freeDictISpell(d);
- elog(ERROR,"No affixes");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("no affixes")));
} else {
freeDictISpell(d);
- elog(ERROR,"No dictionary");
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("no dictionary")));
}
PG_RETURN_POINTER(d);
DictSnowball *d = (DictSnowball*)malloc( sizeof(DictSnowball) );
if ( !d )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
memset(d,0,sizeof(DictSnowball));
d->stoplist.wordop=lowerstr;
d->z = english_create_env();
if (!d->z) {
freestoplist(&(d->stoplist));
- elog(ERROR,"No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
d->stem=english_stem;
DictSnowball *d = (DictSnowball*)malloc( sizeof(DictSnowball) );
if ( !d )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
memset(d,0,sizeof(DictSnowball));
d->stoplist.wordop=lowerstr;
d->z = russian_create_env();
if (!d->z) {
freestoplist(&(d->stoplist));
- elog(ERROR,"No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
d->stem=russian_stem;
int slen;
if ( PG_ARGISNULL(0) || PG_GETARG_POINTER(0)==NULL )
- elog(ERROR,"NULL config");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("NULL config")));
in = PG_GETARG_TEXT_P(0);
if ( VARSIZE(in) - VARHDRSZ == 0 )
- elog(ERROR,"VOID config");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("VOID config")));
filename=text2char(in);
PG_FREE_IF_COPY(in, 0);
if ( (fin=fopen(filename,"r")) == NULL )
- elog(ERROR,"Can't open file '%s': %s", filename, strerror(errno));
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not open file \"%s\": %m",
+ filename)));
d = (DictSyn*)malloc( sizeof(DictSyn) );
if ( !d ) {
fclose(fin);
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
memset(d,0,sizeof(DictSyn));
d->syn=(Syn*)realloc( d->syn, sizeof(Syn)*d->len );
if ( !d->syn ) {
fclose(fin);
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
}
d->syn[cur].out=strdup(lowerstr(starto));
if ( !(d->syn[cur].in && d->syn[cur].out) ) {
fclose(fin);
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
cur++;
DictSnowball *d = (DictSnowball*)malloc( sizeof(DictSnowball) );
if ( !d )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
memset(d,0,sizeof(DictSnowball));
d->stoplist.wordop=lowerstr;
d->z = CFG_PREFIX_create_env();
if (!d->z) {
freestoplist(&(d->stoplist));
- elog(ERROR,"No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
d->stem=CFG_PREFIX_stem;
HASINIT DictExample *d = (DictExample*)malloc( sizeof(DictExample) );
HASINIT
HASINIT if ( !d )
-HASINIT elog(ERROR, "No memory");
+HASINIT ereport(ERROR,
+HASINIT (errcode(ERRCODE_OUT_OF_MEMORY),
+HASINIT errmsg("out of memory")));
HASINIT memset(d,0,sizeof(DictExample));
HASINIT
HASINIT d->stoplist.wordop=lowerstr;
#include "access/gist.h"
#include "access/itup.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
Datum
gtsvector_in(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("gtsvector_in not implemented")));
PG_RETURN_DATUM(0);
}
Datum
gtsvector_out(PG_FUNCTION_ARGS)
{
- elog(ERROR, "Not implemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("gtsvector_out not implemented")));
PG_RETURN_DATUM(0);
}
Conf->Spell=(SPELL *)malloc(Conf->mspell*sizeof(SPELL));
}
if ( Conf->Spell == NULL )
- elog(ERROR,"No memory for AddSpell");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
Conf->Spell[Conf->nspell].word=strdup(word);
if ( !Conf->Spell[Conf->nspell].word )
- elog(ERROR,"No memory for AddSpell");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
strncpy(Conf->Spell[Conf->nspell].flag,flag,10);
Conf->nspell++;
return(0);
Conf->Affix = (AFFIX*)malloc(Conf->maffixes * sizeof(AFFIX));
}
if ( Conf->Affix == NULL )
- elog(ERROR,"No memory for AddAffix");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
if (type=='s') {
sprintf(Conf->Affix[Conf->naffixes].mask,"%s$",mask);
begin=ptr;
state=CS_INKEY;
} else if ( !isspace(*ptr) )
- elog(ERROR,"Syntax error in position %d near '%c'", ptr-VARDATA(in), *ptr);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Syntax error in position %d near \"%c\"",
+ ptr-VARDATA(in), *ptr)));
} else if (state==CS_INKEY) {
if ( isspace(*ptr) ) {
mptr->key=nstrdup(begin, ptr-begin);
mptr->key=nstrdup(begin, ptr-begin);
state=CS_WAITVALUE;
} else if ( !isalpha(*ptr) )
- elog(ERROR,"Syntax error in position %d near '%c'", ptr-VARDATA(in), *ptr);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Syntax error in position %d near \"%c\"",
+ ptr-VARDATA(in), *ptr)));
} else if ( state==CS_WAITEQ ) {
if ( *ptr=='=' )
state=CS_WAITVALUE;
else if ( !isspace(*ptr) )
- elog(ERROR,"Syntax error in position %d near '%c'", ptr-VARDATA(in), *ptr);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Syntax error in position %d near \"%c\"",
+ ptr-VARDATA(in), *ptr)));
} else if ( state==CS_WAITVALUE ) {
if ( *ptr=='"' ) {
begin=ptr+1;
if ( *ptr==',' )
state=CS_WAITKEY;
else if ( !isspace(*ptr) )
- elog(ERROR,"Syntax error in position %d near '%c'", ptr-VARDATA(in), *ptr);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error"),
+ errdetail("Syntax error in position %d near \"%c\"",
+ ptr-VARDATA(in), *ptr)));
} else if ( state == CS_INESC ) {
state=CS_INVALUE;
} else if ( state == CS_IN2ESC ) {
state=CS_IN2VALUE;
} else
- elog(ERROR,"Bad parser state: %d at position %d near '%c'", state, ptr-VARDATA(in), *ptr);
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("bad parser state"),
+ errdetail("%d at position %d near \"%c\"",
+ state, ptr-VARDATA(in), *ptr)));
ptr++;
}
mptr->value = nstrdup(begin, ptr-begin);
mptr++;
} else if ( !(state==CS_WAITDELIM || state==CS_WAITKEY) )
- elog(ERROR,"Unexpected end of line");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("unexpected end of line")));
}
#include "access/gist.h"
#include "access/itup.h"
#include "access/rtree.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
(state->buf)++;
return OPEN;
} else if ( *(state->buf) == ':' ) {
- elog(ERROR,"Error at start of operand");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("error at start of operand")));
} else if (*(state->buf) != ' ') {
state->valstate.prsbuf = state->buf;
state->state = WAITOPERATOR;
return VAL;
}
else
- elog(ERROR, "No operand");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("no operand")));
}
break;
case WAITOPERATOR:
tmp->type = type;
tmp->val = val;
if (distance >= MAXSTRPOS)
- elog(ERROR, "Value is too big");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("value is too big")));
if (lenval >= MAXSTRLEN)
- elog(ERROR, "Operand is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("operand is too long")));
tmp->distance = distance;
tmp->length = lenval;
tmp->next = state->str;
pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, int2 weight)
{
if (lenval >= MAXSTRLEN)
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
pushquery(state, type, crc32_sz((uint8 *) strval, lenval),
state->curop - state->op, lenval, weight);
else
{
if (lenstack == STACKDEPTH)
- elog(ERROR, "Stack too short");
+ /* internal error */
+ elog(ERROR, "stack too short");
stack[lenstack] = val;
lenstack++;
}
break;
case ERR:
default:
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
return ERR;
}
{
#ifdef BS_DEBUG
elog(DEBUG3, (ptr[*pos].type == OPR) ?
- "%d %c" : "%d %d ", *pos, ptr[*pos].val);
+ "%d %c" : "%d %d", *pos, ptr[*pos].val);
#endif
if (ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE)
{
makepol(&state, pushval);
pfree(state.valstate.word);
if (!state.num)
- elog(ERROR, "Empty query");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("empty query")));
/* make finish struct */
commonlen = COMPUTESIZE(state.num, state.sumlen);
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "fmgr.h"
#include "funcapi.h"
case 1: res /= log((float)cnt_length(t)); break;
case 2: res /= (float)cnt_length(t); break;
default:
- elog(ERROR,"Unknown normalization method: %d",method);
+ /* internal error */
+ elog(ERROR,"unrecognized normalization method: %d", method);
}
return res;
int i;
if ( ARR_NDIM(win) != 1 )
- elog(ERROR,"Array of weight is not one dimentional");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array of weight must be one-dimensional")));
+
if ( ARRNELEMS(win) < lengthof(weights) )
- elog(ERROR,"Array of weight is too short");
+ ereport(ERROR,
+ (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
+ errmsg("array of weight is too short")));
for(i=0;i<lengthof(weights);i++) {
ws[ i ] = ( ((float4*)ARR_DATA_PTR(win))[i] >= 0 ) ? ((float4*)ARR_DATA_PTR(win))[i] : weights[i];
if ( ws[ i ] > 1.0 )
- elog(ERROR,"Weight out of range");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("weight out of range")));
}
if ( PG_NARGS() == 4 )
case 1: res /= log((float)cnt_length(txt)); break;
case 2: res /= (float)cnt_length(txt); break;
default:
- elog(ERROR,"Unknown normalization method: %d",method);
+ /* internal error */
+ elog(ERROR,"unrecognized normalization method: %d", method);
}
pfree(doc);
for(i=0;i<txt->size;i++) {
if (!pptr[i].haspos)
- elog(ERROR,"No pos info");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("no pos info")));
dlen += POSDATALEN(txt,&(pptr[i]));
}
int len = (map->reallen) ? 2*map->reallen : 16;
tmp=(SNMapEntry*)realloc(map->list, sizeof(SNMapEntry) * len);
if ( !tmp )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
map->reallen=len;
map->list=tmp;
}
map->list[ map->len ].key = strdup(key);
if ( ! map->list[ map->len ].key )
- elog(ERROR, "No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
map->list[ map->len ].value=value;
map->len++;
if ( map->len>1 ) qsort(map->list, map->len, sizeof(SNMapEntry), compareSNMapEntry);
int reallen=0;
if ( (hin=fopen(filename,"r")) == NULL )
- elog(ERROR,"Can't open file '%s': %s", filename, strerror(errno));
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("could not open file \"%s\": %m",
+ filename)));
+
while( fgets(buf,STOPBUFLEN,hin) ) {
buf[strlen(buf)-1] = '\0';
if ( *buf=='\0' ) continue;
if (!tmp) {
freestoplist(s);
fclose(hin);
- elog(ERROR,"Not enough memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
stop=tmp;
}
if ( !stop[s->len] ) {
freestoplist(s);
fclose(hin);
- elog(ERROR,"Not enough memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
}
if ( s->wordop )
stop[s->len]=(s->wordop)(stop[s->len]);
cfg->len=lexid+1;
cfg->map = (ListDictionary*)malloc( sizeof(ListDictionary)*cfg->len );
if ( !cfg->map )
- ts_error(ERROR,"No memory");
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
memset( cfg->map, 0, sizeof(ListDictionary)*cfg->len );
}
if ( !plan_name2id ) {
plan_name2id = SPI_saveplan( SPI_prepare( "select oid from pg_ts_cfg where ts_name = $1" , 1, arg ) );
if ( !plan_name2id )
+ /* internal error */
elog(ERROR, "SPI_prepare() failed");
}
stat = SPI_execp(plan_name2id, pars, " ", 1);
if ( stat < 0 )
+ /* internal error */
elog (ERROR, "SPI_execp return %d", stat);
if ( SPI_processed > 0 ) {
id=DatumGetObjectId( SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull) );
if ( isnull )
- elog(ERROR, "Null id for tsearch config");
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("null id for tsearch config")));
} else
- elog(ERROR, "No tsearch config");
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("no tsearch config")));
+
SPI_finish();
addSNMap_t( &(CList.name2id_map), name, id );
return id;
PointerGetDatum(&lenlemm))) ) != 0 ) {
if ( lenlemm >= MAXSTRLEN )
- elog(ERROR, "Word is too long");
-
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
if ( type >= cfg->len ) /* skip this type of lexem */
continue;
PointerGetDatum(&lenlemm))) ) != 0 ) {
if ( lenlemm >= MAXSTRLEN )
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
hladdword(prs,lemm,lenlemm,type);
if ( !plan_getcfg_bylocale ) {
plan_getcfg_bylocale=SPI_saveplan( SPI_prepare( "select oid from pg_ts_cfg where locale = $1 ", 1, arg ) );
if ( !plan_getcfg_bylocale )
+ /* internal error */
elog(ERROR, "SPI_prepare() failed");
}
stat = SPI_execp(plan_getcfg_bylocale, pars, " ", 1);
if ( stat < 0 )
+ /* internal error */
elog (ERROR, "SPI_execp return %d", stat);
if ( SPI_processed > 0 )
current_cfg_id = DatumGetObjectId( SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull) );
else
- elog(ERROR,"Can't find tsearch config by locale");
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("could not find tsearch config by locale")));
pfree(DatumGetPointer(pars[0]));
SPI_finish();
Datum tsstat_out(PG_FUNCTION_ARGS);
Datum
tsstat_out(PG_FUNCTION_ARGS) {
- elog(ERROR,"Unimplemented");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("tsstat_out not implemented")));
PG_RETURN_NULL();
}
int ret;
bool isnull;
- if ( (ret = SPI_exec("select oid from pg_type where typname='tsvector'",1)) < 0 )
+ if ( (ret = SPI_exec("select oid from pg_type where typname='tsvector'",1)) < 0 )
+ /* internal error */
elog(ERROR, "SPI_exec to get tsvector oid returns %d", ret);
if ( SPI_processed<0 )
+ /* internal error */
elog(ERROR, "There is no tsvector type");
tiOid = DatumGetObjectId( SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull) );
if ( tiOid==InvalidOid )
+ /* internal error */
elog(ERROR, "tsvector type has InvalidOid");
}
get_ti_Oid();
if ( (plan = SPI_prepare(query,0,NULL))==NULL )
+ /* internal error */
elog(ERROR, "SPI_prepare('%s') returns NULL",query);
if ( (portal = SPI_cursor_open(NULL, plan, NULL, NULL)) == NULL )
+ /* internal error */
elog(ERROR, "SPI_cursor_open('%s') returns NULL",query);
SPI_cursor_fetch(portal, true, 100);
if ( SPI_tuptable->tupdesc->natts != 1 )
- elog(ERROR, "Number of fields doesn't equal to 1");
+ /* internal error */
+ elog(ERROR, "number of fields doesn't equal to 1");
if ( SPI_gettypeid(SPI_tuptable->tupdesc, 1) != tiOid )
- elog(ERROR, "Column isn't of tsvector type");
+ /* internal error */
+ elog(ERROR, "column isn't of tsvector type");
stat=palloc(STATHDRSIZE);
stat->len=STATHDRSIZE;
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
#include "executor/spi.h"
oldstate = WAITENDWORD;
}
else if (state->oprisdelim && ISOPERATOR(*(state->prsbuf)))
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
else if (*(state->prsbuf) != ' ')
{
*(state->curpos) = *(state->prsbuf);
else if (state->state == WAITNEXTCHAR)
{
if (*(state->prsbuf) == '\0')
- elog(ERROR, "There is no escaped character");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("there is no escaped character")));
else
{
RESIZEPRSBUF;
{
RESIZEPRSBUF;
if (state->curpos == state->word)
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
*(state->curpos) = '\0';
return 1;
} else if ( *(state->prsbuf) == ':' ) {
if (state->curpos == state->word)
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
*(state->curpos) = '\0';
if ( state->oprisdelim )
return 1;
RESIZEPRSBUF;
*(state->curpos) = '\0';
if (state->curpos == state->word)
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
if ( state->oprisdelim ) {
state->prsbuf++;
return 1;
oldstate = WAITENDCMPLX;
}
else if (*(state->prsbuf) == '\0')
- elog(ERROR, "Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
else
{
RESIZEPRSBUF;
( *(uint16*)(state->pos) )++;
state->pos[ *(uint16*)(state->pos) ].pos = LIMITPOS(atoi(state->prsbuf));
if ( state->pos[ *(uint16*)(state->pos) ].pos == 0 )
- elog(ERROR,"Wrong position info");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("wrong position info")));
state->pos[ *(uint16*)(state->pos) ].weight = 0;
state->state = WAITPOSDELIM;
} else
- elog(ERROR,"Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
} else if (state->state == WAITPOSDELIM) {
if ( *(state->prsbuf) == ',' ) {
state->state = INPOSINFO;
} else if ( tolower(*(state->prsbuf)) == 'a' || *(state->prsbuf)=='*' ) {
if ( state->pos[ *(uint16*)(state->pos) ].weight )
- elog(ERROR,"Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
state->pos[ *(uint16*)(state->pos) ].weight = 3;
} else if ( tolower(*(state->prsbuf)) == 'b' ) {
if ( state->pos[ *(uint16*)(state->pos) ].weight )
- elog(ERROR,"Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
state->pos[ *(uint16*)(state->pos) ].weight = 2;
} else if ( tolower(*(state->prsbuf)) == 'c' ) {
if ( state->pos[ *(uint16*)(state->pos) ].weight )
- elog(ERROR,"Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
state->pos[ *(uint16*)(state->pos) ].weight = 1;
} else if ( tolower(*(state->prsbuf)) == 'd' ) {
if ( state->pos[ *(uint16*)(state->pos) ].weight )
- elog(ERROR,"Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
state->pos[ *(uint16*)(state->pos) ].weight = 0;
} else if ( isspace(*(state->prsbuf)) || *(state->prsbuf) == '\0' ) {
return 1;
} else if ( !isdigit(*(state->prsbuf)) )
- elog(ERROR,"Syntax error");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error")));
} else
- elog(ERROR, "Inner bug :(");
+ /* internal error */
+ elog(ERROR, "internal error");
state->prsbuf++;
}
cur = tmpbuf + dist;
}
if (state.curpos - state.word >= MAXSTRLEN)
- elog(ERROR, "Word is too long");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("word is too long")));
arr[len].entry.len= state.curpos - state.word;
if (cur - tmpbuf > MAXSTRPOS)
- elog(ERROR, "Too long value");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("too long value")));
arr[len].entry.pos=cur - tmpbuf;
memcpy((void *) cur, (void *) state.word, arr[len].entry.len);
cur += arr[len].entry.len;
{
ptr->len = prs->words[i].len;
if (cur - str > MAXSTRPOS)
- elog(ERROR, "Value is too big");
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("value is too big")));
ptr->pos= cur - str;
memcpy((void *) cur, (void *) prs->words[i].word, prs->words[i].len);
pfree(prs->words[i].word);
Oid funcoid = InvalidOid;
if (!CALLED_AS_TRIGGER(fcinfo))
+ /* internal error */
elog(ERROR, "TSearch: Not fired by trigger manager");
trigdata = (TriggerData *) fcinfo->context;
if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "TSearch: Can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
+ /* internal error */
elog(ERROR, "TSearch: Must be fired BEFORE event");
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
rettuple = trigdata->tg_newtuple;
else
+ /* internal error */
elog(ERROR, "TSearch: Unknown event");
trigger = trigdata->tg_trigger;
rel = trigdata->tg_relation;
if (trigger->tgnargs < 2)
+ /* internal error */
elog(ERROR, "TSearch: format tsearch2(tsvector_field, text_field1,...)");
numidxattr = SPI_fnumber(rel->rd_att, trigger->tgargs[0]);
if (numidxattr == SPI_ERROR_NOATTRIBUTE)
- elog(ERROR, "TSearch: Can not find tsvector_field");
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("cannot find tsvector_field")));
prs.lenwords = 32;
prs.curwords = 0;
{
funcoid=findFunc(trigger->tgargs[i]);
if ( funcoid==InvalidOid )
- elog(ERROR,"TSearch: can't find function or field '%s'",trigger->tgargs[i]);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("cannot find function or field \"%s\"",
+ trigger->tgargs[i])));
+
continue;
}
oidtype = SPI_gettypeid(rel->rd_att, numattr);
}
if (rettuple == NULL)
+ /* internal error */
elog(ERROR, "TSearch: %d returned by SPI_modifytuple", SPI_result);
return PointerGetDatum(rettuple);
#include "access/gist.h"
#include "access/itup.h"
-#include "utils/elog.h"
-#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
#include "executor/spi.h"
case 'b': w=2; break;
case 'c': w=1; break;
case 'd': w=0; break;
- default: elog(ERROR,"Unknown weight");
+ /* internal error */
+ default: elog(ERROR,"unrecognized weight");
}
out=(tsvector*)palloc(in->len);
pfree(map);
if ( min_words >= max_words )
- elog(ERROR,"Must be MinWords < MaxWords");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("must be MinWords < MaxWords")));
if ( min_words<=0 )
- elog(ERROR,"Must be MinWords > 0");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("must be MinWords > 0")));
if ( shortword<0 )
- elog(ERROR,"Must be ShortWord >= 0");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("must be ShortWord >= 0")));
}
while( hlCover(prs,query,&p,&q) ) {
p = XML_ParserCreate_MM(NULL, &mhs, NULL);
if (!p)
{
- elog(ERROR, "pgxml: Could not create expat parser");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("could not create expat parser")));
PG_RETURN_NULL(); /* seems appropriate if we couldn't parse */
}
p = XML_ParserCreate_MM(NULL, &mhs, NULL);
if (!p)
{
- elog(ERROR, "pgxml: Could not create expat parser");
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("could not create expat parser")));
pfree(xpr);
pfree(udata->path);
pfree(udata);
char sepstr[] = "/";
if ((strlen(name) + strlen(UD->currentpath)) > MAXPATHLENGTH - 2)
- elog(WARNING, "Path too long");
+ elog(WARNING, "path too long");
else
{
strncat(UD->currentpath, sepstr, 1);
sepptr = strrchr(UD->currentpath, '/');
if (sepptr == NULL)
{
- elog(ERROR, "There's a problem...");
+ /* internal error */
+ elog(ERROR, "did not find '/'");
sepptr = UD->currentpath;
}
if (strcmp(name, sepptr + 1) != 0)
{
- elog(WARNING, "Wanted [%s], got [%s]", sepptr, name);
+ elog(WARNING, "wanted [%s], got [%s]", sepptr, name);
/* unmatched entry, so do nothing */
}
else
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: elog.h,v 1.55 2003/07/22 22:14:57 tgl Exp $
+ * $Id: elog.h,v 1.56 2003/07/24 17:52:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#define ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN MAKE_SQLSTATE('0','8', '0','0','7')
#define ERRCODE_PROTOCOL_VIOLATION MAKE_SQLSTATE('0','8', 'P','0','1')
+/* Class 09 - Triggered Action Exception */
+#define ERRCODE_TRIGGERED_ACTION_EXCEPTION MAKE_SQLSTATE('0','9', '0','0','0')
+
/* Class 0A - Feature Not Supported */
#define ERRCODE_FEATURE_NOT_SUPPORTED MAKE_SQLSTATE('0','A', '0','0','0')
insert into fkeys2 values (50, '5', 3);
-- no key in pkeys
insert into fkeys2 values (70, '5', 3);
-ERROR: check_fkeys2_pkey_exist: tuple references non-existing key in pkeys
+ERROR: tuple references non-existent key
+DETAIL: Trigger "check_fkeys2_pkey_exist" found tuple referencing non-existent key in "pkeys".
insert into fkeys values (10, '1', 2);
insert into fkeys values (30, '3', 3);
insert into fkeys values (40, '4', 2);
insert into fkeys values (50, '5', 2);
-- no key in pkeys
insert into fkeys values (70, '5', 1);
-ERROR: check_fkeys_pkey_exist: tuple references non-existing key in pkeys
+ERROR: tuple references non-existent key
+DETAIL: Trigger "check_fkeys_pkey_exist" found tuple referencing non-existent key in "pkeys".
-- no key in fkeys2
insert into fkeys values (60, '6', 4);
-ERROR: check_fkeys_pkey2_exist: tuple references non-existing key in fkeys2
+ERROR: tuple references non-existent key
+DETAIL: Trigger "check_fkeys_pkey2_exist" found tuple referencing non-existent key in "fkeys2".
delete from pkeys where pkey1 = 30 and pkey2 = '3';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
-ERROR: check_fkeys2_fkey_restrict: tuple referenced in fkeys
+ERROR: "check_fkeys2_fkey_restrict": tuple is referenced in "fkeys"
delete from pkeys where pkey1 = 40 and pkey2 = '4';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys2 are deleted
update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 50 and pkey2 = '5';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
-ERROR: check_fkeys2_fkey_restrict: tuple referenced in fkeys
+ERROR: "check_fkeys2_fkey_restrict": tuple is referenced in "fkeys"
update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 10 and pkey2 = '1';
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys are deleted
NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys2 are deleted