This commit is contained in:
@ -22,6 +22,7 @@ import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.CaseSensibility;
|
||||
import org.apache.doris.common.FeMetaVersion;
|
||||
import org.apache.doris.common.PatternMatcher;
|
||||
import org.apache.doris.common.PatternMatcherException;
|
||||
import org.apache.doris.common.PatternMatcherWrapper;
|
||||
import org.apache.doris.common.io.Text;
|
||||
import org.apache.doris.datasource.InternalCatalog;
|
||||
@ -118,6 +119,11 @@ public class CatalogPrivEntry extends PrivEntry {
|
||||
return compareAssist(origCtl, otherEntry.origCtl);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivEntry copy() throws AnalysisException, PatternMatcherException {
|
||||
return CatalogPrivEntry.create(this.getOrigCtl(), this.getPrivSet().copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyMatch(PrivEntry other) {
|
||||
if (!(other instanceof CatalogPrivEntry)) {
|
||||
|
||||
@ -22,6 +22,7 @@ import org.apache.doris.cluster.ClusterNamespace;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.CaseSensibility;
|
||||
import org.apache.doris.common.PatternMatcher;
|
||||
import org.apache.doris.common.PatternMatcherException;
|
||||
import org.apache.doris.common.io.Text;
|
||||
|
||||
import java.io.DataInput;
|
||||
@ -126,4 +127,8 @@ public class DbPrivEntry extends CatalogPrivEntry {
|
||||
isAnyDb = origDb.equals(ANY_DB);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivEntry copy() throws AnalysisException, PatternMatcherException {
|
||||
return DbPrivEntry.create(this.getOrigCtl(), this.getOrigDb(), this.getPrivSet().copy());
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
package org.apache.doris.mysql.privilege;
|
||||
|
||||
import org.apache.doris.analysis.UserIdentity;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.PatternMatcherException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -72,4 +74,9 @@ public class GlobalPrivEntry extends PrivEntry {
|
||||
password = new byte[passwordLen];
|
||||
in.readFully(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivEntry copy() throws AnalysisException, PatternMatcherException {
|
||||
return GlobalPrivEntry.create(this.getPrivSet().copy());
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package org.apache.doris.mysql.privilege;
|
||||
|
||||
import org.apache.doris.analysis.UserIdentity;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.CaseSensibility;
|
||||
import org.apache.doris.common.PatternMatcher;
|
||||
import org.apache.doris.common.PatternMatcherException;
|
||||
@ -187,4 +188,6 @@ public abstract class PrivEntry implements Comparable<PrivEntry> {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected abstract PrivEntry copy() throws AnalysisException, PatternMatcherException;
|
||||
}
|
||||
|
||||
@ -17,9 +17,11 @@
|
||||
|
||||
package org.apache.doris.mysql.privilege;
|
||||
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.ErrorReport;
|
||||
import org.apache.doris.common.PatternMatcherException;
|
||||
import org.apache.doris.common.io.Text;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -63,6 +65,20 @@ public abstract class PrivTable {
|
||||
*/
|
||||
public PrivEntry addEntry(PrivEntry newEntry,
|
||||
boolean errOnExist, boolean errOnNonExist) throws DdlException {
|
||||
return addEntry(newEntry, errOnExist, errOnNonExist, false);
|
||||
}
|
||||
|
||||
public PrivEntry addEntry(PrivEntry entry, boolean errOnExist, boolean errOnNonExist, boolean isMerge)
|
||||
throws DdlException {
|
||||
PrivEntry newEntry = entry;
|
||||
if (isMerge) {
|
||||
try {
|
||||
newEntry = entry.copy();
|
||||
} catch (AnalysisException | PatternMatcherException e) {
|
||||
LOG.error("exception when copy PrivEntry", e);
|
||||
}
|
||||
}
|
||||
|
||||
PrivEntry existingEntry = getExistingEntry(newEntry);
|
||||
if (existingEntry == null) {
|
||||
if (errOnNonExist) {
|
||||
@ -201,7 +217,7 @@ public abstract class PrivTable {
|
||||
public void merge(PrivTable privTable) {
|
||||
for (PrivEntry entry : privTable.entries) {
|
||||
try {
|
||||
addEntry(entry, false, false);
|
||||
addEntry(entry, false, false, true);
|
||||
} catch (DdlException e) {
|
||||
//will no exception
|
||||
LOG.debug(e.getMessage());
|
||||
|
||||
@ -77,6 +77,11 @@ public class ResourcePrivEntry extends PrivEntry {
|
||||
return origResource.compareTo(otherEntry.origResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivEntry copy() throws AnalysisException, PatternMatcherException {
|
||||
return ResourcePrivEntry.create(this.getOrigResource(), this.getPrivSet().copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyMatch(PrivEntry other) {
|
||||
if (!(other instanceof ResourcePrivEntry)) {
|
||||
|
||||
@ -123,4 +123,8 @@ public class TablePrivEntry extends DbPrivEntry {
|
||||
isAnyTbl = origTbl.equals(ANY_TBL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivEntry copy() throws AnalysisException, PatternMatcherException {
|
||||
return TablePrivEntry.create(this.getOrigCtl(), this.getOrigDb(), this.getOrigTbl(), this.getPrivSet().copy());
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +69,11 @@ public class WorkloadGroupPrivEntry extends PrivEntry {
|
||||
return origWorkloadGroupName.compareTo(otherEntry.origWorkloadGroupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivEntry copy() throws AnalysisException, PatternMatcherException {
|
||||
return WorkloadGroupPrivEntry.create(this.getOrigWorkloadGroupName(), this.getPrivSet().copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyMatch(PrivEntry other) {
|
||||
if (!(other instanceof WorkloadGroupPrivEntry)) {
|
||||
|
||||
Reference in New Issue
Block a user