2024-12-20 Fred Gleason <fredg@paravelsystems.com>

* Added code at the 275=>276 schema transition in rddbmgr(8) to
	clean up corrupted meta-tables.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2024-12-20 16:40:55 -05:00
parent 266ea140dd
commit 03c16cb1ae
3 changed files with 48 additions and 1 deletions

View File

@ -24944,3 +24944,6 @@
2024-12-13 Fred Gleason <fredg@paravelsystems.com>
* Fixed regression in the build system that caused sections of the
HTML version of Operations Guide to be missing.
2024-12-20 Fred Gleason <fredg@paravelsystems.com>
* Added code at the 275=>276 schema transition in rddbmgr(8) to
clean up corrupted meta-tables.

View File

@ -112,6 +112,7 @@ class MainObject : public QObject
bool UpdateLogTable186(const QString &table,QString *err_msg) const;
bool ConvertTimeField186(const QString &table,const QString &field,
QString *err_msg) const;
bool NormalizeMetatables276(const QString &table_ext,QString *err_msg) const;
bool ConvertArtistSep307(QString *err_msg) const;
bool StackLineTitles347(QString *err_msg) const;

View File

@ -6846,6 +6846,11 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
}
if((cur_schema<276)&&(set_schema>cur_schema)) {
NormalizeMetatables276("CLK",err_msg);
NormalizeMetatables276("RULES",err_msg);
NormalizeMetatables276("PRE",err_msg);
NormalizeMetatables276("POST",err_msg);
NormalizeMetatables276("SRT",err_msg);
sql=QString("alter table `SYSTEM` ")+
"add column `NOTIFICATION_ADDRESS` char(15) default '"+
RD_NOTIFICATION_ADDRESS+"' after `SHOW_USER_LIST`";
@ -11702,6 +11707,44 @@ bool MainObject::ConvertTimeField186(const QString &table,const QString &field,
return true;
}
bool MainObject::NormalizeMetatables276(const QString &table_ext,
QString *err_msg) const
{
QStringList tables;
QString sql=QString("show tables");
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
tables.push_back(q->value(0).toString());
}
delete q;
for(int i=0;i<tables.size();i++) {
QString new_name=tables.at(i);
while(new_name.contains("__"+table_ext)) {
new_name.replace("__"+table_ext,"_"+table_ext);
}
if(new_name!=tables.at(i)) {
if(tables.contains(new_name)) {
DropTable(tables.at(i));
fprintf(stderr,"rddbmgr: dropping duplicate table '%s'\n",
tables.at(i).toUtf8().constData());
}
else {
sql=QString::asprintf("rename table %s to %s",
tables.at(i).toUtf8().constData(),
new_name.toUtf8().constData());
RDSqlQuery::apply(sql);
fprintf(stderr,"rddbmgr: renamed table '%s' to '%s'\n",
tables.at(i).toUtf8().constData(),
new_name.toUtf8().constData());
}
}
}
return true;
}
bool MainObject::ConvertArtistSep307(QString *err_msg) const
{
QString sql;