Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 bf4262a99 -> 611c86063
http://git-wip-us.apache.org/repos/asf/phoenix/blob/611c8606/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java index f72caf9..c5283cd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java @@ -50,7 +50,6 @@ import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.schema.types.PTimestamp; -import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; @@ -76,25 +75,16 @@ public class QueryIT extends BaseQueryIT { " A_INTEGER) " + "VALUES (?, ?, ?)"; // Override value that was set at creation time - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection upsertConn = DriverManager.getConnection(url, props); - upsertConn.setAutoCommit(true); // Test auto commit - PreparedStatement stmt = upsertConn.prepareStatement(updateStmt); + Connection conn = DriverManager.getConnection(url, props); + PreparedStatement stmt = conn.prepareStatement(updateStmt); stmt.setString(1, tenantId); stmt.setString(2, ROW4); stmt.setInt(3, -10); stmt.execute(); - upsertConn.close(); - url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 6); - props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - upsertConn = DriverManager.getConnection(url, props); - analyzeTable(upsertConn, tableName); - upsertConn.close(); - + conn.commit(); + String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and a_integer >= ?"; - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 - Connection conn = DriverManager.getConnection(getUrl(), props); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); statement.setInt(2, 7); @@ -127,7 +117,6 @@ public class QueryIT extends BaseQueryIT { public void testToDateOnString() throws Exception { // TODO: test more conversion combinations String query = "SELECT a_string FROM " + tableName + " WHERE organization_id=? and a_integer = 5"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -143,12 +132,10 @@ public class QueryIT extends BaseQueryIT { } } - @Test public void testColumnOnBothSides() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and a_string = b_string"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -165,7 +152,6 @@ public class QueryIT extends BaseQueryIT { @Test public void testDateInList() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE a_date IN (?,?) AND a_integer < 4"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { @@ -191,7 +177,6 @@ public class QueryIT extends BaseQueryIT { " A_TIMESTAMP) " + "VALUES (?, ?, ?)"; // Override value that was set at creation time - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 10); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection upsertConn = DriverManager.getConnection(url, props); upsertConn.setAutoCommit(true); // Test auto commit @@ -203,7 +188,6 @@ public class QueryIT extends BaseQueryIT { stmt.setTimestamp(3, tsValue1); stmt.execute(); - url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 15); Connection conn1 = DriverManager.getConnection(url, props); analyzeTable(conn1, tableName); conn1.close(); @@ -231,8 +215,7 @@ public class QueryIT extends BaseQueryIT { assertFalse(compare(CompareOp.GREATER, new ImmutableBytesWritable(ts1), new ImmutableBytesWritable(ts1))); String query = "SELECT entity_id, a_timestamp, a_time FROM " + tableName + " WHERE organization_id=? and a_timestamp > ?"; - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); // Execute at timestamp 2 - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = DriverManager.getConnection(url, props); try { PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); @@ -251,7 +234,6 @@ public class QueryIT extends BaseQueryIT { @Test public void testSimpleInListStatement() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND a_integer IN (2,4)"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { @@ -267,7 +249,6 @@ public class QueryIT extends BaseQueryIT { @Test public void testPartiallyQualifiedRVCInList() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE (a_integer,a_string) IN ((2,'a'),(5,'b'))"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { @@ -282,7 +263,6 @@ public class QueryIT extends BaseQueryIT { @Test public void testFullyQualifiedRVCInList() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE (a_integer,a_string, organization_id,entity_id) IN ((2,'a',:1,:2),(5,'b',:1,:3))"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { @@ -300,7 +280,6 @@ public class QueryIT extends BaseQueryIT { @Test public void testOneInListStatement() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND b_string IN (?)"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { @@ -324,7 +303,6 @@ public class QueryIT extends BaseQueryIT { @Test public void testMixedTypeInListStatement() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND x_long IN (5, ?)"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { @@ -347,7 +325,6 @@ public class QueryIT extends BaseQueryIT { public void testIsNull() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE X_DECIMAL is null"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -374,7 +351,6 @@ public class QueryIT extends BaseQueryIT { public void testIsNotNull() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE X_DECIMAL is not null"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -405,7 +381,6 @@ public class QueryIT extends BaseQueryIT { for (String query : queries) { Properties props = new Properties(); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -424,7 +399,6 @@ public class QueryIT extends BaseQueryIT { public void testRowKeySingleIn() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id IN (?,?,?)"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -450,7 +424,6 @@ public class QueryIT extends BaseQueryIT { public void testRowKeyMultiIn() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id IN (?,?,?) and a_string IN (?,?)"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -475,7 +448,6 @@ public class QueryIT extends BaseQueryIT { public void testColumnAliasMapping() throws Exception { String query = "SELECT a.a_string, " + tableName + ".b_string FROM " + tableName + " a WHERE ?=organization_id and 5=a_integer ORDER BY a_string, b_string"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); http://git-wip-us.apache.org/repos/asf/phoenix/blob/611c8606/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java index c77c06f..2bde28c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java @@ -43,7 +43,6 @@ import java.util.HashSet; import java.util.Properties; import java.util.Set; -import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.runner.RunWith; @@ -70,7 +69,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScan() throws Exception { String query = "SELECT a_string, /* comment ok? */ b_string FROM " + tableName + " WHERE ?=organization_id and 5=a_integer"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -89,7 +87,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScanByByteValue() throws Exception { String query = "SELECT a_string, b_string, a_byte FROM " + tableName + " WHERE ?=organization_id and 1=a_byte"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -109,7 +106,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScanByShortValue() throws Exception { String query = "SELECT a_string, b_string, a_short FROM " + tableName + " WHERE ?=organization_id and 128=a_short"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -129,7 +125,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScanByFloatValue() throws Exception { String query = "SELECT a_string, b_string, a_float FROM " + tableName + " WHERE ?=organization_id and ?=a_float"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -150,7 +145,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScanByUnsignedFloatValue() throws Exception { String query = "SELECT a_string, b_string, a_unsigned_float FROM " + tableName + " WHERE ?=organization_id and ?=a_unsigned_float"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -171,7 +165,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScanByDoubleValue() throws Exception { String query = "SELECT a_string, b_string, a_double FROM " + tableName + " WHERE ?=organization_id and ?=a_double"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -192,7 +185,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testScanByUnsigned_DoubleValue() throws Exception { String query = "SELECT a_string, b_string, a_unsigned_double FROM " + tableName + " WHERE ?=organization_id and ?=a_unsigned_double"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -213,7 +205,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testAllScan() throws Exception { String query = "SELECT ALL a_string, b_string FROM " + tableName + " WHERE ?=organization_id and 5=a_integer"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -232,7 +223,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testDistinctScan() throws Exception { String query = "SELECT DISTINCT a_string FROM " + tableName + " WHERE organization_id=?"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -254,7 +244,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testDistinctLimitScan() throws Exception { String query = "SELECT DISTINCT a_string FROM " + tableName + " WHERE organization_id=? LIMIT 1"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -272,7 +261,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testInListSkipScan() throws Exception { String query = "SELECT entity_id, b_string FROM " + tableName + " WHERE organization_id=? and entity_id IN (?,?)"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -299,7 +287,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testUnboundRangeScan1() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id <= ?"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -333,7 +320,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testUnboundRangeScan2() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id >= ?"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -367,7 +353,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testUpperLowerBoundRangeScan() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and substr(entity_id,1,3) > '00A' and substr(entity_id,1,3) < '00C'"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -391,7 +376,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testUpperBoundRangeScan() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and substr(entity_id,1,3) >= '00B' "; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); @@ -417,7 +401,6 @@ public class ScanQueryIT extends BaseQueryIT { public void testLowerBoundRangeScan() throws Exception { String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and substr(entity_id,1,3) < '00B' "; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); http://git-wip-us.apache.org/repos/asf/phoenix/blob/611c8606/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java index 2a3dd54..10f465f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java @@ -1376,4 +1376,69 @@ public class SequenceIT extends BaseClientManagedTimeIT { assertFalse(rs.next()); } + @Test + public void testPointInTimeSequence() throws Exception { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Connection conn; + ResultSet rs; + String seqName = generateUniqueName(); + long ts = nextTimestamp(); + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5)); + conn = DriverManager.getConnection(getUrl(), props); + conn.createStatement().execute("CREATE SEQUENCE " + seqName + ""); + + try { + conn.createStatement().executeQuery("SELECT next value for " + seqName); + fail(); + } catch (SequenceNotFoundException e) { + conn.close(); + } + + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); + conn = DriverManager.getConnection(getUrl(), props); + rs = conn.createStatement().executeQuery("SELECT next value for " + seqName); + assertTrue(rs.next()); + assertEquals(1, rs.getInt(1)); + conn.close(); + + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 7)); + conn = DriverManager.getConnection(getUrl(), props); + rs = conn.createStatement().executeQuery("SELECT next value for " + seqName); + assertTrue(rs.next()); + assertEquals(2, rs.getInt(1)); + conn.close(); + + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 15)); + conn = DriverManager.getConnection(getUrl(), props); + conn.createStatement().execute("DROP SEQUENCE " + seqName + ""); + rs = conn.createStatement().executeQuery("SELECT next value for " + seqName); + assertTrue(rs.next()); + assertEquals(3, rs.getInt(1)); + conn.close(); + + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20)); + conn = DriverManager.getConnection(getUrl(), props); + try { + rs = conn.createStatement().executeQuery("SELECT next value for " + seqName); + fail(); + } catch (SequenceNotFoundException e) { // expected + } + + conn.createStatement().execute("CREATE SEQUENCE " + seqName); + conn.close(); + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 25)); + conn = DriverManager.getConnection(getUrl(), props); + rs = conn.createStatement().executeQuery("SELECT next value for " + seqName); + assertTrue(rs.next()); + assertEquals(1, rs.getInt(1)); + conn.close(); + + props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 6)); + conn = DriverManager.getConnection(getUrl(), props); + rs = conn.createStatement().executeQuery("SELECT next value for " + seqName); + assertTrue(rs.next()); + assertEquals(4, rs.getInt(1)); + conn.close(); + } + } \ No newline at end of file