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 47FED200BC2 for ; Thu, 3 Nov 2016 06:19:19 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 468F1160B0B; Thu, 3 Nov 2016 05:19:19 +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 8ECCF160AFB for ; Thu, 3 Nov 2016 06:19:18 +0100 (CET) Received: (qmail 70111 invoked by uid 500); 3 Nov 2016 05:19:17 -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 70072 invoked by uid 99); 3 Nov 2016 05:19:17 -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; Thu, 03 Nov 2016 05:19:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 58102E0FA0; Thu, 3 Nov 2016 05:19:17 +0000 (UTC) From: maryannxue To: dev@phoenix.apache.org Reply-To: dev@phoenix.apache.org References: In-Reply-To: Subject: [GitHub] phoenix pull request #220: PHOENIX-3394 Handle SequenceResolving through Con... Content-Type: text/plain Message-Id: <20161103051917.58102E0FA0@git1-us-west.apache.org> Date: Thu, 3 Nov 2016 05:19:17 +0000 (UTC) archived-at: Thu, 03 Nov 2016 05:19:19 -0000 Github user maryannxue commented on a diff in the pull request: https://github.com/apache/phoenix/pull/220#discussion_r86287165 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java --- @@ -329,24 +333,14 @@ private TableRef fixTableMultiTenancy(TableRef tableRef) throws SQLException { private PhoenixSequence resolveSequence(String name) { try { - // FIXME: Do this the same way as resolving a table after PHOENIX-2489. - String tenantId = pc.getTenantId() == null ? null : pc.getTenantId().getString(); - String q = "select 1 from " + PhoenixDatabaseMetaData.SYSTEM_SEQUENCE - + " where " + PhoenixDatabaseMetaData.SEQUENCE_SCHEMA - + (schemaName == null ? " is null" : " = '" + schemaName + "'") - + " and " + PhoenixDatabaseMetaData.SEQUENCE_NAME - + " = '" + name + "'" - + " and " + PhoenixDatabaseMetaData.TENANT_ID - + (tenantId == null ? " is null" : " = '" + tenantId + "'"); - ResultSet rs = pc.createStatement().executeQuery(q); - if (rs.next()) { - return new PhoenixSequence(schemaName, name, pc); - } - } catch (SQLException e) { - throw new RuntimeException(e); + SequenceManager manager = new SequenceManager((PhoenixStatement)pc.createStatement()); + manager.newSequenceReference(pc.getTenantId(), TableName.createNormalized(schemaName, name) , null, SequenceValueParseNode.Op.NEXT_VALUE); --- End diff -- @JamesRTaylor Could you also take a look here to make sure that the method is called with right parameters? And is there a chance (and a need) we can avoid creating a new "Statement" each time? --- 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. ---