[ 
https://issues.apache.org/jira/browse/PHOENIX-1131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Samarth Jain updated PHOENIX-1131:
----------------------------------

    Attachment: PHOENIX-1131-3.0.patch

[~jamestaylor] - please review and commit. Thanks!

> PhoenixRuntime.encodePk needs to pad row key values to max column length
> ------------------------------------------------------------------------
>
>                 Key: PHOENIX-1131
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1131
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.0.0, 3.1, 4.1
>            Reporter: Samarth Jain
>            Assignee: Samarth Jain
>         Attachments: PHOENIX-1131-3.0.patch
>
>
> {code}
> @Test
>     public void testEncodeDecodePaddingPks() throws Exception {
>         Connection conn = DriverManager.getConnection(getUrl());
>         conn.createStatement().execute(
>                 "CREATE TABLE T(pk1 CHAR(15) not null, pk2 CHAR(15) not null, 
> v1 DATE " +
>                 "CONSTRAINT pk PRIMARY KEY (pk1, pk2))");
>         
>         PreparedStatement stmt = conn.prepareStatement("UPSERT INTO T (pk1, 
> pk2, v1) VALUES (?, ?, ?)");
>         stmt.setString(1,  "def");
>         stmt.setString(2,  "eid");
>         stmt.setDate(3, new Date(100));
>         stmt.executeUpdate();
>         conn.commit();
>         stmt = conn.prepareStatement("SELECT pk1, pk2 FROM T");
>         Object[] retrievedValues = new Object[2];
>         ResultSet rs = stmt.executeQuery();
>         rs.next();
>         retrievedValues[0] = rs.getString(1);
>         retrievedValues[1] = rs.getString(2);
>         
>         byte[] value = PhoenixRuntime.encodePK(conn, "T", retrievedValues);
>         Object[] decodedValues = PhoenixRuntime.decodePK(conn, "T", value);
>         assertEquals(Arrays.asList(decodedValues), 
> Arrays.asList(retrievedValues));
> }
>    
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to