[DBD::Pg] Detect and store the server_encoding on login.

dbdpg-commits-gENoVmVU/[email protected]
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Committed by Greg Sabino Mullane <greg-O9fzpki4YnJWk0Htik3J/[email protected]>

Detect and store the server_encoding on login.

---
 dbdimp.c |    4 ++++
 dbdimp.h |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/dbdimp.c b/dbdimp.c
index 8dbd448..8055330 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -212,6 +212,9 @@ int dbd_db_login6 (SV * dbh, imp_dbh_t * imp_dbh, char * dbname, char * uid, cha
 	TRACE_PQPROTOCOLVERSION;
 	imp_dbh->pg_protocol = PQprotocolVersion(imp_dbh->conn);
 
+	/* Grab the server encoding so we can set out utf8 flags intelligently */
+	imp_dbh->server_encoding = PQparameterStatus(imp_dbh->conn, "server_encoding");
+
 	/* Figure out this particular backend's version */
 	imp_dbh->pg_server_version = -1;
 #if PGLIBVERSION >= 80000
@@ -230,6 +233,7 @@ int dbd_db_login6 (SV * dbh, imp_dbh_t * imp_dbh, char * dbname, char * uid, cha
 		}
 	}
 
+	/* Set all the defaults for this database handle */
 	imp_dbh->pg_bool_tf      = DBDPG_FALSE;
 	imp_dbh->pg_enable_utf8  = DBDPG_FALSE;
  	imp_dbh->prepare_now     = DBDPG_FALSE;
diff --git a/dbdimp.h b/dbdimp.h
index d2829ea..968cb28 100644
--- a/dbdimp.h
+++ b/dbdimp.h
@@ -31,6 +31,7 @@ struct imp_dbh_st {
 	AV      *savepoints;       /* list of savepoints */
 	PGconn  *conn;             /* connection structure */
 	char    *sqlstate;         /* from the last result */
+	const char  *server_encoding;  /* encoding detected at login */
 
 	bool    pg_bool_tf;        /* do bools return 't'/'f'? Set by user, default is 0 */
 	bool    pg_enable_utf8;    /* should we attempt to make utf8 strings? Set by user, default is 0 */
-- 
1.7.0.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.