From: Eric Bollengier Date: Sun, 15 Feb 2009 15:32:05 +0000 (+0000) Subject: ebl Add patch to check database encoding X-Git-Tag: Release-3.0.0~234 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=268d11a0f7b556cb5239c13eb2173a49ec4daaf3;p=bacula%2Fbacula ebl Add patch to check database encoding git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8453 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/postgresql_check_encoding.patch b/bacula/patches/testing/postgresql_check_encoding.patch new file mode 100644 index 0000000000..5b8d87fa3d --- /dev/null +++ b/bacula/patches/testing/postgresql_check_encoding.patch @@ -0,0 +1,58 @@ +Index: src/cats/postgresql.c +=================================================================== +--- src/cats/postgresql.c (revision 8452) ++++ src/cats/postgresql.c (working copy) +@@ -132,6 +132,34 @@ + return mdb; + } + ++/* Check that the database correspond to the encoding we want */ ++static bool check_database_encoding(JCR *jcr, B_DB *mdb) ++{ ++ SQL_ROW row; ++ int ret=false; ++ ++ if (!db_sql_query(mdb, "SELECT getdatabaseencoding()", NULL, NULL)) { ++ Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); ++ return false; ++ } ++ ++ if (mdb->num_rows == 1) { ++ if ((row = sql_fetch_row(mdb)) == NULL) { ++ Mmsg1(mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); ++ Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); ++ } else { ++ ret = bstrcmp(row[0], "SQL_ASCII") ; ++ if (!ret) { ++ Mmsg(mdb->errmsg, ++ _("Encoding error for database \"%s\". Wanted SQL_ASCII, got %s\n"), ++ mdb->db_name, row[0]); ++ Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); ++ } ++ } ++ } ++ return ret; ++} ++ + /* + * Now actually open the database. This can generate errors, + * which are returned in the errmsg +@@ -147,7 +175,7 @@ + #ifdef xxx + if (!PQisthreadsafe()) { + Jmsg(jcr, M_ABORT, 0, _("PostgreSQL configuration problem. " +- "PostgreSQL library is not thread safe. Connot continue.\n")); ++ "PostgreSQL library is not thread safe. Cannot continue.\n")); + } + #endif + P(mutex); +@@ -219,6 +247,9 @@ + */ + sql_query(mdb, "set standard_conforming_strings=on"); + ++ /* check that encoding is SQL_ASCII */ ++ check_database_encoding(jcr, mdb); ++ + V(mutex); + return 1; + }