diff options
Diffstat (limited to 'src/interfaces/ecpg/ecpglib')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/connect.c | 32 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/data.c | 16 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/descriptor.c | 10 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/error.c | 119 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 43 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/misc.c | 45 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/prepare.c | 10 |
7 files changed, 182 insertions, 93 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 95bdea29571..1b66f6d8358 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.50 2008/03/27 07:56:00 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.51 2008/05/16 15:20:03 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -144,14 +144,14 @@ ecpg_finish(struct connection * act) if (actual_connection == act) actual_connection = all_connections; - ecpg_log("ecpg_finish: Connection %s closed.\n", act->name); + ecpg_log("ecpg_finish: connection %s closed\n", act->name); for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ecpg_free(ptr)); ecpg_free(act->name); ecpg_free(act); } else - ecpg_log("ecpg_finish: called an extra time.\n"); + ecpg_log("ecpg_finish: called an extra time\n"); } bool @@ -163,7 +163,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name) if (!ecpg_init(con, connection_name, lineno)) return (false); - ecpg_log("ECPGsetcommit line %d action = %s connection = %s\n", lineno, mode, con->name); + ecpg_log("ECPGsetcommit on line %d: action \"%s\"; connection \"%s\"\n", lineno, mode, con->name); if (con->autocommit == true && strncmp(mode, "off", strlen("off")) == 0) { @@ -223,13 +223,13 @@ ECPGnoticeReceiver(void *arg, const PGresult *result) sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR; if (message == NULL) /* Shouldn't happen, but need to be sure */ - message = "No message received"; + message = _("No message received"); /* these are not warnings */ if (strncmp(sqlstate, "00", 2) == 0) return; - ecpg_log("ECPGnoticeReceiver %s\n", message); + ecpg_log("ECPGnoticeReceiver: %s\n", message); /* map to SQLCODE for backward compatibility */ if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_NAME) == 0) @@ -377,8 +377,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p host = ecpg_strdup(tmp + 1, lineno); if (strncmp(dbname, "unix:", 5) != 0) { - ecpg_log("ECPGconnect: socketname %s given for TCP connection in line %d\n", host, lineno); - ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>"); + ecpg_log("ECPGconnect: socketname %s given for TCP connection on line %d\n", host, lineno); + ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : _("<DEFAULT>")); if (host) ecpg_free(host); @@ -403,8 +403,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p { if (strcmp(dbname + offset, "localhost") != 0 && strcmp(dbname + offset, "127.0.0.1") != 0) { - ecpg_log("ECPGconnect: non-localhost access via sockets in line %d\n", lineno); - ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>"); + ecpg_log("ECPGconnect: non-localhost access via sockets on line %d\n", lineno); + ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : _("<DEFAULT>")); if (host) ecpg_free(host); if (port) @@ -471,11 +471,11 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p actual_connection = all_connections; ecpg_log("ECPGconnect: opening database %s on %s port %s %s%s %s%s\n", - realname ? realname : "<DEFAULT>", - host ? host : "<DEFAULT>", - port ? (ecpg_internal_regression_mode ? "<REGRESSION_PORT>" : port) : "<DEFAULT>", - options ? "with options " : "", options ? options : "", - user ? "for user " : "", user ? user : ""); + realname ? realname : _("<DEFAULT>"), + host ? host : _("<DEFAULT>"), + port ? (ecpg_internal_regression_mode ? _("<REGRESSION_PORT>") : port) : _("<DEFAULT>"), + options ? _("with options ") : "", options ? options : "", + user ? _("for user ") : "", user ? user : ""); connect_string = ecpg_alloc( strlen_or_null(host) + strlen_or_null(port) @@ -515,7 +515,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p if (PQstatus(this->connection) == CONNECTION_BAD) { const char *errmsg = PQerrorMessage(this->connection); - const char *db = realname ? realname : "<DEFAULT>"; + const char *db = realname ? realname : _("<DEFAULT>"); ecpg_log("ECPGconnect: could not open database: %s\n", errmsg); diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index 0285c71831f..392ebdde773 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.40 2007/11/15 21:14:45 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.41 2008/05/16 15:20:03 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -60,7 +60,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, else log_offset = offset; - ecpg_log("ecpg_get_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, isarray ? "Yes" : "No"); + ecpg_log("ecpg_get_data on line %d: RESULT: %s offset: %ld; array: %s\n", lineno, pval ? (binary ? _("BINARY") : pval) : _("EMPTY"), log_offset, isarray ? _("yes") : _("no")); /* We will have to decode the value */ @@ -360,7 +360,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, else ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, - "different size"); + _("different size")); break; } else if (pval[0] == 't' && pval[1] == '\0') @@ -372,7 +372,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, else ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, - "different size"); + _("different size")); break; } else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field)) @@ -490,7 +490,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, /* did we get an error? */ if (nres == NULL) { - ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n", + ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n", lineno, pval ? pval : "", errno); if (INFORMIX_MODE(compat)) @@ -553,7 +553,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, /* did we get an error? */ if (ires == NULL) { - ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n", + ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n", lineno, pval ? pval : "", errno); if (INFORMIX_MODE(compat)) @@ -607,7 +607,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, /* did we get an error? */ if (errno != 0) { - ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n", + ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n", lineno, pval ? pval : "", errno); if (INFORMIX_MODE(compat)) @@ -654,7 +654,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, /* did we get an error? */ if (errno != 0) { - ecpg_log("ecpg_get_data line %d: RESULT: %s errno %d\n", + ecpg_log("ecpg_get_data on line %d: RESULT %s; errno %d\n", lineno, pval ? pval : "", errno); if (INFORMIX_MODE(compat)) diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c index df9ea295344..457ee04df5f 100644 --- a/src/interfaces/ecpg/ecpglib/descriptor.c +++ b/src/interfaces/ecpg/ecpglib/descriptor.c @@ -1,6 +1,6 @@ /* dynamic SQL support routines * - * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.29 2008/01/15 10:31:47 meskes Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.30 2008/05/16 15:20:03 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL @@ -99,7 +99,7 @@ ECPGget_desc_header(int lineno, const char *desc_name, int *count) *count = PQnfields(ECPGresult); sqlca->sqlerrd[2] = 1; - ecpg_log("ECPGget_desc_header: found %d attributes.\n", *count); + ecpg_log("ECPGget_desc_header: found %d attributes\n", *count); return true; } @@ -381,7 +381,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) */ if (arrsize > 0 && ntuples > arrsize) { - ecpg_log("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + ecpg_log("ECPGget_desc on line %d: incorrect number of matches; %d don't fit into array of %d\n", lineno, ntuples, arrsize); ecpg_raise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL); return false; @@ -450,7 +450,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) */ if (data_var.ind_arrsize > 0 && ntuples > data_var.ind_arrsize) { - ecpg_log("ECPGget_desc line %d: Incorrect number of matches (indicator): %d don't fit into array of %d\n", + ecpg_log("ECPGget_desc on line %d: incorrect number of matches (indicator); %d don't fit into array of %d\n", lineno, ntuples, data_var.ind_arrsize); ecpg_raise(lineno, ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL); return false; @@ -724,6 +724,6 @@ ecpg_find_desc(int line, const char *name) bool ECPGdescribe(int line, bool input, const char *statement,...) { - ecpg_log("ECPGdescribe called on line %d for %s in %s\n", line, (input) ? "input" : "output", statement); + ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, (input) ? _("input") : _("output"), statement); return false; } diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c index cce370aca65..a36f374e7d3 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); } diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index f7bfd9dca7f..a6e58f0eaea 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.77 2008/03/01 03:26:34 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.78 2008/05/16 15:20:03 petere Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -301,7 +301,7 @@ ecpg_is_type_an_array(int type, const struct statement * stmt, const struct vari return (ECPG_ARRAY_ERROR); ecpg_type_infocache_push(&(stmt->connection->cache_head), type, isarray, stmt->lineno); - ecpg_log("ecpg_is_type_an_array line %d: TYPE database: %d C: %d array: %s\n", stmt->lineno, type, var->type, isarray ? "Yes" : "No"); + ecpg_log("ecpg_is_type_an_array on line %d: type (%d); C (%d); array (%s)\n", stmt->lineno, type, var->type, isarray ? _("yes") : _("no")); return isarray; } @@ -328,7 +328,7 @@ ecpg_store_result(const PGresult *results, int act_field, */ if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize)) { - ecpg_log("ecpg_store_result line %d: Incorrect number of matches: %d don't fit into array of %d\n", + ecpg_log("ecpg_store_result on line %d: incorrect number of matches; %d don't fit into array of %d\n", stmt->lineno, ntuples, var->arrsize); ecpg_raise(stmt->lineno, INFORMIX_MODE(stmt->compat) ? ECPG_INFORMIX_SUBSELECT_NOT_ONE : ECPG_TOO_MANY_MATCHES, ECPG_SQLSTATE_CARDINALITY_VIOLATION, NULL); return false; @@ -387,7 +387,7 @@ ecpg_store_result(const PGresult *results, int act_field, len = var->offset * ntuples; break; } - ecpg_log("ecpg_store_result: line %d: allocating memory for %d tuples\n", stmt->lineno, ntuples); + ecpg_log("ecpg_store_result on line %d: allocating memory for %d tuples\n", stmt->lineno, ntuples); var->value = (char *) ecpg_alloc(len, stmt->lineno); if (!var->value) return false; @@ -729,7 +729,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari for (element = 0; element < var->arrsize; element++) sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f'); else - ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, "different size"); + ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, _("different size")); strcpy(mallocedval + strlen(mallocedval) - 1, "]"); } @@ -740,7 +740,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari else if (var->offset == sizeof(int)) sprintf(mallocedval, "%c", (*((int *) var->value)) ? 't' : 'f'); else - ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, "different size"); + ecpg_raise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, _("different size")); } *tobeinserted_p = mallocedval; @@ -1042,7 +1042,7 @@ free_params(const char **paramValues, int nParams, bool print, int lineno) for (n = 0; n < nParams; n++) { if (print) - ecpg_log("free_params line %d: parameter %d = %s\n", lineno, n + 1, paramValues[n] ? paramValues[n] : "null"); + ecpg_log("free_params on line %d: parameter %d = %s\n", lineno, n + 1, paramValues[n] ? paramValues[n] : _("null")); ecpg_free((void *) (paramValues[n])); } ecpg_free(paramValues); @@ -1275,23 +1275,23 @@ ecpg_execute(struct statement * stmt) stmt->connection->committed = false; } - ecpg_log("ecpg_execute line %d: QUERY: %s with %d parameter on connection %s \n", stmt->lineno, stmt->command, nParams, stmt->connection->name); + ecpg_log("ecpg_execute on line %d: query: %s; with %d parameter(s) on connection %s\n", stmt->lineno, stmt->command, nParams, stmt->connection->name); if (stmt->statement_type == ECPGst_execute) { results = PQexecPrepared(stmt->connection->connection, stmt->name, nParams, paramValues, NULL, NULL, 0); - ecpg_log("ecpg_execute line %d: using PQexecPrepared for %s\n", stmt->lineno, stmt->command); + ecpg_log("ecpg_execute on line %d: using PQexecPrepared for \"%s\"\n", stmt->lineno, stmt->command); } else { if (nParams == 0) { results = PQexec(stmt->connection->connection, stmt->command); - ecpg_log("ecpg_execute line %d: using PQexec\n", stmt->lineno); + ecpg_log("ecpg_execute on line %d: using PQexec\n", stmt->lineno); } else { results = PQexecParams(stmt->connection->connection, stmt->command, nParams, NULL, paramValues, NULL, NULL, 0); - ecpg_log("ecpg_execute line %d: using PQexecParams \n", stmt->lineno); + ecpg_log("ecpg_execute on line %d: using PQexecParams\n", stmt->lineno); } } @@ -1310,13 +1310,13 @@ ecpg_execute(struct statement * stmt) case PGRES_TUPLES_OK: nfields = PQnfields(results); sqlca->sqlerrd[2] = ntuples = PQntuples(results); - ecpg_log("ecpg_execute line %d: Correctly got %d tuples with %d fields\n", stmt->lineno, ntuples, nfields); + ecpg_log("ecpg_execute on line %d: correctly got %d tuples with %d fields\n", stmt->lineno, ntuples, nfields); status = true; if (ntuples < 1) { if (ntuples) - ecpg_log("ecpg_execute line %d: Incorrect number of matches: %d\n", + ecpg_log("ecpg_execute on line %d: incorrect number of matches (%d)\n", stmt->lineno, ntuples); ecpg_raise(stmt->lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); status = false; @@ -1335,7 +1335,8 @@ ecpg_execute(struct statement * stmt) PQclear(desc->result); desc->result = results; clear_result = false; - ecpg_log("ecpg_execute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char *) var->pointer); + ecpg_log("ecpg_execute on line %d: putting result (%d tuples) into descriptor %s\n", + stmt->lineno, PQntuples(results), (const char *) var->pointer); } var = var->next; } @@ -1366,7 +1367,7 @@ ecpg_execute(struct statement * stmt) cmdstat = PQcmdStatus(results); sqlca->sqlerrd[1] = PQoidValue(results); sqlca->sqlerrd[2] = atol(PQcmdTuples(results)); - ecpg_log("ecpg_execute line %d Ok: %s\n", stmt->lineno, cmdstat); + ecpg_log("ecpg_execute on line %d: OK: %s\n", stmt->lineno, cmdstat); if (stmt->compat != ECPG_COMPAT_INFORMIX_SE && !sqlca->sqlerrd[2] && (!strncmp(cmdstat, "UPDATE", 6) @@ -1379,7 +1380,7 @@ ecpg_execute(struct statement * stmt) char *buffer; int res; - ecpg_log("ecpg_execute line %d: Got PGRES_COPY_OUT\n", stmt->lineno); + ecpg_log("ecpg_execute on line %d: COPY OUT data transfer in progress\n", stmt->lineno); while ((res = PQgetCopyData(stmt->connection->connection, &buffer, 0)) > 0) { @@ -1392,9 +1393,9 @@ ecpg_execute(struct statement * stmt) PQclear(results); results = PQgetResult(stmt->connection->connection); if (PQresultStatus(results) == PGRES_COMMAND_OK) - ecpg_log("ecpg_execute line %d: Got PGRES_COMMAND_OK after PGRES_COPY_OUT\n", stmt->lineno); + ecpg_log("ecpg_execute on line %d: got PGRES_COMMAND_OK after PGRES_COPY_OUT\n", stmt->lineno); else - ecpg_log("ecpg_execute line %d: Got error after PGRES_COPY_OUT: %s", PQresultErrorMessage(results)); + ecpg_log("ecpg_execute on line %d: got error after PGRES_COPY_OUT: %s", PQresultErrorMessage(results)); } break; } @@ -1404,7 +1405,7 @@ ecpg_execute(struct statement * stmt) * execution should never reach this code because it is already * handled in ECPGcheck_PQresult() */ - ecpg_log("ecpg_execute line %d: Got something else, postgres error.\n", + ecpg_log("ecpg_execute on line %d: unknown execution status type\n", stmt->lineno); ecpg_raise_backend(stmt->lineno, results, stmt->connection->connection, stmt->compat); status = false; @@ -1417,7 +1418,7 @@ ecpg_execute(struct statement * stmt) notify = PQnotifies(stmt->connection->connection); if (notify) { - ecpg_log("ecpg_execute line %d: ASYNC NOTIFY of '%s' from backend pid '%d' received\n", + ecpg_log("ecpg_execute on line %d: asynchronous notification of \"%s\" from backend pid %d received\n", stmt->lineno, notify->relname, notify->be_pid); PQfreemem(notify); } @@ -1624,7 +1625,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char if (con == NULL || con->connection == NULL) { free_statement(stmt); - ecpg_raise(lineno, ECPG_NOT_CONN, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, (con) ? con->name : "<empty>"); + ecpg_raise(lineno, ECPG_NOT_CONN, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, (con) ? con->name : _("<empty>")); setlocale(LC_NUMERIC, oldlocale); ecpg_free(oldlocale); return false; diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 4c2b2447e91..03956f11dc2 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.41 2007/11/15 21:14:45 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.42 2008/05/16 15:20:03 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -15,6 +15,7 @@ #include "pgtypes_date.h" #include "pgtypes_timestamp.h" #include "pgtypes_interval.h" +#include "pg_config_paths.h" #ifdef HAVE_LONG_LONG_INT_64 #ifndef LONG_LONG_MIN @@ -109,7 +110,7 @@ ecpg_init(const struct connection * con, const char *connection_name, const int if (con == NULL) { ecpg_raise(lineno, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST, - connection_name ? connection_name : "NULL"); + connection_name ? connection_name : _("NULL")); return (false); } @@ -178,7 +179,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction) if (!ecpg_init(con, connection_name, lineno)) return (false); - ecpg_log("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con ? con->name : "(nil)"); + ecpg_log("ECPGtrans on line %d: action \"%s\"; connection \"%s\"\n", lineno, transaction, con ? con->name : _("null")); /* if we have no connection we just simulate the command */ if (con && con->connection) @@ -242,6 +243,9 @@ ecpg_log(const char *format,...) va_list ap; struct sqlca_t *sqlca = ECPGget_sqlca(); + /* internationalize the error message string */ + format = ecpg_gettext(format); + if (simple_debug) { int bufsize = strlen(format) + 100; @@ -447,3 +451,38 @@ win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void)) #endif /* ENABLE_THREAD_SAFETY */ #endif /* WIN32 */ + +#ifdef ENABLE_NLS + +char * +ecpg_gettext(const char *msgid) +{ + static bool already_bound = false; + + if (!already_bound) + { + /* dgettext() preserves errno, but bindtextdomain() doesn't */ +#ifdef WIN32 + int save_errno = GetLastError(); +#else + int save_errno = errno; +#endif + const char *ldir; + + already_bound = true; + /* No relocatable lookup here because the binary could be anywhere */ + ldir = getenv("PGLOCALEDIR"); + if (!ldir) + ldir = LOCALEDIR; + bindtextdomain("ecpg", ldir); +#ifdef WIN32 + SetLastError(save_errno); +#else + errno = save_errno; +#endif + } + + return dgettext("ecpg", msgid); +} + +#endif /* ENABLE_NLS */ diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c index 6ddda4e9edd..f6a88d877a1 100644 --- a/src/interfaces/ecpg/ecpglib/prepare.c +++ b/src/interfaces/ecpg/ecpglib/prepare.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.28 2008/05/14 15:16:27 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.29 2008/05/16 15:20:03 petere Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -164,7 +164,7 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co return false; } - ecpg_log("ECPGprepare line %d: NAME: %s QUERY: %s\n", stmt->lineno, name, stmt->command); + ecpg_log("ECPGprepare on line %d: name %s; query: \"%s\"\n", stmt->lineno, name, stmt->command); PQclear(query); this->prepared = true; @@ -201,7 +201,7 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection * con, struct p { bool r = false; - ecpg_log("ECPGdeallocate line %d: NAME: %s\n", lineno, this->name); + ecpg_log("ECPGdeallocate on line %d: name %s\n", lineno, this->name); /* first deallocate the statement in the backend */ if (this->prepared) @@ -470,12 +470,12 @@ ecpg_auto_prepare(int lineno, const char *connection_name, int compat, const int /* if not found - add the statement to the cache */ if (entNo) { - ecpg_log("ecpg_auto_prepare line %d: stmt found in cache, entry %d\n", lineno, entNo); + ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo); *name = ecpg_strdup(stmtCacheEntries[entNo].stmtID, lineno); } else { - ecpg_log("ecpg_auto_prepare line %d: stmt not in cache; inserting\n", lineno); + ecpg_log("ecpg_auto_prepare on line %d: statement not in cache; inserting\n", lineno); /* generate a statement ID */ *name = (char *) ecpg_alloc(STMTID_SIZE, lineno); |