[DBD::Pg] Quick check of server_encoding on startup so we don't try and utf8 flag data from a SQL_ASCII database. Will need to cache that info or check other places...
dbdpg-commits-gENoVmVU/[email protected] Tue, 13 Sep 2011 04:17:00 +0000
| Newsgroups | gmane.comp.db.postgresql.dbdpg.cvs |
|---|---|
| Message-ID | <[email protected]> |
Committed by Greg Sabino Mullane <greg-O9fzpki4YnJWk0Htik3J/[email protected]> Quick check of server_encoding on startup so we don't try and utf8 flag data from a SQL_ASCII database. Will need to cache that info or check other places... --- dbdimp.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dbdimp.c b/dbdimp.c index eb54f11..a9b3212 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -216,10 +216,15 @@ int dbd_db_login6 (SV * dbh, imp_dbh_t * imp_dbh, char * dbname, char * uid, cha DBD_ATTRIB_GET_IV(attr, "pg_utf8_flag", 12, svp, imp_dbh->pg_utf8_flag); if (imp_dbh->pg_utf8_flag == -1) { /* Has not been explicitly set by the user */ /* - Check the client_encoding. If UTF-8, set the flag on, else off + Check the client_encoding. If UTF-8 and server is not SQL_ASCII, set the flag on, else off */ - imp_dbh->utf8_flag = (0 == strncmp(PQparameterStatus(imp_dbh->conn, "client_encoding"), "UTF8", 4)) - ? 0 : 1; + imp_dbh->utf8_flag = + ( + (0 == strncmp(PQparameterStatus(imp_dbh->conn, "client_encoding"), "UTF8", 4)) + && + (0 != strncmp(PQparameterStatus(imp_dbh->conn, "server_encoding"), "SQL_ASCII", 9)) + ) + ? 1 : 0; } else { /* We allow -1 and 0 direct, and force everything else to 1 */ -- 1.7.0.5