mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-17 16:11:12 +02:00
2018-10-08 Fred Gleason <fredg@paravelsystems.com>
* Removed the 'Charset=' and 'Collation=' parameters from the '[mySQL]' section of rd.conf(5). * Removed support for the --mysql-charset=' and '--mysql-collation=' switches in rddbmgr(8). * Refactored handling of character set and collation attributes in rddbmgr(8) to treat them as immutable parts of the DB schema.
This commit is contained in:
@@ -20,14 +20,15 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qstringlist.h>
|
||||
|
||||
#include <dbversion.h>
|
||||
#include <rddb.h>
|
||||
#include <rdescape_string.h>
|
||||
|
||||
#include "rddbmgr.h"
|
||||
//Added by qt3to4:
|
||||
#include <QSqlQuery>
|
||||
|
||||
bool MainObject::Modify(QString *err_msg,int set_schema) const
|
||||
bool MainObject::Modify(QString *err_msg,int set_schema)
|
||||
{
|
||||
*err_msg="ok";
|
||||
|
||||
@@ -68,3 +69,50 @@ int MainObject::GetCurrentSchema() const
|
||||
}
|
||||
|
||||
|
||||
bool MainObject::ModifyCharset(const QString &charset,
|
||||
const QString &collation)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
//
|
||||
// Per-table Attributes
|
||||
//
|
||||
sql=QString("select ")+
|
||||
"TABLE_NAME,"+ // 00
|
||||
"TABLE_COLLATION "+ // 01
|
||||
"from information_schema.TABLES where "+
|
||||
"TABLE_SCHEMA='"+RDEscapeString(db_mysql_database)+"'";
|
||||
q=new RDSqlQuery(sql,false);
|
||||
while(q->next()) {
|
||||
QStringList f0=q->value(1).toString().split("_");
|
||||
QString prev_charset=f0.at(0);
|
||||
if(q->value(1).toString().toLower()!=collation) {
|
||||
RewriteTable(q->value(0).toString(),prev_charset,charset,collation);
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
|
||||
//
|
||||
// Database Attributes
|
||||
//
|
||||
sql=QString("select ")+
|
||||
"SCHEMA_NAME,"+ // 00
|
||||
"DEFAULT_CHARACTER_SET_NAME,"+ // 01
|
||||
"DEFAULT_COLLATION_NAME "+ // 02
|
||||
"from information_schema.SCHEMATA";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
if(q->value(0).toString()==db_mysql_database) {
|
||||
if((q->value(1).toString().toLower()!=charset)||
|
||||
(q->value(2).toString().toLower()!=collation)) {
|
||||
sql=QString("alter database `")+db_mysql_database+"` "+
|
||||
"character set "+charset+" collate "+collation;
|
||||
RDSqlQuery::apply(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user