Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E3252200C60 for ; Mon, 24 Apr 2017 21:23:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E1B5B160B99; Mon, 24 Apr 2017 19:23:41 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3504B160B93 for ; Mon, 24 Apr 2017 21:23:41 +0200 (CEST) Received: (qmail 32375 invoked by uid 500); 24 Apr 2017 19:23:40 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 32345 invoked by uid 99); 24 Apr 2017 19:23:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Apr 2017 19:23:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E43D5E0016; Mon, 24 Apr 2017 19:23:39 +0000 (UTC) From: bijugs To: dev@phoenix.apache.org Reply-To: dev@phoenix.apache.org References: In-Reply-To: Subject: [GitHub] phoenix pull request #229: PHOENIX-3572 Support FETCH NEXT|n ROWS query on c... Content-Type: text/plain Message-Id: <20170424192339.E43D5E0016@git1-us-west.apache.org> Date: Mon, 24 Apr 2017 19:23:39 +0000 (UTC) archived-at: Mon, 24 Apr 2017 19:23:42 -0000 Github user bijugs commented on a diff in the pull request: https://github.com/apache/phoenix/pull/229#discussion_r113034318 --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java --- @@ -0,0 +1,687 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.end2end; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.phoenix.util.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.math.BigDecimal; +import java.sql.*; +import java.util.Properties; +import java.util.Random; + +import static org.apache.phoenix.util.TestUtil.*; +import static org.junit.Assert.*; + + +public class CursorWithRowValueConstructorIT extends BaseClientManagedTimeIT { + private static final String TABLE_NAME = "CursorRVCTestTable"; + protected static final Log LOG = LogFactory.getLog(CursorWithRowValueConstructorIT.class); + + public void createAndInitializeTestTable() throws SQLException { + Connection conn = DriverManager.getConnection(getUrl()); + + PreparedStatement stmt = conn.prepareStatement("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + + "(a_id INTEGER NOT NULL, " + + "a_data INTEGER, " + + "CONSTRAINT my_pk PRIMARY KEY (a_id))"); + stmt.execute(); + synchronized (conn){ + conn.commit(); + } + + //Upsert test values into the test table + Random rand = new Random(); + stmt = conn.prepareStatement("UPSERT INTO " + TABLE_NAME + + "(a_id, a_data) VALUES (?,?)"); + int rowCount = 0; + while(rowCount < 100){ + stmt.setInt(1, rowCount); + stmt.setInt(2, rand.nextInt(501)); + stmt.execute(); + ++rowCount; + } + synchronized (conn){ + conn.commit(); + } + } + + public void deleteTestTable() throws SQLException { + Connection conn = DriverManager.getConnection(getUrl()); + PreparedStatement stmt = conn.prepareStatement("DROP TABLE IF EXISTS " + TABLE_NAME); + stmt.execute(); + synchronized (conn){ + conn.commit(); + } + } + + @Test + public void testCursorsOnTestTablePK() throws SQLException { + try{ + createAndInitializeTestTable(); + String querySQL = "SELECT a_id FROM " + TABLE_NAME; + + //Test actual cursor implementation + String cursorSQL = "DECLARE testCursor CURSOR FOR " + querySQL; + DriverManager.getConnection(getUrl()).prepareStatement(cursorSQL).execute(); + cursorSQL = "OPEN testCursor"; + DriverManager.getConnection(getUrl()).prepareStatement(cursorSQL).execute(); + cursorSQL = "FETCH NEXT FROM testCursor"; --- End diff -- Since this PR is for ``FETCH NEXT`` will remove the code related to ``FETCH PRIOR``. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---