summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/ecpglib/error.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2008-05-16 15:20:04 +0000
committerPeter Eisentraut <peter_e@gmx.net>2008-05-16 15:20:04 +0000
commite1bdd07c3c33d4004180506f1493efcbbbc02b4c (patch)
tree4b277572297bc7280a8e073e2e0931413e25d0fd /src/interfaces/ecpg/ecpglib/error.c
parent4eb0900768a3eb880ab5cb267fa27b46de559433 (diff)
downloadpostgresql-e1bdd07c3c33d4004180506f1493efcbbbc02b4c.tar.gz
Add localization support to ecpg.
Author: Euler Taveira de Oliveira <euler@timbira.com>
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/error.c')
-rw-r--r--src/interfaces/ecpg/ecpglib/error.c119
1 files changed, 84 insertions, 35 deletions
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c
index cce370aca6..a36f374e7d 100644
--- a/src/interfaces/ecpg/ecpglib/error.c
+++ b/src/interfaces/ecpg/ecpglib/error.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.19 2007/11/15 21:14:45 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.20 2008/05/16 15:20:03 petere Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -21,132 +21,182 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
{
case ECPG_NOT_FOUND:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "No data found in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("no data found on line %d"), line);
break;
case ECPG_OUT_OF_MEMORY:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Out of memory in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("out of memory on line %d"), line);
break;
case ECPG_UNSUPPORTED:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Unsupported type %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("unsupported type %s on line %d"), str, line);
break;
case ECPG_TOO_MANY_ARGUMENTS:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Too many arguments in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("too many arguments on line %d"), line);
break;
case ECPG_TOO_FEW_ARGUMENTS:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Too few arguments in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("too few arguments on line %d"), line);
break;
case ECPG_INT_FORMAT:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Not correctly formatted int type: %s line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("not correctly formatted int type \"%s\" on line %d"), str, line);
break;
case ECPG_UINT_FORMAT:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Not correctly formatted unsigned type: %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("not correctly formatted unsigned type \"%s\" on line %d"), str, line);
break;
case ECPG_FLOAT_FORMAT:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Not correctly formatted floating-point type: %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("not correctly formatted floating-point type \"%s\" on line %d"), str, line);
break;
case ECPG_CONVERT_BOOL:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Could not convert %s to bool on line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("could not convert %s to bool on line %d"), str, line);
break;
case ECPG_EMPTY:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Empty query in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("empty query on line %d"), line);
break;
case ECPG_MISSING_INDICATOR:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "NULL value without indicator in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("NULL value without indicator on line %d"), line);
break;
case ECPG_NO_ARRAY:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Variable is not an array in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("variable is not an array on line %d"), line);
break;
case ECPG_DATA_NOT_ARRAY:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Data read from backend is not an array in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("data read from backend is not an array on line %d"), line);
break;
case ECPG_ARRAY_INSERT:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Trying to insert an array of variables in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("trying to insert an array of variables on line %d"), line);
break;
case ECPG_NO_CONN:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "No such connection %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("no such connection %s on line %d"), str, line);
break;
case ECPG_NOT_CONN:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Not connected to '%s' in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("not connected to \"%s\" on line %d"), str, line);
break;
case ECPG_INVALID_STMT:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Invalid statement name %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("invalid statement name %s on line %d"), str, line);
break;
case ECPG_UNKNOWN_DESCRIPTOR:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Descriptor %s not found in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("descriptor %s not found on line %d"), str, line);
break;
case ECPG_INVALID_DESCRIPTOR_INDEX:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Descriptor index out of range in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("descriptor index out of range on line %d"), line);
break;
case ECPG_UNKNOWN_DESCRIPTOR_ITEM:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Unknown descriptor item %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("unknown descriptor item %s on line %d"), str, line);
break;
case ECPG_VAR_NOT_NUMERIC:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Variable is not a numeric type in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("variable is not a numeric type on line %d"), line);
break;
case ECPG_VAR_NOT_CHAR:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Variable is not a character type in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("variable is not a character type on line %d"), line);
break;
case ECPG_TRANS:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Error in transaction processing in line %d.", line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("error in transaction processing on line %d"), line);
break;
case ECPG_CONNECT:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "Could not connect to database %s in line %d.", str, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("could not connect to database \"%s\" on line %d"), str, line);
break;
default:
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "SQL error #%d in line %d.", code, line);
+ /* translator: this string will be truncated at 149
+ characters expanded. */
+ ecpg_gettext("SQL error %d on line %d"), code, line);
break;
}
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
- ecpg_log("raising sqlcode %d in line %d, '%s'.\n", code, line, sqlca->sqlerrm.sqlerrmc);
+ ecpg_log("raising sqlcode %d on line %d: %s\n", code, line, sqlca->sqlerrm.sqlerrmc);
/* free all memory we have allocated for the user */
ECPGfree_auto_mem();
@@ -173,8 +223,7 @@ ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat)
}
/* copy error message */
- snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
- "'%s' in line %d.", message, line);
+ snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "%s on line %d", message, line);
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
/* copy SQLSTATE */
@@ -188,7 +237,7 @@ ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat)
else
sqlca->sqlcode = ECPG_PGSQL;
- ecpg_log("raising sqlstate %.*s (sqlcode: %d) in line %d, '%s'.\n",
+ ecpg_log("raising sqlstate %.*s (sqlcode %d) on line %d: %s\n",
sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc);
/* free all memory we have allocated for the user */
@@ -201,7 +250,7 @@ ecpg_check_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMP
{
if (results == NULL)
{
- ecpg_log("ecpg_check_PQresult line %d: error: %s", lineno, PQerrorMessage(connection));
+ ecpg_log("ecpg_check_PQresult on line %d: %s", lineno, PQerrorMessage(connection));
ecpg_raise_backend(lineno, NULL, connection, compat);
return (false);
}
@@ -224,7 +273,7 @@ ecpg_check_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMP
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
case PGRES_BAD_RESPONSE:
- ecpg_log("ecpg_check_PQresult line %d: Error: %s", lineno, PQresultErrorMessage(results));
+ ecpg_log("ecpg_check_PQresult on line %d: %s", lineno, PQresultErrorMessage(results));
ecpg_raise_backend(lineno, results, connection, compat);
PQclear(results);
return (false);
@@ -233,13 +282,13 @@ ecpg_check_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMP
return (true);
break;
case PGRES_COPY_IN:
- ecpg_log("ecpg_check_PQresult line %d: Got PGRES_COPY_IN ... tossing.\n", lineno);
+ ecpg_log("ecpg_check_PQresult on line %d: COPY IN data transfer in progress\n", lineno);
PQendcopy(connection);
PQclear(results);
return (false);
break;
default:
- ecpg_log("ecpg_check_PQresult line %d: Got something else, postgres error.\n",
+ ecpg_log("ecpg_check_PQresult on line %d: unknown execution status type\n",
lineno);
ecpg_raise_backend(lineno, results, connection, compat);
PQclear(results);
@@ -255,5 +304,5 @@ sqlprint(void)
struct sqlca_t *sqlca = ECPGget_sqlca();
sqlca->sqlerrm.sqlerrmc[sqlca->sqlerrm.sqlerrml] = '\0';
- fprintf(stderr, "sql error %s\n", sqlca->sqlerrm.sqlerrmc);
+ fprintf(stderr, _("sql error: %s\n"), sqlca->sqlerrm.sqlerrmc);
}