[ 
https://issues.apache.org/jira/browse/PHOENIX-4983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709181#comment-16709181
 ] 

ASF GitHub Bot commented on PHOENIX-4983:
-----------------------------------------

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). 


> Allow using a connection with a SCN set to write data to tables EXCEPT 
> transactional tables or mutable tables with indexes or tables with a 
> ROW_TIMESTAMP column
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-4983
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4983
>             Project: Phoenix
>          Issue Type: New Feature
>            Reporter: Thomas D'Silva
>            Assignee: Swaroopa Kadam
>            Priority: Major
>              Labels: SFDC
>         Attachments: PHOENIX-4983-4.x-HBase-1.4.patch
>
>
> Currently If a SCN is set on a connection it is read-only. We only need to 
> prevent a client from using a connection with a SCN set to upsert data for:
> 1) transactional tables 
> 2) mutable tables with indexes 
> 3) tables with a ROW_TIMESTAMP column



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to