Github user twdsilva commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/405#discussion_r238793618
--- Diff:
phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertWithSCNIT.java ---
@@ -0,0 +1,167 @@
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+
+public class UpsertWithSCNIT extends ParallelStatsDisabledIT {
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+
+
+ @Test // See https://issues.apache.org/jira/browse/PHOENIX-4983
+ public void testUpsertOnSCNSetTxnTable() throws SQLException {
+
+ String trnx = "CREATE TABLE transaction_table (METRIC_ID CHAR(15)
NOT NULL,\n" +
+ "METRIC_VALUE VARCHAR(50) \n" +
+ "CONSTRAINT PK PRIMARY KEY(METRIC_ID))
TRANSACTION_PROVIDER='TEPHRA',TRANSACTIONAL=true";
+ Properties props = new Properties();
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ conn.createStatement().execute(trnx);
+ props.setProperty("CurrentSCN",
Long.toString(System.currentTimeMillis()));
+ conn = DriverManager.getConnection(getUrl(), props);
+ conn.setAutoCommit(true);
+
+ String upsert = "UPSERT INTO transaction_table(METRIC_ID,
METRIC_VALUE) VALUES (?,?)";
+ PreparedStatement prep = conn.prepareStatement(upsert);
+ prep.setString(1,"abc");
+ prep.setString(2,"This is the first comment!");
+ exception.expect(SQLException.class);
+ exception.expectMessage(containsString("ERROR 1075 (44A06): Cannot
use a " +
+ "connection with SCN set for a transactional table."));
+ prep.executeUpdate();
+
+ }
+ @Test
+ public void testUpsertOnSCNSetMutTable() throws Exception {
--- End diff --
add a helper function to test the tables that are mutable/immutable and
which don't have an index, have a global index or a local index (and pass these
options in as parameters).
---