This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b09e5ced97 [fix](priv) fix meta replay bug when upgrading from 1.1.x
to 1.2.x (#14046)
b09e5ced97 is described below
commit b09e5ced973cffb0ab03b1c37f15fdd40567d718
Author: Mingyu Chen <[email protected]>
AuthorDate: Tue Nov 8 10:43:33 2022 +0800
[fix](priv) fix meta replay bug when upgrading from 1.1.x to 1.2.x (#14046)
---
.../java/org/apache/doris/mysql/privilege/PrivBitSet.java | 2 +-
.../org/apache/doris/mysql/privilege/UserPrivTable.java | 2 +-
.../org/apache/doris/mysql/privilege/PrivEntryTest.java | 15 +++++++++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
index 3f1b844775..a5a46cb294 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
@@ -53,7 +53,7 @@ public class PrivBitSet implements Writable {
public void unset(int index) {
Preconditions.checkState(index < PaloPrivilege.privileges.length,
index);
- set ^= 1 << index;
+ set &= ~(1 << index);
}
public boolean get(int index) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
index 767ee15b8d..b69b1157d5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
@@ -209,7 +209,7 @@ public class UserPrivTable extends PrivTable {
try {
// USAGE_PRIV is no need to degrade.
PrivBitSet removeUsagePriv =
globalPrivEntry.privSet.copy();
-
removeUsagePriv.xor(PrivBitSet.of(PaloPrivilege.USAGE_PRIV));
+ removeUsagePriv.unset(PaloPrivilege.USAGE_PRIV.getIdx());
CatalogPrivEntry entry =
CatalogPrivEntry.create(globalPrivEntry.origUser, globalPrivEntry.origHost,
InternalCatalog.INTERNAL_CATALOG_NAME,
globalPrivEntry.isDomain, removeUsagePriv);
entry.setSetByDomainResolver(false);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/PrivEntryTest.java
b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/PrivEntryTest.java
index 0a261c0951..16e31f4a68 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/PrivEntryTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/PrivEntryTest.java
@@ -45,4 +45,19 @@ public class PrivEntryTest {
tablePrivTable.getPrivs(userIdentity,
InternalCatalog.INTERNAL_CATALOG_NAME, "db_db1", "tbl_tbl1", privs2);
Assert.assertTrue(PaloPrivilege.satisfy(privs2, PrivPredicate.DROP));
}
+
+ @Test
+ public void testPrivBitSet() {
+ PrivBitSet privBitSet = PrivBitSet.of(PaloPrivilege.ADMIN_PRIV,
PaloPrivilege.NODE_PRIV);
+ Assert.assertTrue(privBitSet.containsPrivs(PaloPrivilege.ADMIN_PRIV));
+ Assert.assertTrue(privBitSet.containsPrivs(PaloPrivilege.NODE_PRIV));
+ privBitSet.set(PaloPrivilege.DROP_PRIV.getIdx());
+ Assert.assertTrue(privBitSet.containsPrivs(PaloPrivilege.DROP_PRIV));
+ privBitSet.set(PaloPrivilege.DROP_PRIV.getIdx());
+ Assert.assertTrue(privBitSet.containsPrivs(PaloPrivilege.DROP_PRIV));
+ privBitSet.unset(PaloPrivilege.NODE_PRIV.getIdx());
+ Assert.assertFalse(privBitSet.containsPrivs(PaloPrivilege.NODE_PRIV));
+ privBitSet.unset(PaloPrivilege.NODE_PRIV.getIdx());
+ Assert.assertFalse(privBitSet.containsPrivs(PaloPrivilege.NODE_PRIV));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]