mirror of
https://github.com/actiontech/dble.git
synced 2026-05-04 13:30:16 -05:00
Merge pull request #3520 from actiontech/fix/codeql2
fix: codeql adaptation
This commit is contained in:
@@ -88,11 +88,8 @@ class DecryptByPublicKey(object):
|
||||
# 这里使用了six库的iterbytes()方法去模拟python2对bytes的轮询
|
||||
|
||||
if len(decrypted_bytes) > 0 and list(six.iterbytes(decrypted_bytes))[0] == 1:
|
||||
try:
|
||||
raw_info = decrypted_bytes[decrypted_bytes.find(b'\x00')+1:]
|
||||
except Exception as e:
|
||||
raise e
|
||||
return raw_info.decode("utf-8")
|
||||
raw_info = decrypted_bytes[decrypted_bytes.find(b'\x00') + 1:]
|
||||
return raw_info.decode("utf-8")
|
||||
|
||||
def decrypt(self) -> str:
|
||||
|
||||
|
||||
@@ -14,12 +14,10 @@ import java.util.Map;
|
||||
|
||||
public final class SystemVariables {
|
||||
|
||||
private Map<String, String> globalVariables;
|
||||
private Map<String, String> sessionVariables;
|
||||
private volatile boolean lowerCase = true;
|
||||
|
||||
public SystemVariables() {
|
||||
globalVariables = new HashMap<>();
|
||||
sessionVariables = new HashMap<>();
|
||||
pickSessionVariables();
|
||||
}
|
||||
@@ -218,8 +216,6 @@ public final class SystemVariables {
|
||||
}
|
||||
} else if ("lower_case_table_names".equals(key)) {
|
||||
lowerCase = !value.equals("0");
|
||||
} else {
|
||||
globalVariables.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,9 @@ public class MySQLResponseService extends BackendService {
|
||||
|
||||
if (!expectAutocommit && xaTxID != null && xaStatus == TxState.TX_INITIALIZE_STATE && !isDDL) {
|
||||
// clientTxIsolation = Isolation.SERIALIZABLE;TODO:NEEDED?
|
||||
XaDelayProvider.delayBeforeXaStart(rrn.getName(), xaTxID);
|
||||
if (rrn != null) {
|
||||
XaDelayProvider.delayBeforeXaStart(rrn.getName(), xaTxID);
|
||||
}
|
||||
if (sb == null) {
|
||||
sb = new StringBuilder(10);
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2022 ActionTech.
|
||||
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
|
||||
*/
|
||||
package com.actiontech.dble.mysql;
|
||||
|
||||
import com.actiontech.dble.util.FormatUtil;
|
||||
import com.actiontech.dble.util.SplitUtil;
|
||||
|
||||
/**
|
||||
* @author mycat
|
||||
*/
|
||||
public class ResultSetPacketParse {
|
||||
|
||||
public static String parse(String src) {
|
||||
String[] sa = SplitUtil.split(src, ',', true);
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < sa.length; ) {
|
||||
int length = Byte.parseByte(sa[i++]) & 0xff;
|
||||
length |= (Byte.parseByte(sa[i++]) & 0xff) << 8;
|
||||
length |= (Byte.parseByte(sa[i++]) & 0xff) << 16;
|
||||
s.append("Length=").append(FormatUtil.format(length, 3)).append(',');
|
||||
s.append("Id=").append(Byte.parseByte(sa[i++])).append(':');
|
||||
for (int x = 0; x < length; x++) {
|
||||
s.append(' ').append(sa[i++]);
|
||||
}
|
||||
s.append('\n');
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
static String s = "1, 0, 0, 1, 1, 68, 0, 0, 2, 3, 100, 101, 102, 22, 99, 111, 98, 97, 114, 95, 116, 101, 115, 116, 95, 99, 111, 110, 110, 95, 98, 105, 110, 100, 95, 49, 2, 116, 49, 2, 116, 49, 10, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 10, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 12, 63, 0, 11, 0, 0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 3, -2, 0, 0, 34, 0, 4, 0, 0, 4, 3, 49, 50, 51, 46, 0, 0, 5, -1, 30, 4, 85, 110, 107, 110, 111, 119, 110, 32, 99, 111, 108, 117, 109, 110, 32, 39, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 39, 32, 105, 110, 32, 39, 102, 105, 101, 108, 100, 32, 108, 105, 115, 116, 39";
|
||||
static String s2 = "1, 0, 0, 1, 1, 68, 0, 0, 2, 3, 100, 101, 102, 22, 99, 111, 98, 97, 114, 95, 116, 101, 115, 116, 95, 99, 111, 110, 110, 95, 98, 105, 110, 100, 95, 49, 2, 116, 49, 2, 116, 49, 10, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 10, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 12, 63, 0, 11, 0, 0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 3, -2, 0, 0, 34, 0, 4, 0, 0, 4, 3, 49, 50, 51, 4, 0, 0, 5, 3, 49, 50, 51, 46, 0, 0, 6, -1, 30, 4, 85, 110, 107, 110, 111, 119, 110, 32, 99, 111, 108, 117, 109, 110, 32, 39, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 39, 32, 105, 110, 32, 39, 102, 105, 101, 108, 100, 32, 108, 105, 115, 116, 39";
|
||||
static String s3 = "1, 0, 0, 1, 1, 46, 0, 0, 1, -1, 30, 4, 85, 110, 107, 110, 111, 119, 110, 32, 99, 111, 108, 117, 109, 110, 32, 39, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 39, 32, 105, 110, 32, 39, 102, 105, 101, 108, 100, 32, 108, 105, 115, 116, 39";
|
||||
static String s4 = "1, 0, 0, 1, 1, 68, 0, 0, 2, 3, 100, 101, 102, 22, 99, 111, 98, 97, 114, 95, 116, 101, 115, 116, 95, 99, 111, 110, 110, 95, 98, 105, 110, 100, 95, 49, 2, 116, 49, 2, 116, 49, 10, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 10, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 12, 63, 0, 11, 0, 0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 3, -2, 0, 0, 34, 0, 4, 0, 0, 4, 3, 49, 50, 51, 4, 0, 0, 5, 3, 49, 50, 51, 46, 0, 0, 6, -1, 30, 4, 85, 110, 107, 110, 111, 119, 110, 32, 99, 111, 108, 117, 109, 110, 32, 39, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 39, 32, 105, 110, 32, 39, 102, 105, 101, 108, 100, 32, 108, 105, 115, 116, 39";
|
||||
static String s5 = "1, 0, 0, 1, 1, 1, 0, 0, 2, 1, 46, 0, 0, 3, -1, 30, 4, 85, 110, 107, 110, 111, 119, 110, 32, 99, 111, 108, 117, 109, 110, 32, 39, 114, 101, 97, 100, 69, 114, 114, 67, 111, 108, 39, 32, 105, 110, 32, 39, 102, 105, 101, 108, 100, 32, 108, 105, 115, 116, 39";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(ResultSetPacketParse.parse(s));
|
||||
System.out.println(ResultSetPacketParse.parse(s2));
|
||||
System.out.println(ResultSetPacketParse.parse(s3));
|
||||
System.out.println(ResultSetPacketParse.parse(s4));
|
||||
System.out.println(ResultSetPacketParse.parse(s5));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2022 ActionTech.
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
|
||||
*/
|
||||
|
||||
package com.actiontech.dble.sequence;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* SequenceTest
|
||||
*
|
||||
* @author Hash Zhang
|
||||
* @version 1.0
|
||||
* @time 00:12:05 2016/5/6
|
||||
*/
|
||||
public class SequenceTest {
|
||||
private Set<String> sequenceSet;
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
sequenceSet = new TreeSet<>();
|
||||
startTime = System.nanoTime();
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testIncrement(){
|
||||
// System.out.print("Increment ");
|
||||
// for (int i = 0; i < 1000000; i++) {
|
||||
// sequenceSet.add(i+"");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@Test
|
||||
public void testUUID() {
|
||||
System.out.print("UUID ");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
sequenceSet.add(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandom() {
|
||||
TreeSet<String> treeSet = new TreeSet<>();
|
||||
System.out.println(Long.toBinaryString(Long.parseLong(System.currentTimeMillis() + "")).length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandom2() {
|
||||
System.out.print("UUID ");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
sequenceSet.add("aaassscccddd" + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void end() {
|
||||
endTime = System.nanoTime();
|
||||
System.out.println("Time elapsed: " + (endTime - startTime) / (1000000L) + "ms");
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2022 ActionTech.
|
||||
* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
|
||||
*/
|
||||
package com.actiontech.dble.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author mycat
|
||||
*/
|
||||
public class HashMapMain {
|
||||
|
||||
public void t() {
|
||||
String[] keys = new String[]{"a", "b", "c", "d", "e"};
|
||||
long t = System.currentTimeMillis();
|
||||
int count = 1000000;
|
||||
Map<String, String> m = new HashMap<String, String>();
|
||||
t = System.currentTimeMillis();
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (String key : keys) {
|
||||
m.put(key, "String.value");
|
||||
}
|
||||
for (String key : keys) {
|
||||
m.remove(key);
|
||||
}
|
||||
}
|
||||
System.out.println((System.currentTimeMillis() - t) * 1000 * 1000 / (count * keys.length * 2) + " ns");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user