[chore](backup) Fix the db name of the restored view (#38072)
Cherry-pick #37412, #39855 Previously, during restore, the database name in the CREATE VIEW statement was not modified, causing the restored view to be unviewable with the SHOW VIEW command. This PR retains the original cluster's database name in the BackupMeta and manually replaces it with the new cluster's database name in the CREATE VIEW statement during restore.
This commit is contained in:
@ -780,7 +780,8 @@ public class RestoreJob extends AbstractJob {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
remoteView.resetIdsForRestore(env);
|
||||
String srcDbName = jobInfo.dbName;
|
||||
remoteView.resetIdsForRestore(env, srcDbName, db.getFullName());
|
||||
restoredTbls.add(remoteView);
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,8 +237,13 @@ public class View extends Table {
|
||||
return copied;
|
||||
}
|
||||
|
||||
public void resetIdsForRestore(Env env) {
|
||||
public void resetIdsForRestore(Env env, String srcDbName, String dbName) {
|
||||
id = env.getNextId();
|
||||
|
||||
// the source db name is not setted in old BackupMeta, keep compatible with the old one.
|
||||
if (srcDbName != null) {
|
||||
inlineViewDef = inlineViewDef.replaceAll(srcDbName, dbName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user