proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/index/standard/IndexKeyType.java | IndexKeyType | getMemory | class IndexKeyType extends ValueDataType {
public IndexKeyType(DataHandler handler, CompareMode compareMode, int[] sortTypes) {
super(handler, compareMode, sortTypes);
}
@Override
public int compare(Object a, Object b) {
if (a == b) {
return 0;
}
if (a == nu... |
IndexKey k = (IndexKey) obj;
int memory = 4;
if (k == null)
return memory;
Value[] columns = k.columns;
for (int i = 0, len = columns.length; i < len; i++) {
Value c = columns[i];
if (c == null)
memory += 4;
else
... | 291 | 111 | 402 | <methods>public void <init>(com.lealone.db.DataHandler, com.lealone.db.value.CompareMode, int[]) ,public int compare(java.lang.Object, java.lang.Object) ,public int compareValues(com.lealone.db.value.Value[], com.lealone.db.value.Value[]) ,public boolean equals(java.lang.Object) ,public int getMemory(java.lang.Object) ... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/index/standard/StandardDelegateIndex.java | StandardDelegateIndex | find | class StandardDelegateIndex extends StandardIndex {
private final StandardPrimaryIndex mainIndex;
public StandardDelegateIndex(StandardPrimaryIndex mainIndex, StandardTable table, int id,
String name, IndexType indexType) {
super(table, id, name, indexType,
IndexColumn.wrap... |
ValueLong min = mainIndex.getKey(first, StandardPrimaryIndex.MIN, StandardPrimaryIndex.MIN);
// ifNull is MIN_VALUE as well, because the column is never NULL
// so avoid returning all rows (returning one row is OK)
ValueLong max = mainIndex.getKey(last, StandardPrimaryIndex.MAX, Standar... | 633 | 103 | 736 | <methods>public boolean canGetFirstOrLast() ,public void close(com.lealone.db.session.ServerSession) <variables> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/index/standard/ValueDataType.java | ValueDataType | compareValue | class ValueDataType implements StorageDataType {
final DataHandler handler;
final CompareMode compareMode;
final int[] sortTypes;
public ValueDataType(DataHandler handler, CompareMode compareMode, int[] sortTypes) {
this.handler = handler;
this.compareMode = compareMode;
this.s... |
if (a == b) {
return 0;
}
// null is never stored;
// comparison with null is used to retrieve all entries
// in which case null is always lower than all entries
// (even for descending ordered indexes)
if (a == null) {
return -1;
... | 894 | 205 | 1,099 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/index/standard/VersionedValue.java | VersionedValue | toString | class VersionedValue {
public final int version; // 表的元数据版本号
public final Value[] columns;
public VersionedValue(int version, Value[] columns) {
this.version = version;
this.columns = columns;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
} |
// StringBuilder buff = new StringBuilder("VersionedValue[ ");
// buff.append("version = ").append(version);
// buff.append(", columns = ").append(Arrays.toString(columns)).append(" ]");
return Arrays.toString(columns);
| 92 | 69 | 161 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/index/standard/VersionedValueType.java | VersionedValueType | getMemory | class VersionedValueType extends ValueDataType {
final int columnCount;
final EnumColumn[] enumColumns;
public VersionedValueType(DataHandler handler, CompareMode compareMode, int[] sortTypes,
int columnCount) {
this(handler, compareMode, sortTypes, columnCount, null);
}
publi... |
VersionedValue v = (VersionedValue) obj;
Value[] columns = v.columns;
if (columnIndex >= 0 && columnIndex < columns.length) {
return columns[columnIndex].getMemory();
} else {
return 0;
}
| 1,228 | 69 | 1,297 | <methods>public void <init>(com.lealone.db.DataHandler, com.lealone.db.value.CompareMode, int[]) ,public int compare(java.lang.Object, java.lang.Object) ,public int compareValues(com.lealone.db.value.Value[], com.lealone.db.value.Value[]) ,public boolean equals(java.lang.Object) ,public int getMemory(java.lang.Object) ... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/lock/DbObjectLock.java | DbObjectLock | unlock | class DbObjectLock extends Lock {
public static final RuntimeException LOCKED_EXCEPTION = new RuntimeException();
private final DbObjectType type;
private ArrayList<AsyncHandler<AsyncResult<Boolean>>> handlers;
public DbObjectLock(DbObjectType type) {
this.type = type;
}
@Override
... |
if (handlers != null) {
handlers.forEach(h -> {
h.handle(new AsyncResult<>(succeeded));
});
handlers = null;
}
unlock(oldSession, newSession);
| 296 | 65 | 361 | <methods>public non-sealed void <init>() ,public int addWaitingTransaction(java.lang.Object, com.lealone.transaction.Transaction, com.lealone.db.session.Session) ,public com.lealone.db.lock.LockOwner getLockOwner() ,public abstract java.lang.String getLockType() ,public java.lang.Object getOldValue() ,public com.lealon... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/result/Row.java | Row | setValue | class Row extends SimpleRow {
public static final int MEMORY_CALCULATE = -1;
private ITransactionalValue tv;
private IPage page;
public Row(Value[] data, int memory) {
super(data);
this.memory = memory;
}
public Value[] getValueList() {
return data;
}
public ... |
if (i == -1) {
key = v.getLong();
} else {
data[i] = v;
}
| 256 | 39 | 295 | <methods>public void <init>(com.lealone.db.value.Value[]) ,public int getColumnCount() ,public int getMemory() ,public com.lealone.db.value.Value getValue(int) ,public void setValue(int, com.lealone.db.value.Value) ,public java.lang.String toString() <variables>protected final non-sealed com.lealone.db.value.Value[] da... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/result/SimpleRow.java | SimpleRow | toString | class SimpleRow extends RowBase {
protected final Value[] data;
public SimpleRow(Value[] data) {
this.data = data;
}
@Override
public int getColumnCount() {
return data.length;
}
@Override
public Value getValue(int index) {
return data[index];
}
@Over... |
StatementBuilder buff = new StatementBuilder("( /* key:");
buff.append(getKey());
if (version != 0) {
buff.append(" v:" + version);
}
buff.append(" */ ");
if (data != null) {
for (Value v : data) {
buff.appendExceptFirst(", ");
... | 302 | 129 | 431 | <methods>public non-sealed void <init>() ,public long getKey() ,public int getVersion() ,public void setKey(long) ,public void setVersion(int) <variables>protected long key,protected int memory,protected int version |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/result/SimpleRowValue.java | SimpleRowValue | getMemory | class SimpleRowValue extends RowBase {
private final int virtualColumnCount;
private int index;
private Value data;
public SimpleRowValue(int columnCount) {
this.virtualColumnCount = columnCount;
}
@Override
public int getColumnCount() {
return virtualColumnCount;
}
... |
if (memory == 0) {
memory = Constants.MEMORY_OBJECT + (data == null ? 0 : data.getMemory());
}
return memory;
| 222 | 46 | 268 | <methods>public non-sealed void <init>() ,public long getKey() ,public int getVersion() ,public void setKey(long) ,public void setVersion(int) <variables>protected long key,protected int memory,protected int version |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/result/SortOrder.java | SortOrder | sort | class SortOrder implements Comparator<Value[]> {
/**
* This bit mask means the values should be sorted in ascending order.
*/
public static final int ASCENDING = 0;
/**
* This bit mask means the values should be sorted in descending order.
*/
public static final int DESCENDING = 1;... |
int rowsSize = rows.size();
if (rows.isEmpty() || offset >= rowsSize || limit == 0) {
return;
}
if (offset < 0) {
offset = 0;
}
if (offset + limit > rowsSize) {
limit = rowsSize - offset;
}
if (limit == 1 && offset == 0... | 1,755 | 200 | 1,955 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/schema/UserAggregate.java | UserAggregate | getInstance | class UserAggregate extends SchemaObjectBase {
private final String className;
private Class<?> javaClass;
public UserAggregate(Schema schema, int id, String name, String className, boolean force) {
super(schema, id, name);
this.className = className;
if (!force) {
getI... |
if (javaClass == null) {
javaClass = Utils.loadUserClass(className);
}
try {
return Utils.newInstance(javaClass);
} catch (Exception e) {
throw DbException.convert(e);
}
| 279 | 69 | 348 | <methods>public java.lang.String getSQL() ,public com.lealone.db.schema.Schema getSchema() ,public boolean isHidden() <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/service/JavaServiceExecutor.java | JavaServiceExecutor | init | class JavaServiceExecutor extends ServiceExecutorBase {
private final Service service;
private Map<String, Method> objectMethodMap;
private Object implementClassObject;
public JavaServiceExecutor(Service service) {
this.service = service;
}
// 第一次调用时再初始化,否则会影响启动时间
private void ini... |
if (implementClassObject != null)
return;
Class<?> implementClass;
try {
implementClass = Class.forName(service.getImplementBy());
implementClassObject = implementClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw ... | 481 | 631 | 1,112 | <methods>public non-sealed void <init>() <variables>protected Map<java.lang.String,com.lealone.db.service.ServiceMethod> serviceMethodMap |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/service/Service.java | Service | execute | class Service extends SchemaObjectBase {
private String language;
private String packageName;
private String implementBy;
private final String sql;
private final String serviceExecutorClassName;
private final List<ServiceMethod> serviceMethods;
private ServiceExecutor executor;
private... |
String[] a = StringUtils.arraySplit(serviceName, '.');
if (a.length == 4) {
Database db = LealoneDatabase.getInstance().getDatabase(a[0]);
String methodName = a[3];
if (db.getSettings().databaseToUpper) {
methodName = methodName.toUpperCase();
... | 1,227 | 160 | 1,387 | <methods>public java.lang.String getSQL() ,public com.lealone.db.schema.Schema getSchema() ,public boolean isHidden() <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/service/ServiceExecutorBase.java | ServiceExecutorBase | getServiceMethodArg | class ServiceExecutorBase implements ServiceExecutor {
protected Map<String, ServiceMethod> serviceMethodMap;
protected Object[] getServiceMethodArgs(String methodName, Value[] methodArgs) {
Object[] args = new Object[methodArgs.length];
// 如果没有定义服务方法,直接把传递进来的方法参数转成对象
if (serviceMethod... |
Object arg = null;
switch (type) {
case Value.BOOLEAN:
arg = v.getBoolean();
break;
case Value.BYTE:
arg = v.getByte();
break;
case Value.SHORT:
arg = v.getShort();
break;
case Value.INT:
... | 1,182 | 484 | 1,666 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/session/ServerSessionFactory.java | ServerSessionFactory | initDatabase | class ServerSessionFactory extends SessionFactoryBase {
private static final ServerSessionFactory instance = new ServerSessionFactory();
public static ServerSessionFactory getInstance() {
return instance;
}
@Override
public Future<Session> createSession(ConnectionInfo ci, boolean allowRed... |
SchedulerLock schedulerLock = database.getSchedulerLock();
if (schedulerLock.tryLock(SchedulerThread.currentScheduler())) {
try {
// sharding模式下访问remote page时会用到
database.setLastConnectionInfo(ci);
database.init();
} finally {
... | 934 | 105 | 1,039 | <methods>public void <init>() ,public Class<? extends com.lealone.db.Plugin> getPluginClass() <variables> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/stat/QueryStatisticsData.java | QueryStatisticsData | getQueries | class QueryStatisticsData {
private static final Comparator<QueryEntry> QUERY_ENTRY_COMPARATOR = Comparator
.comparingLong(q -> q.lastUpdateTime);
private final HashMap<String, QueryEntry> map = new HashMap<>();
private int maxQueryEntries;
public QueryStatisticsData(int maxQueryEntries)... |
// return a copy of the map so we don't have to
// worry about external synchronization
ArrayList<QueryEntry> list = new ArrayList<>(map.values());
// only return the newest 100 entries
list.sort(QUERY_ENTRY_COMPARATOR);
return list.subList(0, Math.min(list.size(), maxQu... | 1,397 | 95 | 1,492 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/CreateTableData.java | CreateTableData | isMemoryTable | class CreateTableData {
/**
* The schema.
*/
public Schema schema;
/**
* The table name.
*/
public String tableName;
/**
* The object id.
*/
public int id;
/**
* The column list.
*/
public ArrayList<Column> columns = new ArrayList<>();
/**... |
return !session.getDatabase().isPersistent() || globalTemporary || temporary || !persistData
|| id < 0;
| 346 | 34 | 380 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/MetaTable.java | MetaTable | add | class MetaTable extends Table {
/**
* The approximate number of rows of a meta table.
*/
public static final long ROW_COUNT_APPROXIMATION = 1000;
protected final int type;
protected final int indexColumn;
protected final MetaIndex metaIndex;
/**
* Create a new metadata table.
... |
Value[] values = new Value[strings.length];
for (int i = 0; i < strings.length; i++) {
String s = strings[i];
Value v = (s == null) ? (Value) ValueNull.INSTANCE : ValueString.get(s);
Column col = columns[i];
v = col.convert(v);
values[i] = v;
... | 1,045 | 134 | 1,179 | <methods>public void <init>(com.lealone.db.schema.Schema, int, java.lang.String, boolean, boolean) ,public void addConstraint(com.lealone.db.constraint.Constraint) ,public void addDependencies(Set<com.lealone.db.DbObject>) ,public com.lealone.db.index.Index addIndex(com.lealone.db.session.ServerSession, java.lang.Strin... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/PerfMetaTable.java | PerfMetaTable | generateRows | class PerfMetaTable extends MetaTable {
private static final int QUERY_STATISTICS = 0;
public static int getMetaTableTypeCount() {
return QUERY_STATISTICS + 1;
}
public PerfMetaTable(Schema schema, int id, int type) {
super(schema, id, type);
}
@Override
public String cre... |
ArrayList<Row> rows = Utils.newSmallArrayList();
switch (type) {
case QUERY_STATISTICS: {
QueryStatisticsData statData = database.getQueryStatisticsData();
if (statData != null) {
for (QueryStatisticsData.QueryEntry entry : statData.getQueries()) {
... | 398 | 469 | 867 | <methods>public void <init>(com.lealone.db.schema.Schema, int, int) ,public boolean canDrop() ,public boolean canGetRowCount() ,public boolean canReference() ,public abstract java.lang.String createColumns() ,public transient com.lealone.db.table.Column[] createColumns(java.lang.String[]) ,public abstract ArrayList<com... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/RangeTable.java | RangeTable | getScanIndex | class RangeTable extends Table {
/**
* The name of the range table.
*/
public static final String NAME = "SYSTEM_RANGE";
/**
* The PostgreSQL alias for the range table.
*/
public static final String ALIAS = "GENERATE_SERIES";
private IExpression min, max, step;
private boo... |
if (getStep(session) == 0) {
throw DbException.get(ErrorCode.STEP_SIZE_MUST_NOT_BE_ZERO);
}
return new RangeIndex(this, IndexColumn.wrap(columns));
| 967 | 63 | 1,030 | <methods>public void <init>(com.lealone.db.schema.Schema, int, java.lang.String, boolean, boolean) ,public void addConstraint(com.lealone.db.constraint.Constraint) ,public void addDependencies(Set<com.lealone.db.DbObject>) ,public com.lealone.db.index.Index addIndex(com.lealone.db.session.ServerSession, java.lang.Strin... |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/TableAlterHistory.java | TableAlterHistory | getRecords | class TableAlterHistory {
private PreparedStatement psGetVersion;
private PreparedStatement psGetRecords;
private PreparedStatement psAddRecord;
private PreparedStatement psDeleteRecords;
// 执行DROP DATABASE时调用这个方法,避免在删掉table_alter_history后还读它
public void cleanPreparedStatements() {
psG... |
ArrayList<TableAlterHistoryRecord> records = new ArrayList<>();
if (psGetRecords == null)
return records;
try {
psGetRecords.setInt(1, id);
psGetRecords.setInt(2, versionMin);
psGetRecords.setInt(3, versionMax);
ResultSet rs = psGetRec... | 912 | 191 | 1,103 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/TableAlterHistoryRecord.java | TableAlterHistoryRecord | redo | class TableAlterHistoryRecord {
// private final int id;
// private final int version;
private final int alterType;
private final String columns;
public TableAlterHistoryRecord(int id, int version, int alterType, String columns) {
// this.id = id;
// this.version = version;
... |
if (alterType == SQLStatement.ALTER_TABLE_DROP_COLUMN) {
int position = Integer.parseInt(columns);
int len = values.length;
if (len == 1)
return new Value[0];
Value[] newValues = new Value[len - 1];
System.arraycopy(values, 0, newValue... | 135 | 539 | 674 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/table/TableAnalyzer.java | TableAnalyzer | analyzeIfRequired | class TableAnalyzer {
private final Table table;
private final AtomicBoolean analyzing = new AtomicBoolean();
private int nextAnalyze;
private int changesSinceAnalyze;
public TableAnalyzer(Table table, int nextAnalyze) {
this.table = table;
this.nextAnalyze = nextAnalyze;
}
... |
if (nextAnalyze > changesSinceAnalyze++) {
return;
}
if (analyzing.compareAndSet(false, true)) {
changesSinceAnalyze = 0;
int n = 2 * nextAnalyze;
if (n > 0) {
nextAnalyze = n;
}
int rows = session.getDataba... | 904 | 139 | 1,043 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/util/HashBase.java | HashBase | reset | class HashBase {
private static final int MAX_LOAD = 90;
/**
* The bit mask to get the index from the hash code.
*/
protected int mask;
/**
* The number of slots in the table.
*/
protected int len;
/**
* The number of occupied slots, excluding the zero key (if any).
... |
minSize = size * 3 / 4;
size = 0;
level = newLevel;
len = 2 << level;
mask = len - 1;
maxSize = (int) (len * MAX_LOAD / 100L);
deletedCount = 0;
maxDeleted = 20 + len / 2;
| 611 | 88 | 699 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/util/IntArray.java | IntArray | removeRange | class IntArray {
private int[] data;
private int size;
private int hash;
/**
* Create an int array with the default initial capacity.
*/
public IntArray() {
this(10);
}
/**
* Create an int array with specified initial capacity.
*
* @param capacity the init... |
if (SysProperties.CHECK) {
if (fromIndex > toIndex || toIndex > size) {
throw new ArrayIndexOutOfBoundsException(
"from=" + fromIndex + " to=" + toIndex + " size=" + size);
}
}
System.arraycopy(data, toIndex, data, fromIndex, size ... | 1,092 | 105 | 1,197 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/util/IntIntHashMap.java | IntIntHashMap | put | class IntIntHashMap extends HashBase {
/**
* The value indicating that the entry has not been found.
*/
public static final int NOT_FOUND = -1;
private static final int DELETED = 1;
private int[] keys;
private int[] values;
private int zeroValue;
@Override
protected void res... |
if (key == 0) {
zeroKey = true;
zeroValue = value;
return;
}
checkSizePut();
int index = getIndex(key);
int plus = 1;
int deleted = -1;
do {
int k = keys[index];
if (k == 0) {
if (values[... | 734 | 263 | 997 | <methods>public void <init>() ,public int size() <variables>private static final int MAX_LOAD,protected int deletedCount,protected int len,protected int level,protected int mask,private int maxDeleted,private int maxSize,private int minSize,protected int size,protected boolean zeroKey |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/util/SourceCompiler.java | SCJavaFileManager | getJavaFileForOutput | class SCJavaFileManager extends ForwardingJavaFileManager<JavaFileManager> {
private final ClassLoader classLoader;
protected SCJavaFileManager(JavaFileManager fileManager, ClassLoader classLoader) {
super(fileManager);
this.classLoader = classLoader;
}
@Overri... |
if (sibling != null && sibling instanceof SCJavaFileObject) {
return ((SCJavaFileObject) sibling).addOutputJavaFile(className);
}
throw new IOException(
"The source file passed to getJavaFileForOutput() is not a SCJavaFileObject: "
... | 207 | 80 | 287 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/util/SynchronizedVerifier.java | SynchronizedVerifier | detectConcurrentAccess | class SynchronizedVerifier {
private static volatile boolean enabled;
private static final Map<Class<?>, AtomicBoolean> DETECT = Collections
.synchronizedMap(new HashMap<Class<?>, AtomicBoolean>());
private static final Map<Object, Object> CURRENT = Collections
.synchronizedMap(new ... |
AtomicBoolean value = DETECT.get(o.getClass());
if (value != null) {
value.set(true);
if (CURRENT.remove(o) != null) {
throw new AssertionError("Concurrent access");
}
CURRENT.put(o, o);
try {
Thread.sleep(1);
... | 375 | 152 | 527 | <no_super_class> |
lealone_Lealone | Lealone/lealone-db/src/main/java/com/lealone/db/util/ValueHashMap.java | ValueHashMap | put | class ValueHashMap<V> extends HashBase {
private Value[] keys;
private V[] values;
/**
* Create a new value hash map.
*
* @return the object
*/
public static <T> ValueHashMap<T> newInstance() {
return new ValueHashMap<T>();
}
@Override
@SuppressWarnings("unchec... |
checkSizePut();
int index = getIndex(key);
int plus = 1;
int deleted = -1;
do {
Value k = keys[index];
if (k == null) {
// found an empty record
if (deleted >= 0) {
index = deleted;
d... | 990 | 233 | 1,223 | <methods>public void <init>() ,public int size() <variables>private static final int MAX_LOAD,protected int deletedCount,protected int len,protected int level,protected int mask,private int maxDeleted,private int maxSize,private int minSize,protected int size,protected boolean zeroKey |
lealone_Lealone | Lealone/lealone-main/src/main/java/com/lealone/main/Shell.java | Shell | getConnection | class Shell extends LealoneClient {
public static void main(String[] args) {
Shell shell = new Shell(args);
main(shell);
}
public Shell(String[] args) {
super(args);
}
@Override
protected Connection getConnection() throws SQLException {<FILL_FUNCTION_BODY>}
} |
ConnectionInfo ci = getConnectionInfo();
if (ci.isEmbedded()) {
Lealone.embed();
}
return getConnectionSync(ci);
| 90 | 45 | 135 | <methods>public void <init>(java.lang.String[]) ,public java.lang.String[] getArgs() ,public static Future<com.lealone.client.jdbc.JdbcConnection> getConnection(java.lang.String) ,public static Future<com.lealone.client.jdbc.JdbcConnection> getConnection(java.lang.String, java.lang.String, java.lang.String) ,public sta... |
lealone_Lealone | Lealone/lealone-main/src/main/java/com/lealone/main/config/Config.java | Config | mergeEngines | class Config {
public String base_dir = "." + File.separator + Constants.PROJECT_NAME + "_data";
public String listen_address = "127.0.0.1";
public List<PluggableEngineDef> storage_engines;
public List<PluggableEngineDef> transaction_engines;
public List<PluggableEngineDef> sql_engines;
publi... |
if (defaultList == null)
return newList;
if (newList == null)
return defaultList;
LinkedHashMap<String, PluggableEngineDef> map = new LinkedHashMap<>();
for (PluggableEngineDef e : defaultList) {
map.put(e.name.toUpperCase(), e);
}
for... | 1,418 | 202 | 1,620 | <no_super_class> |
lealone_Lealone | Lealone/lealone-main/src/main/java/com/lealone/main/config/YamlConfigLoader.java | YamlConfigLoader | isYamlAvailable | class YamlConfigLoader implements ConfigLoader {
private static final Logger logger = LoggerFactory.getLogger(YamlConfigLoader.class);
private static URL getConfigURL() throws ConfigException {
String configUrl = Config.getProperty("config");
if (configUrl != null) {
URL url = getC... |
try {
Class.forName("org.yaml.snakeyaml.Yaml");
return true;
} catch (Exception e) {
return false;
}
| 895 | 49 | 944 | <no_super_class> |
lealone_Lealone | Lealone/lealone-main/src/main/java/com/lealone/main/config/YamlConstructor.java | ConstructEnv | construct | class ConstructEnv extends AbstractConstruct {
@Override
public Object construct(Node node) {<FILL_FUNCTION_BODY>}
} |
String val = constructScalar((ScalarNode) node);
Matcher matcher = ENV_FORMAT.matcher(val);
matcher.matches();
String name = matcher.group("name");
String value = matcher.group("value");
String separator = matcher.group("separator");
S... | 37 | 136 | 173 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/AsyncConnection.java | AsyncConnection | close | class AsyncConnection {
protected final WritableChannel writableChannel;
protected final boolean isServer;
protected InetSocketAddress inetSocketAddress;
protected boolean closed;
public AsyncConnection(WritableChannel writableChannel, boolean isServer) {
this.writableChannel = writableCha... |
closed = true;
if (writableChannel != null) {
writableChannel.close();
}
| 463 | 32 | 495 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/AsyncConnectionPool.java | AsyncConnectionPool | getConnection | class AsyncConnectionPool {
private final List<AsyncConnection> list;
public AsyncConnectionPool(boolean isThreadSafe) {
list = isThreadSafe ? new ArrayList<>() : new CopyOnWriteArrayList<>();
}
public AsyncConnection getConnection(Map<String, String> config) {<FILL_FUNCTION_BODY>}
publi... |
if (!isShared(config)) {
// 专用连接如果空闲了也可以直接复用
for (AsyncConnection c : list) {
if (c.getMaxSharedSize() == 1 && c.getSharedSize() == 0)
return c;
}
return null;
}
AsyncConnection best = null;
int min = In... | 381 | 200 | 581 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/NetBuffer.java | NetBuffer | length | class NetBuffer {
private final DataBuffer dataBuffer;
private boolean onlyOnePacket;
private boolean forWrite;
public NetBuffer(DataBuffer dataBuffer) {
this.dataBuffer = dataBuffer;
this.forWrite = true;
}
public NetBuffer(DataBuffer dataBuffer, boolean onlyOnePacket) {
... |
if (forWrite)
return dataBuffer.position();
if (onlyOnePacket)
return dataBuffer.limit();
int pos = dataBuffer.position();
if (pos > 0)
return pos;
else
return dataBuffer.limit();
| 473 | 69 | 542 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/NetBufferOutputStream.java | NetBufferOutputStream | flush | class NetBufferOutputStream extends OutputStream {
protected final WritableChannel writableChannel;
protected final int initialSizeHint;
protected final DataBufferFactory dataBufferFactory;
protected NetBuffer buffer;
public NetBufferOutputStream(WritableChannel writableChannel, int initialSizeHin... |
buffer.flip();
if (reset) {
NetBuffer old = buffer;
reset();
writableChannel.write(old);
// 警告: 不能像下面这样用,调用write后会很快写数据到接收端,然后另一个线程很快又收到响应,
// 在调用reset前又继续用原来的buffer写,从而导致产生非常难找的协议与并发问题,我就为这个问题痛苦排查过大半天。
// writableChannel.write(buf... | 279 | 158 | 437 | <methods>public void <init>() ,public void close() throws java.io.IOException,public void flush() throws java.io.IOException,public static java.io.OutputStream nullOutputStream() ,public abstract void write(int) throws java.io.IOException,public void write(byte[]) throws java.io.IOException,public void write(byte[], in... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/NetClientBase.java | NetClientBase | initSocket | class NetClientBase implements NetClient {
// 使用InetSocketAddress为key而不是字符串,是因为像localhost和127.0.0.1这两种不同格式实际都是同一个意思,
// 如果用字符串,就会产生两条AsyncConnection,这是没必要的。
private final Map<InetSocketAddress, AsyncConnectionPool> asyncConnections;
private final AtomicBoolean closed = new AtomicBoolean(false);
pri... |
int socketRecvBuffer = MapUtils.getInt(config, ConnectionSetting.SOCKET_RECV_BUFFER_SIZE.name(),
16 * 1024);
int socketSendBuffer = MapUtils.getInt(config, ConnectionSetting.SOCKET_SEND_BUFFER_SIZE.name(),
8 * 1024);
socket.setReceiveBufferSize(socketRecvBuffer);... | 1,022 | 151 | 1,173 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/NetScheduler.java | NetScheduler | runEventLoop | class NetScheduler extends SchedulerBase {
protected final NetEventLoop netEventLoop;
public NetScheduler(int id, String name, int schedulerCount, Map<String, String> config,
boolean isThreadSafe) {
super(id, name, schedulerCount, config);
netEventLoop = NetFactory.getFactory(confi... |
try {
netEventLoop.write();
netEventLoop.select();
netEventLoop.handleSelectedKeys();
} catch (Throwable t) {
getLogger().warn("Failed to runEventLoop", t);
}
| 338 | 61 | 399 | <methods>public void <init>(int, java.lang.String, int, Map<java.lang.String,java.lang.String>) ,public void accept(java.nio.channels.SelectionKey) ,public void addPendingTransaction(com.lealone.transaction.PendingTransaction) ,public void addPeriodicTask(com.lealone.db.async.AsyncPeriodicTask) ,public void addSession(... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/NetServerBase.java | NetServerBase | checkBindException | class NetServerBase extends ProtocolServerBase implements NetServer {
protected AsyncConnectionManager connectionManager;
@Override
public void setConnectionManager(AsyncConnectionManager connectionManager) {
this.connectionManager = connectionManager;
}
private void check() {
if ... |
String address = host + ":" + port;
if (e instanceof BindException) {
if (e.getMessage().contains("in use")) {
message += ", " + address
+ " is in use by another process. Change host:port in lealone.yaml "
+ "to values that do ... | 205 | 202 | 407 | <methods>public boolean allow(java.lang.String) ,public boolean getAllowOthers() ,public java.lang.String getBaseDir() ,public Map<java.lang.String,java.lang.String> getConfig() ,public java.lang.String getHost() ,public java.lang.String getName() ,public int getPort() ,public com.lealone.common.security.EncryptionOpti... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/TcpClientConnection.java | TcpClientConnection | handleResponse | class TcpClientConnection extends TransferConnection {
private static final Logger logger = LoggerFactory.getLogger(TcpClientConnection.class);
private final Map<Integer, Session> sessions;
private final Map<Integer, AsyncCallback<?>> callbackMap;
private final AtomicInteger nextId = new AtomicInteger... |
checkClosed();
String newTargetNodes = null;
Session session = null;
DbException e = null;
if (status == Session.STATUS_OK) {
// ok
} else if (status == Session.STATUS_ERROR) {
e = parseError(in);
} else if (status == Session.STATUS_CLOSED... | 931 | 340 | 1,271 | <methods>public void <init>(com.lealone.net.WritableChannel, boolean) ,public com.lealone.net.TransferOutputStream createTransferOutputStream(com.lealone.db.session.Session) ,public com.lealone.db.DataBufferFactory getDataBufferFactory() ,public int getPacketLength() ,public java.nio.ByteBuffer getPacketLengthByteBuffe... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/TransferConnection.java | TransferConnection | parseError | class TransferConnection extends AsyncConnection {
private static final Logger logger = LoggerFactory.getLogger(TransferConnection.class);
protected final ByteBuffer packetLengthByteBuffer = ByteBuffer
.allocate(getPacketLengthByteBufferCapacity());
public TransferConnection(WritableChannel w... |
Throwable t;
try {
String sqlState = in.readString();
String message = in.readString();
String sql = in.readString();
int errorCode = in.readInt();
String stackTrace = in.readString();
JdbcSQLException s = new JdbcSQLException(mess... | 899 | 186 | 1,085 | <methods>public void <init>(com.lealone.net.WritableChannel, boolean) ,public void checkClosed() ,public void checkTimeout(long) ,public void close() ,public java.lang.String getHostAndPort() ,public java.net.InetSocketAddress getInetSocketAddress() ,public int getMaxSharedSize() ,public abstract int getPacketLength() ... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/TransferInputStream.java | DataReader | readChar | class DataReader extends Reader {
private final InputStream in;
/**
* Create a new data reader.
*
* @param in the input stream
*/
public DataReader(InputStream in) {
this.in = in;
}
/**
* Read a byte.
*
... |
int x = readByte() & 0xff;
if (x < 0x80) {
return (char) x;
} else if (x >= 0xe0) {
return (char) (((x & 0xf) << 12) + ((readByte() & 0x3f) << 6) + (readByte() & 0x3f));
} else {
return (char) (((x & 0x1f) << 6) + (readByte... | 301 | 134 | 435 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/bio/BioNetClient.java | BioNetClient | createConnectionInternal | class BioNetClient extends NetClientBase {
public BioNetClient() {
super(true);
}
@Override
protected void createConnectionInternal(Map<String, String> config, NetNode node,
AsyncConnectionManager connectionManager, AsyncCallback<AsyncConnection> ac,
Scheduler scheduler... |
InetSocketAddress inetSocketAddress = node.getInetSocketAddress();
int networkTimeout = MapUtils.getInt(config, ConnectionSetting.NETWORK_TIMEOUT.name(),
Constants.DEFAULT_NETWORK_TIMEOUT);
Socket socket = null;
try {
socket = new Socket();
socket... | 94 | 299 | 393 | <methods>public void <init>(boolean) ,public void addConnection(java.net.InetSocketAddress, com.lealone.net.AsyncConnection) ,public void checkTimeout(long) ,public void close() ,public Future<com.lealone.net.AsyncConnection> createConnection(Map<java.lang.String,java.lang.String>, com.lealone.net.NetNode, com.lealone.... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/bio/BioWritableChannel.java | BioWritableChannel | write | class BioWritableChannel implements WritableChannel {
private final String host;
private final int port;
private final int maxPacketSize;
private Socket socket;
private DataInputStream in;
private DataOutputStream out;
private DataBuffer dataBuffer;
public BioWritableChannel(Map<Stri... |
ByteBuffer bb = data.getByteBuffer();
try {
if (bb.hasArray()) {
out.write(bb.array(), bb.arrayOffset(), bb.limit());
} else {
byte[] bytes = new byte[bb.limit()];
bb.get(bytes);
out.write(bytes);
}
... | 849 | 119 | 968 | <no_super_class> |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/nio/NioNetClient.java | NioNetClient | createConnectionInternal | class NioNetClient extends NetClientBase {
public NioNetClient() {
super(false);
}
@Override
protected void createConnectionInternal(Map<String, String> config, NetNode node, //
AsyncConnectionManager connectionManager, AsyncCallback<AsyncConnection> ac,
Scheduler sched... |
InetSocketAddress inetSocketAddress = node.getInetSocketAddress();
SocketChannel channel = null;
NetEventLoop eventLoop = (NetEventLoop) scheduler.getNetEventLoop();
try {
channel = SocketChannel.open();
channel.configureBlocking(false);
initSocket(ch... | 97 | 300 | 397 | <methods>public void <init>(boolean) ,public void addConnection(java.net.InetSocketAddress, com.lealone.net.AsyncConnection) ,public void checkTimeout(long) ,public void close() ,public Future<com.lealone.net.AsyncConnection> createConnection(Map<java.lang.String,java.lang.String>, com.lealone.net.NetNode, com.lealone.... |
lealone_Lealone | Lealone/lealone-net/src/main/java/com/lealone/net/nio/NioServerAccepter.java | NioServerAccepter | accept | class NioServerAccepter extends NetServerBase {
private static final Logger logger = LoggerFactory.getLogger(NioServerAccepter.class);
private ServerSocketChannel serverChannel;
@Override
public synchronized void start() {
if (isStarted())
return;
super.start();
try... |
SocketChannel channel = null;
AsyncConnection conn = null;
try {
channel = serverChannel.accept();
channel.configureBlocking(false);
NioWritableChannel writableChannel = new NioWritableChannel(channel, null);
conn = createConnection(writableChanne... | 284 | 182 | 466 | <methods>public non-sealed void <init>() ,public com.lealone.net.AsyncConnection createConnection(com.lealone.net.WritableChannel, com.lealone.db.scheduler.Scheduler) ,public void removeConnection(com.lealone.net.AsyncConnection) ,public void setConnectionManager(com.lealone.net.AsyncConnectionManager) <variables>prote... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/AsyncServer.java | AsyncServer | register | class AsyncServer<T extends AsyncConnection> extends DelegatedProtocolServer
implements AsyncConnectionManager {
private final AtomicInteger connectionSize = new AtomicInteger();
private SchedulerFactory schedulerFactory;
private int serverId;
public SchedulerFactory getSchedulerFactory() {
... |
beforeRegister(conn, scheduler);
NetEventLoop eventLoop = (NetEventLoop) scheduler.getNetEventLoop();
writableChannel.setEventLoop(eventLoop); // 替换掉原来的
eventLoop.register(conn);
afterRegister(conn, scheduler);
| 1,017 | 73 | 1,090 | <methods>public non-sealed void <init>() ,public boolean allow(java.lang.String) ,public boolean getAllowOthers() ,public java.lang.String getBaseDir() ,public Map<java.lang.String,java.lang.String> getConfig() ,public java.lang.String getHost() ,public java.lang.String getName() ,public int getPort() ,public com.lealo... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/AsyncServerManager.java | AsyncServerManager | addServer | class AsyncServerManager {
private static final BitField serverIds = new BitField();
private static final ArrayList<AsyncServer<?>> servers = new ArrayList<>(1);
// 注册网络ACCEPT事件,个数会动态增减
private static RegisterAccepterTask[] registerAccepterTasks = new RegisterAccepterTask[1];
public static int all... |
synchronized (servers) {
servers.add(server);
// serverId从0开始
int serverId = server.getServerId();
if (serverId >= registerAccepterTasks.length) {
RegisterAccepterTask[] tasks = new RegisterAccepterTask[serverId + 1];
System.arrayc... | 1,097 | 166 | 1,263 | <no_super_class> |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/BatchStatementPacketHandlers.java | PreparedUpdate | handle | class PreparedUpdate implements PacketHandler<BatchStatementPreparedUpdate> {
@Override
public Packet handle(PacketHandleTask task, BatchStatementPreparedUpdate packet) {<FILL_FUNCTION_BODY>}
} |
ServerSession session = task.session;
int commandId = packet.commandId;
int size = packet.size;
PreparedSQLStatement command = (PreparedSQLStatement) session.getCache(commandId);
List<? extends CommandParameter> params = command.getParameters();
i... | 60 | 306 | 366 | <methods>public non-sealed void <init>() ,public static PacketHandler#RAW getHandler(com.lealone.server.protocol.PacketType) ,public static PacketHandler#RAW getHandler(int) ,public static void register(com.lealone.server.protocol.PacketType, PacketHandler<? extends com.lealone.server.protocol.Packet>) <variables>priva... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/LobPacketHandlers.java | Read | handle | class Read implements PacketHandler<LobRead> {
@Override
public Packet handle(ServerSession session, LobRead packet) {<FILL_FUNCTION_BODY>}
} |
long lobId = packet.lobId;
byte[] hmac = packet.hmac;
long offset = packet.offset;
int length = packet.length;
SmallLRUCache<String, InputStream> lobs = session.getLobCache();
try {
boolean useTableLobStorage = false;
... | 49 | 526 | 575 | <methods>public non-sealed void <init>() ,public static PacketHandler#RAW getHandler(com.lealone.server.protocol.PacketType) ,public static PacketHandler#RAW getHandler(int) ,public static void register(com.lealone.server.protocol.PacketType, PacketHandler<? extends com.lealone.server.protocol.Packet>) <variables>priva... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/PacketHandlers.java | UpdateBase | createYieldableUpdate | class UpdateBase<P extends Packet> implements PacketHandler<P> {
protected void createYieldableUpdate(PacketHandleTask task, PreparedSQLStatement stmt) {<FILL_FUNCTION_BODY>}
protected Packet createAckPacket(PacketHandleTask task, int updateCount) {
return new StatementUpdateAck(updateCoun... |
if (stmt instanceof StatementList) {
StatementListPacketHandlers.updateHandler.createYieldableUpdate(task, stmt);
return;
}
PreparedSQLStatement.Yieldable<?> yieldable = stmt.createYieldableUpdate(ar -> {
if (ar.isSucceeded()) {
... | 97 | 177 | 274 | <no_super_class> |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/PreparedStatementPacketHandlers.java | PreparedStatementPacketHandlers | register | class PreparedStatementPacketHandlers extends PacketHandlers {
static void register() {<FILL_FUNCTION_BODY>}
private static PreparedSQLStatement prepareStatement(ServerSession session, int commandId,
String sql) {
PreparedSQLStatement command = session.prepareStatement(sql, -1);
co... |
register(PacketType.PREPARED_STATEMENT_PREPARE, new Prepare());
register(PacketType.PREPARED_STATEMENT_PREPARE_READ_PARAMS, new PrepareReadParams());
register(PacketType.PREPARED_STATEMENT_QUERY, new PreparedQuery());
register(PacketType.PREPARED_STATEMENT_UPDATE, new PreparedUpdate());... | 646 | 150 | 796 | <methods>public non-sealed void <init>() ,public static PacketHandler#RAW getHandler(com.lealone.server.protocol.PacketType) ,public static PacketHandler#RAW getHandler(int) ,public static void register(com.lealone.server.protocol.PacketType, PacketHandler<? extends com.lealone.server.protocol.Packet>) <variables>priva... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/ResultPacketHandlers.java | Close | handle | class Close implements PacketHandler<ResultClose> {
@Override
public Packet handle(ServerSession session, ResultClose packet) {<FILL_FUNCTION_BODY>}
} |
Result result = (Result) session.removeCache(packet.resultId, true);
if (result != null) {
result.close();
}
return null;
| 47 | 48 | 95 | <methods>public non-sealed void <init>() ,public static PacketHandler#RAW getHandler(com.lealone.server.protocol.PacketType) ,public static PacketHandler#RAW getHandler(int) ,public static void register(com.lealone.server.protocol.PacketType, PacketHandler<? extends com.lealone.server.protocol.Packet>) <variables>priva... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/SessionPacketHandlers.java | CancelStatement | handle | class CancelStatement implements PacketHandler<SessionCancelStatement> {
@Override
public Packet handle(ServerSession session, SessionCancelStatement packet) {<FILL_FUNCTION_BODY>}
} |
PreparedSQLStatement command = (PreparedSQLStatement) session.removeCache(packet.statementId,
true);
if (command != null) {
command.cancel();
command.close();
} else {
session.cancelStatement(packet.statementId);
... | 51 | 81 | 132 | <methods>public non-sealed void <init>() ,public static PacketHandler#RAW getHandler(com.lealone.server.protocol.PacketType) ,public static PacketHandler#RAW getHandler(int) ,public static void register(com.lealone.server.protocol.PacketType, PacketHandler<? extends com.lealone.server.protocol.Packet>) <variables>priva... |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/handler/StatementListPacketHandlers.java | Update | createYieldableUpdate | class Update extends UpdatePacketHandler<StatementUpdate> {
private void handleAsyncResult(PacketHandleTask task, AsyncResult<?> ar, AtomicInteger count,
AtomicReference<Integer> resultRef, AtomicReference<Throwable> causeRef) {
if (ar.isFailed() && causeRef.get() == null)
... |
StatementList statementList = (StatementList) stmt;
String[] statements = statementList.getRemaining().split(";");
AtomicInteger count = new AtomicInteger();
AtomicReference<Integer> resultRef = new AtomicReference<>();
AtomicReference<Throwable> causeRef = n... | 230 | 465 | 695 | <no_super_class> |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/scheduler/PacketHandleTask.java | PacketHandleTask | handlePacket | class PacketHandleTask extends LinkableTask {
private static final Logger logger = LoggerFactory.getLogger(PacketHandleTask.class);
public final TcpServerConnection conn;
public final TransferInputStream in;
public final int packetId;
public final int packetType;
public final ServerSession ses... |
int version = session.getProtocolVersion();
PacketDecoder<? extends Packet> decoder = PacketDecoders.getDecoder(packetType);
Packet packet = decoder.decode(in, version);
in.closeInputStream(); // 到这里输入流已经读完,及时释放NetBuffer
@SuppressWarnings("unchecked")
PacketHandler<Packe... | 356 | 188 | 544 | <methods>public non-sealed void <init>() <variables> |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/scheduler/SessionInfo.java | SessionInfo | checkSessionTimeout | class SessionInfo extends LinkableBase<SessionInfo> implements ServerSession.TimeoutListener {
private static final Logger logger = LoggerFactory.getLogger(SessionInfo.class);
private final Scheduler scheduler;
private final AsyncServerConnection conn;
private final ServerSession session;
private... |
if (sessionTimeout <= 0)
return;
if (lastActiveTime + sessionTimeout < currentTime) {
conn.closeSession(this);
logger.warn("Client session timeout, session id: " + sessionId //
+ ", host: " + conn.getWritableChannel().getHost() //
... | 1,193 | 100 | 1,293 | <methods>public non-sealed void <init>() ,public com.lealone.server.scheduler.SessionInfo getNext() ,public void setNext(com.lealone.server.scheduler.SessionInfo) <variables>public com.lealone.server.scheduler.SessionInfo next |
lealone_Lealone | Lealone/lealone-server/src/main/java/com/lealone/server/scheduler/SessionValidator.java | SessionValidator | validate | class SessionValidator {
private volatile long wrongPasswordDelay = SysProperties.DELAY_WRONG_PASSWORD_MIN;
private long lastTime;
private long delay;
/**
* This method is called after validating user name and password. If user
* name and password were correct, the sleep time is reset, other... |
int min = SysProperties.DELAY_WRONG_PASSWORD_MIN;
if (isUserAndPasswordCorrect) {
long delay = wrongPasswordDelay;
if (delay > min && delay > 0) {
// delay up to the last delay
// an attacker can't know how long it will be
this.del... | 366 | 278 | 644 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/SQLEngineBase.java | SQLEngineBase | createConditionAndOr | class SQLEngineBase extends PluginBase implements SQLEngine {
public SQLEngineBase(String name) {
super(name);
}
public abstract SQLParserBase createParser(ServerSession session);
@Override
public SQLParserBase createParser(Session session) {
return createParser((ServerSession) se... |
return new ConditionAndOr(and ? ConditionAndOr.AND : ConditionAndOr.OR, (Expression) left,
(Expression) right);
| 258 | 37 | 295 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public synchronized void close() ,public Map<java.lang.String,java.lang.String> getConfig() ,public java.lang.String getName() ,public Class<? extends com.lealone.db.Plugin> getPluginClass() ,public com.lealone.db.Plugin.State getState() ,public synch... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/StatementList.java | StatementList | executeRemaining | class StatementList extends StatementBase {
private final StatementBase firstStatement;
private final String remaining;
public StatementList(ServerSession session, StatementBase firstStatement, String remaining) {
super(session);
this.firstStatement = firstStatement;
this.remaining... |
StatementBase remainingStatement = (StatementBase) session.prepareStatement(remaining, -1);
if (remainingStatement.isQuery()) {
remainingStatement.query(0);
} else {
remainingStatement.update();
}
| 360 | 62 | 422 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean canReuse() ,public void cancel() ,public void checkCanceled() ,public void checkParameters() ,public void close() ,public YieldableBase<com.lealone.db.result.Result> createYieldableQuery(int, boolean, AsyncHandler<AsyncResult<com.lealone.... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/CreatePlugin.java | CreatePlugin | update | class CreatePlugin extends AdminStatement {
private String pluginName;
private String implementBy;
private String classPath;
private boolean ifNotExists;
private CaseInsensitiveMap<String> parameters;
public CreatePlugin(ServerSession session) {
super(session);
}
@Override
... |
LealoneDatabase.checkAdminRight(session, "create plugin");
LealoneDatabase lealoneDB = LealoneDatabase.getInstance();
DbObjectLock lock = lealoneDB.tryExclusivePluginLock(session);
if (lock == null)
return -1;
PluginObject pluginObject = lealoneDB.findPluginObject(se... | 267 | 504 | 771 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/DropPlugin.java | DropPlugin | update | class DropPlugin extends AdminStatement {
private String pluginName;
private boolean ifExists;
public DropPlugin(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.DROP_PLUGIN;
}
public void setPluginName(String name) {
... |
LealoneDatabase.checkAdminRight(session, "drop plugin");
LealoneDatabase lealoneDB = LealoneDatabase.getInstance();
DbObjectLock lock = lealoneDB.tryExclusivePluginLock(session);
if (lock == null)
return -1;
PluginObject pluginObject = lealoneDB.findPluginObject(sess... | 152 | 193 | 345 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/ShutdownDatabase.java | ShutdownDatabase | update | class ShutdownDatabase extends AdminStatement {
private final Database db;
private final boolean immediately;
public ShutdownDatabase(ServerSession session, Database db, boolean immediately) {
super(session);
this.db = db;
this.immediately = immediately;
}
@Override
pu... |
LealoneDatabase.checkAdminRight(session, "shutdown database");
// 如果是LealoneDatabase什么都不做
if (LealoneDatabase.isMe(db.getName()))
return 0;
DbObjectLock lock = LealoneDatabase.getInstance().tryExclusiveDatabaseLock(session);
if (lock == null)
return -1;
... | 127 | 147 | 274 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/ShutdownPlugin.java | ShutdownPlugin | update | class ShutdownPlugin extends AdminStatement {
private final String pluginName;
public ShutdownPlugin(ServerSession session, String pluginName) {
super(session);
this.pluginName = pluginName;
}
@Override
public int getType() {
return SQLStatement.SHUTDOWN_PLUGIN;
}
... |
LealoneDatabase.checkAdminRight(session, "shutdown plugin");
LealoneDatabase lealoneDB = LealoneDatabase.getInstance();
DbObjectLock lock = lealoneDB.tryExclusivePluginLock(session);
if (lock == null)
return -1;
PluginObject pluginObject = lealoneDB.findPluginObject(... | 112 | 165 | 277 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/ShutdownServer.java | ShutdownServer | update | class ShutdownServer extends AdminStatement {
private final int port;
private final String name;
public ShutdownServer(ServerSession session, int port, String name) {
super(session);
this.port = port;
this.name = name;
}
@Override
public int getType() {
return ... |
LealoneDatabase.checkAdminRight(session, "shutdown server");
// 通过指定的名称来关闭server
if (name != null) {
ProtocolServerEngine e = getProtocolServerEngine(name);
e.stop();
} else {
// 通过指定的端口号来关闭server,如果端口号小于0就关闭所有server
ThreadUtils.start("Shu... | 210 | 177 | 387 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/StartPlugin.java | StartPlugin | update | class StartPlugin extends AdminStatement {
private final String pluginName;
public StartPlugin(ServerSession session, String pluginName) {
super(session);
this.pluginName = pluginName;
}
@Override
public int getType() {
return SQLStatement.START_PLUGIN;
}
@Overrid... |
LealoneDatabase.checkAdminRight(session, "start plugin");
LealoneDatabase lealoneDB = LealoneDatabase.getInstance();
DbObjectLock lock = lealoneDB.tryExclusivePluginLock(session);
if (lock == null)
return -1;
PluginObject pluginObject = lealoneDB.findPluginObject(ses... | 107 | 164 | 271 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/admin/StartServer.java | StartServer | update | class StartServer extends AdminStatement {
private final String name;
private final CaseInsensitiveMap<String> parameters;
public StartServer(ServerSession session, String name, CaseInsensitiveMap<String> parameters) {
super(session);
this.name = name;
if (parameters == null)
... |
LealoneDatabase.checkAdminRight(session, "start server");
ProtocolServerEngine e = ShutdownServer.getProtocolServerEngine(name);
if (!e.isInited())
e.init(parameters);
e.start();
return 0;
| 150 | 68 | 218 | <methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterDatabase.java | AlterDatabase | update | class AlterDatabase extends DatabaseStatement {
private final Database db;
public AlterDatabase(ServerSession session, Database db, RunMode runMode,
CaseInsensitiveMap<String> parameters) {
super(session, db.getName());
this.db = db;
this.parameters = parameters;
va... |
LealoneDatabase.checkAdminRight(session, "alter database");
if (parameters == null || parameters.isEmpty())
return 0;
if (LealoneDatabase.getInstance().tryExclusiveDatabaseLock(session) == null)
return -1;
db.updateDbSettings(session, parameters);
return ... | 137 | 82 | 219 | <methods>public java.lang.String getDatabaseName() ,public boolean isDatabaseStatement() <variables>protected final non-sealed java.lang.String dbName,protected CaseInsensitiveMap<java.lang.String> parameters |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterIndexRename.java | AlterIndexRename | update | class AlterIndexRename extends SchemaStatement {
private Index oldIndex;
private String newIndexName;
public AlterIndexRename(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.ALTER_INDEX_RENAME;
}
p... |
session.getUser().checkRight(oldIndex.getTable(), Right.ALL);
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.INDEX, session);
if (lock == null)
return -1;
if (schema.findIndex(session, newIndexName) != null || newIndexName.equals(oldIndex.getName())) {
... | 160 | 146 | 306 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterSchemaRename.java | AlterSchemaRename | update | class AlterSchemaRename extends DefinitionStatement {
private Schema oldSchema;
private String newSchemaName;
public AlterSchemaRename(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.ALTER_SCHEMA_RENAME;
}
public void se... |
session.getUser().checkSchemaAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveSchemaLock(session);
if (lock == null)
return -1;
if (!oldSchema.canDrop()) {
throw DbException.get(ErrorCode.SCHEMA_CAN_NOT_BE_DROPPED_1, oldSc... | 156 | 238 | 394 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterSequence.java | AlterSequence | update | class AlterSequence extends SchemaStatement {
private Table table;
private Sequence sequence;
private Expression start;
private Expression increment;
private Boolean cycle;
private Expression minValue;
private Expression maxValue;
private Expression cacheSize;
private Boolean transa... |
if (table != null) {
session.getUser().checkRight(table, Right.ALL);
}
sequence.tryLock(session, false);
Sequence newSequence = sequence.copy();
if (cycle != null) {
newSequence.setCycle(cycle);
}
if (cacheSize != null) {
long ... | 465 | 294 | 759 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterTableDropConstraint.java | AlterTableDropConstraint | update | class AlterTableDropConstraint extends SchemaStatement {
private String constraintName;
private final boolean ifExists;
public AlterTableDropConstraint(ServerSession session, Schema schema, boolean ifExists) {
super(session, schema);
this.ifExists = ifExists;
}
@Override
publi... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.CONSTRAINT, session);
if (lock == null)
return -1;
Constraint constraint = schema.findConstraint(session, constraintName);
if (constraint == null) {
if (!ifExists) {
throw DbException.get(E... | 154 | 170 | 324 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterTableRename.java | AlterTableRename | update | class AlterTableRename extends SchemaStatement {
private Table oldTable;
private String newTableName;
private boolean hidden;
public AlterTableRename(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.ALTE... |
session.getUser().checkRight(oldTable, Right.ALL);
DbObjectLock lock = tryAlterTable(oldTable);
if (lock == null)
return -1;
Table t = schema.findTableOrView(session, newTableName);
if (t != null && hidden && newTableName.equals(oldTable.getName())) {
if... | 191 | 251 | 442 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterTableRenameColumn.java | AlterTableRenameColumn | update | class AlterTableRenameColumn extends SchemaStatement {
private Table table;
private Column column;
private String newName;
public AlterTableRenameColumn(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.A... |
session.getUser().checkRight(table, Right.ALL);
DbObjectLock lock = tryAlterTable(table);
if (lock == null)
return -1;
table.checkSupportAlter();
// we need to update CHECK constraint
// since it might reference the name of the column
Expression newC... | 199 | 235 | 434 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterTableSet.java | AlterTableSet | update | class AlterTableSet extends SchemaStatement {
private final Table table;
private final int type;
private final boolean value;
private boolean checkExisting;
public AlterTableSet(ServerSession session, Table table, int type, boolean value) {
super(session, table.getSchema());
this.t... |
session.getUser().checkRight(table, Right.ALL);
DbObjectLock lock = tryAlterTable(table);
if (lock == null)
return -1;
switch (type) {
case SQLStatement.ALTER_TABLE_SET_REFERENTIAL_INTEGRITY:
table.setCheckForeignKeyConstraints(session, value, value ? ch... | 176 | 135 | 311 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterUser.java | AlterUser | update | class AlterUser extends UserStatement {
private int type;
private User user;
private String newName;
private boolean admin;
public AlterUser(ServerSession session) {
super(session);
}
@Override
public int getType() {
return type;
}
public void setType(int type... |
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveAuthLock(session);
if (lock == null)
return -1;
switch (type) {
case SQLStatement.ALTER_USER_SET_PASSWORD:
if (user != session.getUser()) {
session.getUser().checkAdm... | 200 | 366 | 566 | <methods>public void setHash(com.lealone.sql.expression.Expression) ,public void setHashMongo(com.lealone.sql.expression.Expression) ,public void setHashMySQL(com.lealone.sql.expression.Expression) ,public void setHashPostgreSQL(com.lealone.sql.expression.Expression) ,public void setPassword(com.lealone.sql.expression.... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/AlterView.java | AlterView | update | class AlterView extends SchemaStatement {
private TableView view;
public AlterView(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.ALTER_VIEW;
}
public void setView(TableView view) {
this.view ... |
session.getUser().checkRight(view, Right.ALL);
if (schema.tryExclusiveLock(DbObjectType.TABLE_OR_VIEW, session) == null)
return -1;
DbException e = view.recompile(session, false);
if (e != null) {
throw e;
}
return 0;
| 123 | 93 | 216 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/Analyze.java | Analyze | update | class Analyze extends DefinitionStatement {
/**
* The sample size.
*/
private int sample;
public Analyze(ServerSession session) {
super(session);
sample = session.getDatabase().getSettings().analyzeSample;
}
@Override
public int getType() {
return SQLStatemen... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
for (Table table : db.getAllTablesAndViews(false)) {
table.analyze(session, sample);
}
return 0;
| 141 | 63 | 204 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateAggregate.java | CreateAggregate | update | class CreateAggregate extends SchemaStatement {
private String name;
private String javaClassName;
private boolean ifNotExists;
private boolean force;
public CreateAggregate(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.AGGREGATE, session);
if (lock == null)
return -1;
if (schema.findAggregate(session, name) != null || schema.findFunction(session, name) != null) {
if (!ifNotExists) {
... | 226 | 187 | 413 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateConstant.java | CreateConstant | update | class CreateConstant extends SchemaStatement {
private String constantName;
private Expression expression;
private boolean ifNotExists;
public CreateConstant(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatem... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.CONSTANT, session);
if (lock == null)
return -1;
// 当成功获得排它锁后,不管以下代码是正常还是异常返回都不需要在这里手工释放锁,
// 排它锁会在事务提交或回滚时自动被释放。
if (schema.findConstant(session, constantName) != null)... | 196 | 237 | 433 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateDatabase.java | CreateDatabase | update | class CreateDatabase extends DatabaseStatement {
private final boolean ifNotExists;
public CreateDatabase(ServerSession session, String dbName, boolean ifNotExists, RunMode runMode,
CaseInsensitiveMap<String> parameters) {
super(session, dbName);
if (parameters == null)
... |
LealoneDatabase.checkAdminRight(session, "create database");
LealoneDatabase lealoneDB = LealoneDatabase.getInstance();
DbObjectLock lock = lealoneDB.tryExclusiveDatabaseLock(session);
if (lock == null)
return -1;
if (LealoneDatabase.isMe(dbName) || lealoneDB.findDa... | 165 | 386 | 551 | <methods>public java.lang.String getDatabaseName() ,public boolean isDatabaseStatement() <variables>protected final non-sealed java.lang.String dbName,protected CaseInsensitiveMap<java.lang.String> parameters |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateFunctionAlias.java | CreateFunctionAlias | update | class CreateFunctionAlias extends SchemaStatement {
private String aliasName;
private String javaClassMethod;
private boolean deterministic;
private boolean ifNotExists;
private boolean force;
private String source;
private boolean bufferResultSetToLocalTemp = true;
public CreateFuncti... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.FUNCTION_ALIAS, session);
if (lock == null)
return -1;
if (schema.findFunction(session, aliasName) != null) {
if (!ifNotExists) {
throw DbException.get(Error... | 421 | 270 | 691 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateIndex.java | CreateIndex | update | class CreateIndex extends SchemaStatement {
private String tableName;
private String indexName;
private IndexColumn[] indexColumns;
private boolean ifNotExists;
private boolean primaryKey, unique, hash;
private String comment;
public CreateIndex(ServerSession session, Schema schema) {
... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.INDEX, session);
if (lock == null)
return -1;
Table table = schema.getTableOrView(session, tableName);
if (schema.findIndex(session, indexName) != null) {
if (ifNotExists) {
return 0;
... | 344 | 432 | 776 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateRole.java | CreateRole | update | class CreateRole extends AuthStatement {
private String roleName;
private boolean ifNotExists;
public CreateRole(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.CREATE_ROLE;
}
public void setRoleName(String name) {
... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveAuthLock(session);
if (lock == null)
return -1;
if (db.findUser(session, roleName) != null) {
throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, r... | 154 | 219 | 373 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateSchema.java | CreateSchema | update | class CreateSchema extends DefinitionStatement {
private String schemaName;
private String authorization;
private boolean ifNotExists;
public CreateSchema(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.CREATE_SCHEMA;
}
... |
session.getUser().checkSchemaAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveSchemaLock(session);
if (lock == null)
return -1;
User user = db.getUser(session, authorization);
// during DB startup, the Right/Role records have ... | 189 | 229 | 418 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateSequence.java | CreateSequence | update | class CreateSequence extends SchemaStatement {
private String sequenceName;
private boolean ifNotExists;
private boolean cycle;
private Expression minValue;
private Expression maxValue;
private Expression start;
private Expression increment;
private Expression cacheSize;
private boo... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.SEQUENCE, session);
if (lock == null)
return -1;
if (schema.findSequence(session, sequenceName) != null) {
if (ifNotExists) {
return 0;
}
throw DbException.get(ErrorCode.SEQ... | 521 | 240 | 761 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateTrigger.java | CreateTrigger | update | class CreateTrigger extends SchemaStatement {
private String triggerName;
private boolean ifNotExists;
private boolean insteadOf;
private boolean before;
private int typeMask;
private boolean rowBased;
private int queueSize = TriggerObject.DEFAULT_QUEUE_SIZE;
private boolean noWait;
... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.TRIGGER, session);
if (lock == null)
return -1;
if (schema.findTrigger(session, triggerName) != null) {
if (ifNotExists) {
return 0;
}
throw DbException.get(ErrorCode.TRIGGE... | 555 | 403 | 958 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateUser.java | CreateUser | update | class CreateUser extends UserStatement {
private String userName;
private boolean admin;
private String comment;
private boolean ifNotExists;
public CreateUser(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.CREATE_USER;
... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveAuthLock(session);
if (lock == null)
return -1;
if (db.findRole(session, userName) != null) {
throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, u... | 486 | 460 | 946 | <methods>public void setHash(com.lealone.sql.expression.Expression) ,public void setHashMongo(com.lealone.sql.expression.Expression) ,public void setHashMySQL(com.lealone.sql.expression.Expression) ,public void setHashPostgreSQL(com.lealone.sql.expression.Expression) ,public void setPassword(com.lealone.sql.expression.... |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateUserDataType.java | CreateUserDataType | update | class CreateUserDataType extends SchemaStatement {
private String typeName;
private Column column;
private boolean ifNotExists;
public CreateUserDataType(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.USER_DATATYPE, session);
if (lock == null)
return -1;
if (schema.findUserDataType(session, typeName) != null) {
if (ifNotExists) {
return 0;
}
... | 194 | 329 | 523 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/CreateView.java | CreateView | update | class CreateView extends SchemaStatement {
private String viewName;
private boolean ifNotExists;
private Query select;
private String selectSQL;
private String[] columnNames;
private String comment;
private boolean orReplace;
private boolean force;
public CreateView(ServerSession s... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.TABLE_OR_VIEW, session);
if (lock == null)
return -1;
Database db = session.getDatabase();
TableView view = null;
Table old = getSchema().findTableOrView(session, viewName);
if (old != null) {
... | 350 | 508 | 858 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DatabaseStatement.java | DatabaseStatement | validateParameters | class DatabaseStatement extends DefinitionStatement {
protected final String dbName;
protected CaseInsensitiveMap<String> parameters;
protected DatabaseStatement(ServerSession session, String dbName) {
super(session);
this.dbName = dbName;
}
@Override
public boolean isDatabas... |
if (parameters == null || parameters.isEmpty())
return;
CaseInsensitiveMap<String> parameters = new CaseInsensitiveMap<>(this.parameters);
HashSet<String> recognizedSettingOptions = new HashSet<>(DbSetting.values().length);
for (DbSetting s : DbSetting.values())
... | 129 | 168 | 297 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropAggregate.java | DropAggregate | update | class DropAggregate extends SchemaStatement {
private String name;
private boolean ifExists;
public DropAggregate(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_AGGREGATE;
}
public void setNa... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.AGGREGATE, session);
if (lock == null)
return -1;
UserAggregate aggregate = schema.findAggregate(session, name);
if (aggregate == null) {
if (!ifExists) {
... | 158 | 145 | 303 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropConstant.java | DropConstant | update | class DropConstant extends SchemaStatement {
private String constantName;
private boolean ifExists;
public DropConstant(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_CONSTANT;
}
public void ... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.CONSTANT, session);
if (lock == null)
return -1;
Constant constant = schema.findConstant(session, constantName);
if (constant == null) {
if (!ifExists) {
... | 156 | 140 | 296 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropDatabase.java | DropDatabase | update | class DropDatabase extends DatabaseStatement {
private boolean ifExists;
public DropDatabase(ServerSession session, String dbName) {
super(session, dbName);
}
@Override
public int getType() {
return SQLStatement.DROP_DATABASE;
}
public void setIfExists(boolean ifExists) {... |
LealoneDatabase.checkAdminRight(session, "drop database");
if (LealoneDatabase.isMe(dbName)) {
throw DbException.get(ErrorCode.CANNOT_DROP_LEALONE_DATABASE);
}
LealoneDatabase lealoneDB = LealoneDatabase.getInstance();
DbObjectLock lock = lealoneDB.tryExclusiveDataba... | 126 | 311 | 437 | <methods>public java.lang.String getDatabaseName() ,public boolean isDatabaseStatement() <variables>protected final non-sealed java.lang.String dbName,protected CaseInsensitiveMap<java.lang.String> parameters |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropFunctionAlias.java | DropFunctionAlias | update | class DropFunctionAlias extends SchemaStatement {
private String aliasName;
private boolean ifExists;
public DropFunctionAlias(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_ALIAS;
}
public v... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.FUNCTION_ALIAS, session);
if (lock == null)
return -1;
FunctionAlias functionAlias = schema.findFunction(session, aliasName);
if (functionAlias == null) {
if (!ifExi... | 163 | 154 | 317 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropIndex.java | DropIndex | update | class DropIndex extends SchemaStatement {
private String indexName;
private boolean ifExists;
public DropIndex(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_INDEX;
}
public void setIndexName... |
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.INDEX, session);
if (lock == null)
return -1;
Index index = schema.findIndex(session, indexName);
if (index == null) {
if (!ifExists) {
throw DbException.get(ErrorCode.INDEX_NOT_FOUND_1, in... | 154 | 355 | 509 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropRole.java | DropRole | update | class DropRole extends AuthStatement {
private String roleName;
private boolean ifExists;
public DropRole(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.DROP_ROLE;
}
public void setRoleName(String roleName) {
th... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveAuthLock(session);
if (lock == null)
return -1;
if (roleName.equals(Constants.PUBLIC_ROLE_NAME)) {
throw DbException.get(ErrorCode.ROLE_CAN_NOT_BE_DRO... | 152 | 201 | 353 | <no_super_class> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropSchema.java | DropSchema | update | class DropSchema extends DefinitionStatement {
private String schemaName;
private boolean ifExists;
public DropSchema(ServerSession session) {
super(session);
}
@Override
public int getType() {
return SQLStatement.DROP_SCHEMA;
}
public void setSchemaName(String name) ... |
session.getUser().checkAdmin();
Database db = session.getDatabase();
DbObjectLock lock = db.tryExclusiveSchemaLock(session);
if (lock == null)
return -1;
Schema schema = db.findSchema(session, schemaName);
if (schema == null) {
if (!ifExists) {
... | 151 | 192 | 343 | <methods>public boolean isDDL() <variables> |
lealone_Lealone | Lealone/lealone-sql/src/main/java/com/lealone/sql/ddl/DropSequence.java | DropSequence | update | class DropSequence extends SchemaStatement {
private String sequenceName;
private boolean ifExists;
public DropSequence(ServerSession session, Schema schema) {
super(session, schema);
}
@Override
public int getType() {
return SQLStatement.DROP_SEQUENCE;
}
public void ... |
session.getUser().checkAdmin();
DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.SEQUENCE, session);
if (lock == null)
return -1;
Sequence sequence = schema.findSequence(session, sequenceName);
if (sequence == null) {
if (!ifExists) {
... | 156 | 189 | 345 | <methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.