Skip to content

Commit

Permalink
backup globaoinfo as sql
Browse files Browse the repository at this point in the history
  • Loading branch information
justfortaste committed Jan 7, 2025
1 parent e3a7476 commit 1e4e1a5
Show file tree
Hide file tree
Showing 19 changed files with 462 additions and 1,042 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ unsupportedOtherStatement
| BACKUP GLOBAL? SNAPSHOT label=multipartIdentifier TO repo=identifier
((ON | EXCLUDE) LEFT_PAREN baseTableRef (COMMA baseTableRef)* RIGHT_PAREN)?
properties=propertyClause? #backup
| RESTORE GLOBAL? SNAPSHOT label=multipartIdentifier FROM repo=identifier
| RESTORE SNAPSHOT label=multipartIdentifier FROM repo=identifier
((ON | EXCLUDE) LEFT_PAREN baseTableRef (COMMA baseTableRef)* RIGHT_PAREN)?
properties=propertyClause? #restore
| START TRANSACTION (WITH CONSISTENT SNAPSHOT)? #unsupportedStartTransaction
Expand Down Expand Up @@ -372,7 +372,7 @@ unsupportedShowStatement
| SHOW TABLETS FROM tableName=multipartIdentifier partitionSpec?
wildWhere? sortClause? limitClause? #showTabletsFromTable
| SHOW GLOBAL? BACKUP ((FROM | IN) database=multipartIdentifier)? wildWhere? #showBackup
| SHOW GLOBAL? BRIEF? RESTORE ((FROM | IN) database=multipartIdentifier)? wildWhere? #showRestore
| SHOW BRIEF? RESTORE ((FROM | IN) database=multipartIdentifier)? wildWhere? #showRestore
| SHOW RESOURCES wildWhere? sortClause? limitClause? #showResources
| SHOW WORKLOAD GROUPS wildWhere? #showWorkloadGroups
| SHOW SNAPSHOT ON repo=identifier wildWhere? #showSnapshot
Expand Down Expand Up @@ -509,7 +509,7 @@ unsupportedCancelStatement
| CANCEL DECOMMISSION BACKEND hostPorts+=STRING_LITERAL
(COMMA hostPorts+=STRING_LITERAL)* #cancelDecommisionBackend
| CANCEL GLOBAL? BACKUP ((FROM | IN) database=identifier)? #cancelBackup
| CANCEL GLOBAL? RESTORE ((FROM | IN) database=identifier)? #cancelRestore
| CANCEL RESTORE ((FROM | IN) database=identifier)? #cancelRestore
;

supportedAdminStatement
Expand Down
14 changes: 0 additions & 14 deletions fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -4558,10 +4558,6 @@ show_param ::=
{:
RESULT = new ShowRestoreStmt(db, parser.where);
:}
| KW_GLOBAL KW_RESTORE opt_wild_where
{:
RESULT = new ShowRestoreStmt(parser.where);
:}
| KW_BRIEF KW_RESTORE opt_db:db opt_wild_where
{:
RESULT = new ShowRestoreStmt(db, parser.where, true);
Expand Down Expand Up @@ -5085,10 +5081,6 @@ cancel_param ::=
{:
RESULT = new CancelBackupStmt(db, true);
:}
| KW_GLOBAL KW_RESTORE
{:
RESULT = new CancelBackupStmt(true);
:}
| KW_WARM KW_UP KW_JOB opt_wild_where
{:
RESULT = new CancelCloudWarmUpStmt(parser.where);
Expand Down Expand Up @@ -5579,12 +5571,6 @@ restore_stmt ::=
{:
RESULT = new RestoreStmt(label, repoName, tblRefClause, properties);
:}
| KW_RESTORE KW_GLOBAL KW_SNAPSHOT job_label:label
KW_FROM ident:repoName
opt_properties:properties
{:
RESULT = new RestoreStmt(label, repoName, properties);
:}
;

// Kill statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class AbstractBackupStmt extends DdlStmt {
protected String repoName;
protected AbstractBackupTableRefClause abstractBackupTableRefClause;
protected Map<String, String> properties;

protected long timeoutMs;
public boolean backupGlobal = false;

Expand Down Expand Up @@ -127,7 +128,7 @@ public String getDbName() {
}

public boolean isBackupGlobal() {
return backupGlobal;
return backupGlobal;
}

public String getLabel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public class RestoreStmt extends AbstractBackupStmt implements NotFallbackInPars
public static final String PROP_CLEAN_TABLES = "clean_tables";
public static final String PROP_CLEAN_PARTITIONS = "clean_partitions";
public static final String PROP_ATOMIC_RESTORE = "atomic_restore";
public static final String PROP_RESERVE_PRIVILEGE = "reserve_privilege";
public static final String PROP_RESERVE_CATALOG = "reserve_catalog";
public static final String PROP_RESERVE_WORKLOAD_GROUP = "reserve_workload_group";

private boolean allowLoad = false;
private ReplicaAllocation replicaAlloc = ReplicaAllocation.DEFAULT_ALLOCATION;
Expand All @@ -61,9 +58,6 @@ public class RestoreStmt extends AbstractBackupStmt implements NotFallbackInPars
private boolean isAtomicRestore = false;
private byte[] meta = null;
private byte[] jobInfo = null;
private boolean reservePrivilege = false;
private boolean reserveCatalog = false;
private boolean reserveWorkloadGroup = false;

public RestoreStmt(LabelName labelName, String repoName, AbstractBackupTableRefClause restoreTableRefClause,
Map<String, String> properties) {
Expand Down Expand Up @@ -138,18 +132,6 @@ public boolean isAtomicRestore() {
return isAtomicRestore;
}

public boolean reservePrivilege() {
return reservePrivilege;
}

public boolean reserveCatalog() {
return reserveCatalog;
}

public boolean reserveWorkloadGroup() {
return reserveWorkloadGroup;
}

@Override
public void analyze(Analyzer analyzer) throws UserException {
if (repoName.equals(Repository.KEEP_ON_LOCAL_REPO_NAME)) {
Expand Down Expand Up @@ -235,59 +217,6 @@ public void analyzeProperties() throws AnalysisException {
// is atomic restore
isAtomicRestore = eatBooleanProperty(copiedProperties, PROP_ATOMIC_RESTORE, isAtomicRestore);

// reserve privilege
if (copiedProperties.containsKey(PROP_RESERVE_PRIVILEGE)) {
if (copiedProperties.get(PROP_RESERVE_PRIVILEGE).equalsIgnoreCase("true")) {
reservePrivilege = true;
} else if (copiedProperties.get(PROP_RESERVE_PRIVILEGE).equalsIgnoreCase("false")) {
reservePrivilege = false;
} else {
ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR,
"Invalid reserve_privilege value: " + copiedProperties.get(PROP_RESERVE_PRIVILEGE));
}
copiedProperties.remove(PROP_RESERVE_PRIVILEGE);
}

// reserve catalog
if (copiedProperties.containsKey(PROP_RESERVE_CATALOG)) {
if (copiedProperties.get(PROP_RESERVE_CATALOG).equalsIgnoreCase("true")) {
reserveCatalog = true;
} else if (copiedProperties.get(PROP_RESERVE_CATALOG).equalsIgnoreCase("false")) {
reserveCatalog = false;
} else {
ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR,
"Invalid reserve_catalog value: " + copiedProperties.get(PROP_RESERVE_CATALOG));
}
copiedProperties.remove(PROP_RESERVE_CATALOG);
}

// reserve workload group
if (copiedProperties.containsKey(PROP_RESERVE_WORKLOAD_GROUP)) {
if (copiedProperties.get(PROP_RESERVE_WORKLOAD_GROUP).equalsIgnoreCase("true")) {
reserveWorkloadGroup = true;
} else if (copiedProperties.get(PROP_RESERVE_WORKLOAD_GROUP).equalsIgnoreCase("false")) {
reserveWorkloadGroup = false;
} else {
ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR,
"Invalid reserve_workload_group value: " + copiedProperties.get(PROP_RESERVE_WORKLOAD_GROUP));
}
copiedProperties.remove(PROP_RESERVE_WORKLOAD_GROUP);
}

if (isBackupGlobal()) {
if (!properties.containsKey(PROP_RESERVE_PRIVILEGE)
&& !properties.containsKey(PROP_RESERVE_CATALOG)
&& !properties.containsKey(PROP_RESERVE_WORKLOAD_GROUP)) {
reservePrivilege = true;
reserveCatalog = true;
reserveWorkloadGroup = true;
}
} else {
reservePrivilege = false;
reserveCatalog = false;
reserveWorkloadGroup = false;
}

if (!copiedProperties.isEmpty()) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR,
"Unknown restore job properties: " + copiedProperties.keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.doris.common.CaseSensibility;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.PatternMatcher;
import org.apache.doris.common.PatternMatcherWrapper;
import org.apache.doris.common.UserException;
Expand Down Expand Up @@ -66,11 +65,6 @@ public ShowRestoreStmt(String dbName, Expr where) {
this.where = where;
}

public ShowRestoreStmt(Expr where) {
this.dbName = FeConstants.INTERNAL_DB_NAME;
this.where = where;
}

public ShowRestoreStmt(String dbName, Expr where, boolean needBriefResult) {
this.dbName = dbName;
this.where = where;
Expand Down
Loading

0 comments on commit 1e4e1a5

Please sign in to comment.