From: Christian Kruse Date: Tue, 13 May 2014 08:40:49 +0000 (+0200) Subject: bdr: adding errcodes to a lot of ereports X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=65b424648c6039aff16fd335d3aa2b0968041f52;p=users%2Fandresfreund%2Fpostgres.git bdr: adding errcodes to a lot of ereports --- diff --git a/contrib/bdr/bdr.c b/contrib/bdr/bdr.c index 396062d654..7de5c5cc0f 100644 --- a/contrib/bdr/bdr.c +++ b/contrib/bdr/bdr.c @@ -169,7 +169,8 @@ bdr_send_feedback(PGconn *conn, XLogRecPtr blockpos, int64 now, bool replyReques if (PQputCopyData(conn, replybuf, len) <= 0 || PQflush(conn)) { ereport(ERROR, - (errmsg("could not send feedback packet: %s", + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("could not send feedback packet: %s", PQerrorMessage(conn)))); return false; } @@ -242,7 +243,8 @@ bdr_connect(char *conninfo_repl, if (PQstatus(streamConn) != CONNECTION_OK) { ereport(FATAL, - (errmsg("could not connect to the primary server: %s", + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("could not connect to the primary server: %s", PQerrorMessage(streamConn)))); } @@ -280,7 +282,8 @@ bdr_connect(char *conninfo_repl, if (strcmp(remote_sysid, local_sysid) == 0) { ereport(FATAL, - (errmsg("system identifiers must differ between the nodes"), + (errcode(ERRCODE_INVALID_NAME), + errmsg("system identifiers must differ between the nodes"), errdetail("Both system identifiers are %s.", remote_sysid))); } else @@ -829,7 +832,8 @@ bdr_create_con_gucs(char *name, PQfreemem(errormsg); ereport(ERROR, - (errmsg("bdr %s: error in dsn: %s", name, str))); + (errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("bdr %s: error in dsn: %s", name, str))); } cur_option = options; @@ -838,7 +842,9 @@ bdr_create_con_gucs(char *name, if (strcmp(cur_option->keyword, "dbname") == 0) { if (cur_option->val == NULL) - ereport(ERROR, (errmsg("bdr %s: no dbname set", name))); + ereport(ERROR, + (errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("bdr %s: no dbname set", name))); strncpy(NameStr(opts->dbname), cur_option->val, NAMEDATALEN); @@ -885,7 +891,8 @@ bdr_create_con_gucs(char *name, elog(DEBUG2, "bdr %s: has init_replica=t", name); if (database_initcons[off] != NULL) ereport(ERROR, - (errmsg("Connections %s and %s on database %s both have bdr_init_replica enabled, cannot continue", + (errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("Connections %s and %s on database %s both have bdr_init_replica enabled, cannot continue", name, database_initcons[off], used_databases[off]))); else database_initcons[off] = name; /* no need to pstrdup, see _PG_init */ @@ -1375,7 +1382,8 @@ _PG_init(void) if (!process_shared_preload_libraries_in_progress) ereport(ERROR, - (errmsg("bdr can only be loaded via shared_preload_libraries"))); + (errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("bdr can only be loaded via shared_preload_libraries"))); if (!commit_ts_enabled) ereport(ERROR, diff --git a/contrib/bdr/bdr_count.c b/contrib/bdr/bdr_count.c index 94a9a4ca14..1ad1ce09d3 100644 --- a/contrib/bdr/bdr_count.c +++ b/contrib/bdr/bdr_count.c @@ -301,7 +301,8 @@ pg_stat_get_bdr(PG_FUNCTION_ARGS) if (!superuser()) ereport(ERROR, - (errmsg("Access to pg_stat_get_bdr() denied as non-superuser"))); + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("Access to pg_stat_get_bdr() denied as non-superuser"))); if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo)) ereport(ERROR, diff --git a/contrib/bdr/bdr_executor.c b/contrib/bdr/bdr_executor.c index cce81bac04..af15f5ba76 100644 --- a/contrib/bdr/bdr_executor.c +++ b/contrib/bdr/bdr_executor.c @@ -86,7 +86,8 @@ UserTableUpdateOpenIndexes(EState *estate, TupleTableSlot *slot) if (recheckIndexes != NIL) ereport(ERROR, - (errmsg("bdr doesn't support index rechecks"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("bdr doesn't support index rechecks"))); } /* FIXME: recheck the indexes */ diff --git a/contrib/bdr/bdr_init_replica.c b/contrib/bdr/bdr_init_replica.c index 582d8b7c2b..9ac4c6ab9d 100644 --- a/contrib/bdr/bdr_init_replica.c +++ b/contrib/bdr/bdr_init_replica.c @@ -355,7 +355,8 @@ bdr_ensure_ext_installed(PGconn *pgconn, Name bdr_conn_name) if (PQgetisnull(res, 0, 1)) { ereport(ERROR, - (errmsg("Remote database for BDR connection %s does not have the bdr extension active", + (errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("Remote database for BDR connection %s does not have the bdr extension active", NameStr(*bdr_conn_name)), errdetail("no entry with name 'bdr' in pg_extensions"), errhint("add 'bdr' to shared_preload_libraries in postgresql.conf " @@ -366,7 +367,8 @@ bdr_ensure_ext_installed(PGconn *pgconn, Name bdr_conn_name) { /* bdr ext is not known to Pg at all */ ereport(ERROR, - (errmsg("Remote PostgreSQL install for bdr connection %s does not have bdr extension installed", + (errcode(ERRCODE_CONFIG_FILE_ERROR), + errmsg("Remote PostgreSQL install for bdr connection %s does not have bdr extension installed", NameStr(*bdr_conn_name)), errdetail("no entry with name 'bdr' in pg_available_extensions; did you install BDR?"))); } @@ -1009,7 +1011,8 @@ bdr_catchup_to_lsn(int cfg_index, { LWLockRelease(BdrWorkerCtl->lock); ereport(ERROR, - (errmsg("No free bdr worker slots, bdr_max_workers=%d too low", + (errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED), + errmsg("No free bdr worker slots, bdr_max_workers=%d too low", bdr_max_workers))); } BdrWorkerCtl->slots[worker_shmem_idx].worker_type = BDR_WORKER_APPLY;