提交 91926786 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting / javadocs

上级 d95318e6
...@@ -4718,7 +4718,7 @@ public class Parser { ...@@ -4718,7 +4718,7 @@ public class Parser {
} }
throw DbException.getInvalidValueException("BINARY_COLLATION", name); throw DbException.getInvalidValueException("BINARY_COLLATION", name);
} }
private RunScriptCommand parseRunScript() { private RunScriptCommand parseRunScript() {
RunScriptCommand command = new RunScriptCommand(session); RunScriptCommand command = new RunScriptCommand(session);
read("FROM"); read("FROM");
......
...@@ -1273,8 +1273,8 @@ public class Select extends Query { ...@@ -1273,8 +1273,8 @@ public class Select extends Query {
return false; return false;
} }
public SortOrder prepareOrder() { public SortOrder getSortOrder() {
return sort; return sort;
} }
} }
...@@ -203,7 +203,7 @@ public class SetTypes { ...@@ -203,7 +203,7 @@ public class SetTypes {
* The type of a SET BINARY_COLLATION statement. * The type of a SET BINARY_COLLATION statement.
*/ */
public static final int BINARY_COLLATION = 38; public static final int BINARY_COLLATION = 38;
private static final ArrayList<String> TYPES = New.arrayList(); private static final ArrayList<String> TYPES = New.arrayList();
private SetTypes() { private SetTypes() {
......
...@@ -112,12 +112,12 @@ public class Mode { ...@@ -112,12 +112,12 @@ public class Mode {
* The function LOG() uses base 10 instead of E. * The function LOG() uses base 10 instead of E.
*/ */
public boolean logIsLogBase10; public boolean logIsLogBase10;
/** /**
* SERIAL and BIGSERIAL columns are not automatically primary keys. * SERIAL and BIGSERIAL columns are not automatically primary keys.
*/ */
public boolean serialColumnIsNotPK; public boolean serialColumnIsNotPK;
/** /**
* Swap the parameters of the CONVERT function. * Swap the parameters of the CONVERT function.
*/ */
......
...@@ -242,7 +242,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -242,7 +242,7 @@ public class Function extends Expression implements FunctionCall {
// 2 or 3 arguments // 2 or 3 arguments
addFunction("LOCATE", LOCATE, VAR_ARGS, Value.INT); addFunction("LOCATE", LOCATE, VAR_ARGS, Value.INT);
// alias for MSSQLServer // alias for MSSQLServer
addFunction("CHARINDEX", LOCATE, VAR_ARGS, Value.INT); addFunction("CHARINDEX", LOCATE, VAR_ARGS, Value.INT);
// same as LOCATE with 2 arguments // same as LOCATE with 2 arguments
addFunction("POSITION", LOCATE, 2, Value.INT); addFunction("POSITION", LOCATE, 2, Value.INT);
addFunction("INSTR", INSTR, VAR_ARGS, Value.INT); addFunction("INSTR", INSTR, VAR_ARGS, Value.INT);
......
...@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* *
* @param masks the search mask * @param masks the search mask
* @param rowCount the number of rows in the index * @param rowCount the number of rows in the index
* @param sortOrder the sort order
* @return the estimated cost * @return the estimated cost
*/ */
protected long getCostRangeIndex(int[] masks, long rowCount, SortOrder sortOrder) { protected long getCostRangeIndex(int[] masks, long rowCount, SortOrder sortOrder) {
...@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
break; break;
} }
} }
// If the query ORDER BY clause matches the ordering of this index, it will be cheaper // if the ORDER BY clause matches the ordering of this index,
// than another index, so adjust the cost accordingly. // it will be cheaper than another index, so adjust the cost accordingly
if (sortOrder != null) { if (sortOrder != null) {
int[] columnIndexes = new int[ indexColumns.length ]; int[] columnIndexes = new int[ indexColumns.length ];
int[] columnSortTypes = new int[ indexColumns.length ]; int[] columnSortTypes = new int[ indexColumns.length ];
...@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
coveringCount++; coveringCount++;
} }
if (sortOrderMatches) { if (sortOrderMatches) {
// "coveringCount" makes sure that when we have two or more covering indexes, we choose the one that covers more // "coveringCount" makes sure that when we have two
// or more covering indexes, we choose the one
// that covers more
cost -= coveringCount; cost -= coveringCount;
} }
} }
......
...@@ -80,6 +80,7 @@ public interface Index extends SchemaObject { ...@@ -80,6 +80,7 @@ public interface Index extends SchemaObject {
* @param session the session * @param session the session
* @param masks per-column comparison bit masks, null means 'always false', * @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition * see constants in IndexCondition
* @param sortOrder the sort order
* @return the estimated cost * @return the estimated cost
*/ */
double getCost(Session session, int[] masks, SortOrder sortOrder); double getCost(Session session, int[] masks, SortOrder sortOrder);
......
...@@ -45,7 +45,7 @@ public class Chunk { ...@@ -45,7 +45,7 @@ public class Chunk {
* The total number of pages in this chunk. * The total number of pages in this chunk.
*/ */
int pageCount; int pageCount;
/** /**
* The number of pages still alive. * The number of pages still alive.
*/ */
......
...@@ -352,7 +352,7 @@ public class DataUtils { ...@@ -352,7 +352,7 @@ public class DataUtils {
file, src.remaining(), pos, e); file, src.remaining(), pos, e);
} }
} }
/** /**
* Convert the length to a length code 0..31. 31 means more than 1 MB. * Convert the length to a length code 0..31. 31 means more than 1 MB.
* *
......
...@@ -1176,7 +1176,7 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1176,7 +1176,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this.keyType = keyType; this.keyType = keyType;
return this; return this;
} }
public DataType getKeyType() { public DataType getKeyType() {
return keyType; return keyType;
} }
......
...@@ -868,7 +868,7 @@ public class MVStore { ...@@ -868,7 +868,7 @@ public class MVStore {
} else { } else {
meta.put("root." + m.getId(), String.valueOf(Integer.MAX_VALUE)); meta.put("root." + m.getId(), String.valueOf(Integer.MAX_VALUE));
} }
} }
Set<Chunk> removedChunks = applyFreedPages(storeVersion, time); Set<Chunk> removedChunks = applyFreedPages(storeVersion, time);
ByteBuffer buff; ByteBuffer buff;
if (writeBuffer != null) { if (writeBuffer != null) {
...@@ -947,15 +947,15 @@ public class MVStore { ...@@ -947,15 +947,15 @@ public class MVStore {
writeFileHeader(); writeFileHeader();
shrinkFileIfPossible(1); shrinkFileIfPossible(1);
} }
for (MVMap<?, ?> m : changed) { for (MVMap<?, ?> m : changed) {
Page p = m.getRoot(); Page p = m.getRoot();
if (p.getTotalCount() > 0) { if (p.getTotalCount() > 0) {
p.writeEnd(); p.writeEnd();
} }
} }
meta.getRoot().writeEnd(); meta.getRoot().writeEnd();
// some pages might have been changed in the meantime (in the newest version) // some pages might have been changed in the meantime (in the newest version)
unsavedPageCount = Math.max(0, unsavedPageCount - currentUnsavedPageCount); unsavedPageCount = Math.max(0, unsavedPageCount - currentUnsavedPageCount);
currentStoreVersion = -1; currentStoreVersion = -1;
...@@ -1297,7 +1297,7 @@ public class MVStore { ...@@ -1297,7 +1297,7 @@ public class MVStore {
} }
registerFreePage(version, c.id, DataUtils.getPageMaxLength(pos), 1); registerFreePage(version, c.id, DataUtils.getPageMaxLength(pos), 1);
} }
private void registerFreePage(long version, int chunkId, long maxLengthLive, int pageCount) { private void registerFreePage(long version, int chunkId, long maxLengthLive, int pageCount) {
synchronized (freedPages) { synchronized (freedPages) {
HashMap<Integer, Chunk>freed = freedPages.get(version); HashMap<Integer, Chunk>freed = freedPages.get(version);
...@@ -1736,7 +1736,7 @@ public class MVStore { ...@@ -1736,7 +1736,7 @@ public class MVStore {
} }
store(true); store(true);
} }
public boolean isReadOnly() { public boolean isReadOnly() {
return readOnly; return readOnly;
} }
......
...@@ -852,7 +852,7 @@ public class Page { ...@@ -852,7 +852,7 @@ public class Page {
} }
return write(chunk, buff); return write(chunk, buff);
} }
/** /**
* Unlink the children recursively after all data is written. * Unlink the children recursively after all data is written.
*/ */
......
...@@ -218,7 +218,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -218,7 +218,7 @@ public class MVPrimaryIndex extends BaseIndex {
return new MVStoreCursor(session, Collections.<Value>emptyList().iterator(), 0); return new MVStoreCursor(session, Collections.<Value>emptyList().iterator(), 0);
} }
long key = first ? map.firstKey().getLong() : map.lastKey().getLong(); long key = first ? map.firstKey().getLong() : map.lastKey().getLong();
MVStoreCursor cursor = new MVStoreCursor(session, MVStoreCursor cursor = new MVStoreCursor(session,
Arrays.asList((Value) ValueLong.get(key)).iterator(), key); Arrays.asList((Value) ValueLong.get(key)).iterator(), key);
cursor.next(); cursor.next();
return cursor; return cursor;
......
...@@ -520,7 +520,7 @@ public class MVTable extends TableBase { ...@@ -520,7 +520,7 @@ public class MVTable extends TableBase {
rowCount = 0; rowCount = 0;
changesSinceAnalyze = 0; changesSinceAnalyze = 0;
} }
@Override @Override
public void addRow(Session session, Row row) { public void addRow(Session session, Row row) {
lastModificationId = database.getNextModificationDataId(); lastModificationId = database.getNextModificationDataId();
...@@ -701,7 +701,7 @@ public class MVTable extends TableBase { ...@@ -701,7 +701,7 @@ public class MVTable extends TableBase {
public String toString() { public String toString() {
return getSQL(); return getSQL();
} }
public boolean isMVStore() { public boolean isMVStore() {
return true; return true;
} }
......
...@@ -147,7 +147,7 @@ public class MVTableEngine implements TableEngine { ...@@ -147,7 +147,7 @@ public class MVTableEngine implements TableEngine {
public Store(Database db, MVStore store) { public Store(Database db, MVStore store) {
this.db = db; this.db = db;
this.store = store; this.store = store;
this.transactionStore = new TransactionStore(store, this.transactionStore = new TransactionStore(store,
new ValueDataType(null, null, null)); new ValueDataType(null, null, null));
} }
......
...@@ -75,7 +75,7 @@ public class TransactionStore { ...@@ -75,7 +75,7 @@ public class TransactionStore {
public TransactionStore(MVStore store) { public TransactionStore(MVStore store) {
this(store, new ObjectDataType()); this(store, new ObjectDataType());
} }
/** /**
* Create a new transaction store. * Create a new transaction store.
* *
...@@ -92,7 +92,7 @@ public class TransactionStore { ...@@ -92,7 +92,7 @@ public class TransactionStore {
ArrayType valueType = new ArrayType(new DataType[]{ ArrayType valueType = new ArrayType(new DataType[]{
new ObjectDataType(), new ObjectDataType(), keyType new ObjectDataType(), new ObjectDataType(), keyType
}); });
MVMapConcurrent.Builder<long[], Object[]> builder = MVMapConcurrent.Builder<long[], Object[]> builder =
new MVMapConcurrent.Builder<long[], Object[]>(). new MVMapConcurrent.Builder<long[], Object[]>().
valueType(valueType); valueType(valueType);
// TODO escape other map names, to avoid conflicts // TODO escape other map names, to avoid conflicts
...@@ -129,7 +129,7 @@ public class TransactionStore { ...@@ -129,7 +129,7 @@ public class TransactionStore {
/** /**
* Get the list of currently open transactions that have pending writes. * Get the list of currently open transactions that have pending writes.
* *
* @return the list of transactions * @return the list of transactions
*/ */
public synchronized List<Transaction> getOpenTransactions() { public synchronized List<Transaction> getOpenTransactions() {
...@@ -158,8 +158,8 @@ public class TransactionStore { ...@@ -158,8 +158,8 @@ public class TransactionStore {
int status = Transaction.STATUS_OPEN; int status = Transaction.STATUS_OPEN;
return new Transaction(this, transactionId, status, null, 0); return new Transaction(this, transactionId, status, null, 0);
} }
void storeTransaction(Transaction t) { private void storeTransaction(Transaction t) {
long transactionId = t.getId(); long transactionId = t.getId();
if (openTransactions.containsKey(transactionId)) { if (openTransactions.containsKey(transactionId)) {
return; return;
...@@ -185,10 +185,10 @@ public class TransactionStore { ...@@ -185,10 +185,10 @@ public class TransactionStore {
openTransactions.put(t.getId(), v); openTransactions.put(t.getId(), v);
store.commit(); store.commit();
} }
/** /**
* Log an entry. * Log an entry.
* *
* @param t the transaction * @param t the transaction
* @param logId the log id * @param logId the log id
* @param opType the operation type * @param opType the operation type
...@@ -345,7 +345,7 @@ public class TransactionStore { ...@@ -345,7 +345,7 @@ public class TransactionStore {
* The transaction store. * The transaction store.
*/ */
final TransactionStore store; final TransactionStore store;
/** /**
* The version of the store at the time the transaction was started. * The version of the store at the time the transaction was started.
*/ */
...@@ -454,7 +454,7 @@ public class TransactionStore { ...@@ -454,7 +454,7 @@ public class TransactionStore {
*/ */
public <K, V> TransactionMap<K, V> openMap(String name, long readVersion) { public <K, V> TransactionMap<K, V> openMap(String name, long readVersion) {
checkOpen(); checkOpen();
return new TransactionMap<K, V>(this, name, new ObjectDataType(), return new TransactionMap<K, V>(this, name, new ObjectDataType(),
new ObjectDataType(), readVersion); new ObjectDataType(), readVersion);
} }
...@@ -569,7 +569,7 @@ public class TransactionStore { ...@@ -569,7 +569,7 @@ public class TransactionStore {
*/ */
private final MVMap<K, Object[]> mapRead; private final MVMap<K, Object[]> mapRead;
TransactionMap(Transaction transaction, String name, DataType keyType, TransactionMap(Transaction transaction, String name, DataType keyType,
DataType valueType, long readVersion) { DataType valueType, long readVersion) {
this.transaction = transaction; this.transaction = transaction;
ArrayType arrayType = new ArrayType(new DataType[] { ArrayType arrayType = new ArrayType(new DataType[] {
...@@ -811,7 +811,13 @@ public class TransactionStore { ...@@ -811,7 +811,13 @@ public class TransactionStore {
public V getLatest(K key) { public V getLatest(K key) {
return get(key, mapWrite); return get(key, mapWrite);
} }
/**
* Whether the map contains the key.
*
* @param key the key
* @return true if the map contains an entry for this key
*/
public boolean containsKey(K key) { public boolean containsKey(K key) {
return get(key) != null; return get(key) != null;
} }
...@@ -855,50 +861,102 @@ public class TransactionStore { ...@@ -855,50 +861,102 @@ public class TransactionStore {
} }
} }
/**
* Rename the map.
*
* @param newMapName the new map name
*/
public void renameMap(String newMapName) { public void renameMap(String newMapName) {
// TODO rename maps transactionally // TODO rename maps transactionally
mapWrite.renameMap(newMapName); mapWrite.renameMap(newMapName);
} }
/**
* Check whether this map is closed.
*
* @return true if closed
*/
public boolean isClosed() { public boolean isClosed() {
return mapWrite.isClosed(); return mapWrite.isClosed();
} }
/**
* Remove the map.
*/
public void removeMap() { public void removeMap() {
// TODO remove in a transaction // TODO remove in a transaction
mapWrite.removeMap(); mapWrite.removeMap();
} }
/**
* Clear the map.
*/
public void clear() { public void clear() {
// TODO truncate transactionally // TODO truncate transactionally
mapWrite.clear(); mapWrite.clear();
} }
/**
* Get the first key.
*
* @return the first key, or null if empty
*/
public K firstKey() { public K firstKey() {
// TODO transactional firstKey // TODO transactional firstKey
return mapRead.firstKey(); return mapRead.firstKey();
} }
/**
* Get the last key.
*
* @return the last key, or null if empty
*/
public K lastKey() { public K lastKey() {
// TODO transactional lastKey // TODO transactional lastKey
return mapRead.lastKey(); return mapRead.lastKey();
} }
/**
* Iterate over all keys.
*
* @param from the first key to return
* @return the iterator
*/
public Iterator<K> keyIterator(K from) { public Iterator<K> keyIterator(K from) {
// TODO transactional keyIterator // TODO transactional keyIterator
return mapRead.keyIterator(from); return mapRead.keyIterator(from);
} }
/**
* Get the smallest key that is larger or equal to this key.
*
* @param key the key (may not be null)
* @return the result
*/
public K ceilingKey(K key) { public K ceilingKey(K key) {
// TODO transactional ceilingKey // TODO transactional ceilingKey
return mapRead.ceilingKey(key); return mapRead.ceilingKey(key);
} }
/**
* Get the smallest key that is larger than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public K higherKey(K key) { public K higherKey(K key) {
// TODO transactional higherKey // TODO transactional higherKey
return mapRead.higherKey(key); return mapRead.higherKey(key);
} }
/**
* Get the largest key that is smaller than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public K lowerKey(K key) { public K lowerKey(K key) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return mapRead.lowerKey(key); return mapRead.lowerKey(key);
...@@ -909,7 +967,7 @@ public class TransactionStore { ...@@ -909,7 +967,7 @@ public class TransactionStore {
} }
} }
/** /**
* A data type that contains an array of objects with the specified data * A data type that contains an array of objects with the specified data
* types. * types.
...@@ -970,8 +1028,8 @@ public class TransactionStore { ...@@ -970,8 +1028,8 @@ public class TransactionStore {
array[i] = t.read(buff); array[i] = t.read(buff);
} }
return array; return array;
} }
} }
} }
......
...@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase { ...@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase {
* @param session the session * @param session the session
* @param masks per-column comparison bit masks, null means 'always false', * @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition * see constants in IndexCondition
* @param sortOrder the sort order
* @return the plan item * @return the plan item
*/ */
public PlanItem getBestPlanItem(Session session, int[] masks, SortOrder sortOrder) { public PlanItem getBestPlanItem(Session session, int[] masks, SortOrder sortOrder) {
......
...@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver { ...@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver {
} }
SortOrder sortOrder = null; SortOrder sortOrder = null;
if (select != null) { if (select != null) {
sortOrder = select.prepareOrder(); sortOrder = select.getSortOrder();
} }
item = table.getBestPlanItem(s, masks, sortOrder); item = table.getBestPlanItem(s, masks, sortOrder);
// The more index conditions, the earlier the table. // The more index conditions, the earlier the table.
......
...@@ -35,15 +35,17 @@ public class CompareMode { ...@@ -35,15 +35,17 @@ public class CompareMode {
public static final String ICU4J = "ICU4J_"; public static final String ICU4J = "ICU4J_";
/** /**
* This constant means that the BINARY columns are sorted as if the bytes were signed. * This constant means that the BINARY columns are sorted as if the bytes
* were signed.
*/ */
public static final String SIGNED = "SIGNED"; public static final String SIGNED = "SIGNED";
/** /**
* This constant means that the BINARY columns are sorted as if the bytes were unsigned. * This constant means that the BINARY columns are sorted as if the bytes
* were unsigned.
*/ */
public static final String UNSIGNED = "UNSIGNED"; public static final String UNSIGNED = "UNSIGNED";
private static CompareMode lastUsed; private static CompareMode lastUsed;
private static final boolean CAN_USE_ICU4J; private static final boolean CAN_USE_ICU4J;
...@@ -78,12 +80,13 @@ public class CompareMode { ...@@ -78,12 +80,13 @@ public class CompareMode {
* *
* @param name the collation name or null * @param name the collation name or null
* @param strength the collation strength * @param strength the collation strength
* @param binaryUnsigned whether to compare binaries as unsigned
* @return the compare mode * @return the compare mode
*/ */
public static synchronized CompareMode getInstance(String name, int strength, boolean binaryUnsigned) { public static synchronized CompareMode getInstance(String name, int strength, boolean binaryUnsigned) {
if (lastUsed != null) { if (lastUsed != null) {
if (StringUtils.equals(lastUsed.name, name) && if (StringUtils.equals(lastUsed.name, name) &&
lastUsed.strength == strength && lastUsed.strength == strength &&
lastUsed.binaryUnsigned == binaryUnsigned) { lastUsed.binaryUnsigned == binaryUnsigned) {
return lastUsed; return lastUsed;
} }
...@@ -220,7 +223,7 @@ public class CompareMode { ...@@ -220,7 +223,7 @@ public class CompareMode {
public int getStrength() { public int getStrength() {
return strength; return strength;
} }
public boolean isBinaryUnsigned() { public boolean isBinaryUnsigned() {
return binaryUnsigned; return binaryUnsigned;
} }
......
...@@ -606,7 +606,7 @@ public abstract class TestBase { ...@@ -606,7 +606,7 @@ public abstract class TestBase {
fail("Expected: " + df.format(expected) + " actual: " + df.format(actual)); fail("Expected: " + df.format(expected) + " actual: " + df.format(actual));
} }
} }
/** /**
* Check if two values are equal, and if not throw an exception. * Check if two values are equal, and if not throw an exception.
* *
......
...@@ -836,7 +836,7 @@ public class TestCases extends TestBase { ...@@ -836,7 +836,7 @@ public class TestCases extends TestBase {
Connection conn = getConnection("cases"); Connection conn = getConnection("cases");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ResultSet rs; ResultSet rs;
// test the default (SIGNED) // test the default (SIGNED)
stat.execute("create table bin( x binary(1) );"); stat.execute("create table bin( x binary(1) );");
stat.execute("insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');"); stat.execute("insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');");
...@@ -849,7 +849,7 @@ public class TestCases extends TestBase { ...@@ -849,7 +849,7 @@ public class TestCases extends TestBase {
assertEquals("09", rs.getString(1)); assertEquals("09", rs.getString(1));
rs.next(); rs.next();
assertEquals("0a", rs.getString(1)); assertEquals("0a", rs.getString(1));
// test UNSIGNED mode // test UNSIGNED mode
stat.execute("drop table bin"); stat.execute("drop table bin");
stat.execute("SET BINARY_COLLATION UNSIGNED"); stat.execute("SET BINARY_COLLATION UNSIGNED");
...@@ -864,10 +864,10 @@ public class TestCases extends TestBase { ...@@ -864,10 +864,10 @@ public class TestCases extends TestBase {
assertEquals("99", rs.getString(1)); assertEquals("99", rs.getString(1));
rs.next(); rs.next();
assertEquals("aa", rs.getString(1)); assertEquals("aa", rs.getString(1));
conn.close(); conn.close();
} }
private void testPersistentSettings() throws SQLException { private void testPersistentSettings() throws SQLException {
deleteDb("cases"); deleteDb("cases");
Connection conn = getConnection("cases"); Connection conn = getConnection("cases");
......
...@@ -303,7 +303,7 @@ public class TestCompatibility extends TestBase { ...@@ -303,7 +303,7 @@ public class TestCompatibility extends TestBase {
assertEquals("John, Doe", rs.getString(1)); assertEquals("John, Doe", rs.getString(1));
rs.close(); rs.close();
prep.close(); prep.close();
// CONVERT has it's parameters the other way around from the default mode // CONVERT has it's parameters the other way around from the default mode
rs = stat.executeQuery("SELECT CONVERT(INT, '10')"); rs = stat.executeQuery("SELECT CONVERT(INT, '10')");
rs.next(); rs.next();
......
...@@ -882,11 +882,11 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -882,11 +882,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
deleteDb("functions"); deleteDb("functions");
Connection conn = getConnection("functions"); Connection conn = getConnection("functions");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT TRUNCATE(1.234, 2) FROM dual"); ResultSet rs = stat.executeQuery("SELECT TRUNCATE(1.234, 2) FROM dual");
rs.next(); rs.next();
assertEquals(1.23d, rs.getDouble(1)); assertEquals(1.23d, rs.getDouble(1));
rs = stat.executeQuery("SELECT CURRENT_TIMESTAMP(), TRUNCATE(CURRENT_TIMESTAMP()) FROM dual"); rs = stat.executeQuery("SELECT CURRENT_TIMESTAMP(), TRUNCATE(CURRENT_TIMESTAMP()) FROM dual");
rs.next(); rs.next();
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
...@@ -897,14 +897,14 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -897,14 +897,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
c.set(Calendar.MILLISECOND, 0); c.set(Calendar.MILLISECOND, 0);
java.util.Date nowDate = c.getTime(); java.util.Date nowDate = c.getTime();
assertEquals(nowDate, rs.getTimestamp(2)); assertEquals(nowDate, rs.getTimestamp(2));
try { try {
rs = stat.executeQuery("SELECT TRUNCATE('bad', 1) FROM dual"); rs = stat.executeQuery("SELECT TRUNCATE('bad', 1) FROM dual");
fail("expected exception"); fail("expected exception");
} catch (SQLException ex) { } catch (SQLException ex) {
// expected // expected
} }
// check for passing wrong data type // check for passing wrong data type
try { try {
rs = stat.executeQuery("SELECT TRUNCATE('bad') FROM dual"); rs = stat.executeQuery("SELECT TRUNCATE('bad') FROM dual");
...@@ -912,7 +912,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -912,7 +912,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
} catch (SQLException ex) { } catch (SQLException ex) {
// expected // expected
} }
// check for too many parameters // check for too many parameters
try { try {
rs = stat.executeQuery("SELECT TRUNCATE(1,2,3) FROM dual"); rs = stat.executeQuery("SELECT TRUNCATE(1,2,3) FROM dual");
...@@ -920,10 +920,10 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -920,10 +920,10 @@ public class TestFunctions extends TestBase implements AggregateFunction {
} catch (SQLException ex) { } catch (SQLException ex) {
// expected // expected
} }
conn.close(); conn.close();
} }
private void assertCallResult(String expected, Statement stat, String sql) throws SQLException { private void assertCallResult(String expected, Statement stat, String sql) throws SQLException {
ResultSet rs = stat.executeQuery("CALL " + sql); ResultSet rs = stat.executeQuery("CALL " + sql);
rs.next(); rs.next();
......
...@@ -783,12 +783,15 @@ public class TestOptimizations extends TestBase { ...@@ -783,12 +783,15 @@ public class TestOptimizations extends TestBase {
conn.close(); conn.close();
} }
/** Where there are multiple indices, and we have an ORDER BY, select the index that already has the required ordering. */ /**
* Where there are multiple indices, and we have an ORDER BY, select the
* index that already has the required ordering.
*/
private void testOrderedIndexes() throws SQLException { private void testOrderedIndexes() throws SQLException {
deleteDb("optimizations"); deleteDb("optimizations");
Connection conn = getConnection("optimizations"); Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR, PRIMARY KEY(K1,K2))"); stat.execute("CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR, PRIMARY KEY(K1,K2))");
stat.execute("CREATE INDEX my_index ON my_table(K1,VAL);"); stat.execute("CREATE INDEX my_index ON my_table(K1,VAL);");
ResultSet rs = stat.executeQuery("EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,VAL"); ResultSet rs = stat.executeQuery("EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,VAL");
...@@ -796,15 +799,17 @@ public class TestOptimizations extends TestBase { ...@@ -796,15 +799,17 @@ public class TestOptimizations extends TestBase {
assertContains(rs.getString(1), "/* PUBLIC.MY_INDEX: K1 = 7 */"); assertContains(rs.getString(1), "/* PUBLIC.MY_INDEX: K1 = 7 */");
stat.execute("DROP TABLE my_table"); stat.execute("DROP TABLE my_table");
// where we have two covering indexes, make sure we choose the one that covers more // where we have two covering indexes, make sure
// we choose the one that covers more
stat.execute("CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)"); stat.execute("CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)");
stat.execute("CREATE INDEX my_index1 ON my_table(K1,K2);"); stat.execute("CREATE INDEX my_index1 ON my_table(K1,K2);");
stat.execute("CREATE INDEX my_index2 ON my_table(K1,K2,VAL);"); stat.execute("CREATE INDEX my_index2 ON my_table(K1,K2,VAL);");
rs = stat.executeQuery("EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,K2,VAL"); rs = stat.executeQuery("EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,K2,VAL");
rs.next(); rs.next();
assertContains(rs.getString(1), "/* PUBLIC.MY_INDEX2: K1 = 7 */"); assertContains(rs.getString(1), "/* PUBLIC.MY_INDEX2: K1 = 7 */");
conn.close(); conn.close();
} }
} }
...@@ -79,9 +79,9 @@ public class TestMVStore extends TestBase { ...@@ -79,9 +79,9 @@ public class TestMVStore extends TestBase {
testIterate(); testIterate();
testCloseTwice(); testCloseTwice();
testSimple(); testSimple();
// longer running tests // longer running tests
testLargerThan2G(); testLargerThan2G();
} }
...@@ -1360,7 +1360,7 @@ public class TestMVStore extends TestBase { ...@@ -1360,7 +1360,7 @@ public class TestMVStore extends TestBase {
} }
s.close(); s.close();
} }
private void testLargerThan2G() throws IOException { private void testLargerThan2G() throws IOException {
if (!config.big) { if (!config.big) {
return; return;
......
...@@ -42,7 +42,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -42,7 +42,7 @@ public class TestMVTableEngine extends TestBase {
testLocking(); testLocking();
testSimple(); testSimple();
} }
private void testSpeed() throws Exception { private void testSpeed() throws Exception {
String dbName; String dbName;
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
...@@ -56,7 +56,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -56,7 +56,7 @@ public class TestMVTableEngine extends TestBase {
// System.out.println(prof.getTop(10)); // System.out.println(prof.getTop(10));
} }
} }
private void testSpeed(String dbName) throws Exception { private void testSpeed(String dbName) throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
......
...@@ -78,7 +78,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -78,7 +78,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
testFuzzOperations(); testFuzzOperations();
deleteDb("pageStore"); deleteDb("pageStore");
} }
private void testDropTempTable() throws SQLException { private void testDropTempTable() throws SQLException {
deleteDb("pageStoreDropTemp"); deleteDb("pageStoreDropTemp");
Connection c1 = getConnection("pageStoreDropTemp"); Connection c1 = getConnection("pageStoreDropTemp");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论