src/cats/postgresql.c
static bool pgsql_check_database_encoding(JCR *jcr, BDB_POSTGRESQL *mdb)
{
   SQL_ROW row;
   int ret = false; 

   if (!mdb->sql_query("SELECT getdatabaseencoding()", QF_STORE_RESULT)) { 
      Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
      return false; 
   }

   if ((row = mdb->sql_fetch_row()) == NULL) { 
      Mmsg1(mdb->errmsg, _("error fetching row: %s\n"), mdb->sql_strerror()); 
      Jmsg(jcr, M_ERROR, 0, "Can't check database encoding %s", mdb->errmsg);
   } else { 
      ret = bstrcmp(row[0], "SQL_ASCII");

      if (ret) {
         /* If we are in SQL_ASCII, we can force the client_encoding to SQL_ASCII too */
         mdb->sql_query("SET client_encoding TO 'SQL_ASCII'"); 

      } else { 
         /* Something is wrong with database encoding */
         Mmsg(mdb->errmsg,
              _("Encoding error for database \"%s\". Wanted SQL_ASCII, got %s\n"),
              mdb->get_db_name(), row[0]); 
         Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
         Dmsg1(dbglvl_err, "%s", mdb->errmsg);
      }
   }
   return ret;
}
/* Check that the database corresponds to the encoding we want  */
Check that the database corresponds to the encoding we want
Check that the database corresponds to the encoding we want
static bool pgsql_check_database_encoding(JCR *jcr, BDB_POSTGRESQL *mdb)
{
   SQL_ROW row;
   int ret = false; 
   if (!mdb->sql_query("SELECT getdatabaseencoding()", QF_STORE_RESULT)) { 
      Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
      return false; 
   }
   if ((row = mdb->sql_fetch_row()) == NULL) { 
      Mmsg1(mdb->errmsg, _("error fetching row: %s\n"), mdb->sql_strerror()); 
      Jmsg(jcr, M_ERROR, 0, "Can't check database encoding %s", mdb->errmsg);
   } else { 
      ret = bstrcmp(row[0], "SQL_ASCII");
      if (ret) {
         mdb->sql_query("SET client_encoding TO 'SQL_ASCII'"); 
      } else { 
         Mmsg(mdb->errmsg,
              _("Encoding error for database \"%s\". Wanted SQL_ASCII, got %s\n"),
              mdb->get_db_name(), row[0]); 
         Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
         Dmsg1(dbglvl_err, "%s", mdb->errmsg);
      }
   }
   return ret;
}
static bool pgsql_check_database_encoding ( JCR * jcr , BDB_POSTGRESQL * mdb ) { SQL_ROW row ; int ret = false ; if ( ! mdb -> sql_query ( " " , QF_STORE_RESULT ) ) { Jmsg ( jcr , M_ERROR , 0 , " " , mdb -> errmsg ) ; return false ; } if ( ( row = mdb -> sql_fetch_row ( ) ) == NULL ) { Mmsg1 ( mdb -> errmsg , _ ( " \n " ) , mdb -> sql_strerror ( ) ) ; Jmsg ( jcr , M_ERROR , 0 , " " , mdb -> errmsg ) ; } else { ret = bstrcmp ( row [ 0 ] , " " ) ; if ( ret ) { mdb -> sql_query ( " " ) ; } else { Mmsg ( mdb -> errmsg , _ ( " \" \" \n " ) , mdb -> get_db_name ( ) , row [ 0 ] ) ; Jmsg ( jcr , M_WARNING , 0 , " " , mdb -> errmsg ) ; Dmsg1 ( dbglvl_err , " " , mdb -> errmsg ) ; } } return ret ; }
Check that the database corresponds to the encoding we want
Check that the database corresponds to the encoding we want
/* If we are in SQL_ASCII, we can force the client_encoding to SQL_ASCII too */ /* Something is wrong with database encoding */