From dev-return-44882-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Thu Feb 21 13:27:32 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6D2C818064C for ; Thu, 21 Feb 2019 14:27:32 +0100 (CET) Received: (qmail 82517 invoked by uid 500); 21 Feb 2019 13:27:31 -0000 Mailing-List: contact dev-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list dev@ignite.apache.org Received: (qmail 82501 invoked by uid 99); 21 Feb 2019 13:27:30 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Feb 2019 13:27:30 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 5026BC63DC for ; Thu, 21 Feb 2019 13:27:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=6.31 tests=[DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gridgain-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ajUyyNhchxj8 for ; Thu, 21 Feb 2019 13:27:29 +0000 (UTC) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id A552A623E2 for ; Thu, 21 Feb 2019 13:27:28 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id u21so20393371lfu.1 for ; Thu, 21 Feb 2019 05:27:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gridgain-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=gGuXn6VYYpaepPYafb4t9cw46pmSIcGPteqluj3pNHk=; b=Xbx2xBpr9lh/chcpiIJ17t0duEir5beIDY1R3/2iNeZeVvgHsZhg1dYbpT8BDiIqcI VGUlM/Y4wrVbF/+goL8gPsnzILrAAmBShS6lXis44Ncb/l6qCjNyQF/vf6B139BIViXT VNp0usSIBfhbPEyLujgmj1GD8zjfHHKviKoTFgL6TlDAymI1iTYIocspPHCriPyw1k5m 7VR07GQdmyRdepyO++NneNXTZVdAu+D0/J27M4ouFvv57LHloQixz7FfcSpremh3lfiH K3DsGTGSEJ7yDVDXw52gSplOuLS4WgjhfH7DIZENNXRmKGRXRdk9BHjLjyTG4hdMhtuD poIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=gGuXn6VYYpaepPYafb4t9cw46pmSIcGPteqluj3pNHk=; b=Z6XCJxSQzA1wheKLedwlLtsZEETzzrBIlRrmRXeBS8MDt7/rQKMN4uNSIHtCWKD6FI 5RDpisBeibqRrmoJK+tkEhAZw9AHFVsYauRmyNb5QDee4b9h77wWrdt9Q8sQiZ1scshI 3FX9grYXIczn3UhoqepvTeQN7uQiw0y9Ju1di37cI03dOVwuC2tFJLr6xtCqzziTnZz9 qgkOHLUGjSFM1YsFnKvWV+FQCaxqE7SVEg/M0zyVYH2+sDp9Dz54KE/VOy4IWLjQZcjm KsOmriRtxXTjm4iw7vlnSXGsG2sfzznKDEJHYmXjSfbytg6+2CPMhey8JT1T9rivz1PS lq/g== X-Gm-Message-State: AHQUAubj8BOaxfOwpNqB4zuu88cLQcJfIP7qnznP6L/78xotqiClwW/q +ADxT1n2u89NXSyOLczivV/2lA== X-Google-Smtp-Source: AHgI3IbIgemelbfqjDrkVIT4edBRPd3W2ybabJsYsoS27zwD2Fb02L4znQAXRqe0wjtFOu7C065G+w== X-Received: by 2002:a19:9c87:: with SMTP id f129mr7251672lfe.77.1550755647945; Thu, 21 Feb 2019 05:27:27 -0800 (PST) Received: from [172.25.4.56] ([195.239.208.174]) by smtp.gmail.com with ESMTPSA id x16sm6669444lff.72.2019.02.21.05.27.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 05:27:27 -0800 (PST) From: Taras Ledkov Subject: SQL: INSERT with hidden columns _key, _val and check the type of input objects To: dev@ignite.apache.org Message-ID: <70d96a86-6eed-9ad5-816a-be4f76ff6cbf@gridgain.com> Date: Thu, 21 Feb 2019 16:27:25 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Hi, Lets discuss SQL DML (INSERT/UPDATE) current behavior specific: Ignite doesn't check a type of input objects when hidden columns _key, _value is used in a DML statements. I describe the current behavior for example: 1. Cache configuration:  'setIndexedTypes(PersonKey.class, Person.class))' 2.  PersonKey type contains 'int id' field. 3. SQL statement: 'INSERT INTO test (_val, _key) VALUES (?, ?)' Cases: 1. Invalid value object type: - Any value object may be passed as a query parameter - Query is executed without an error and returns '1' (one row updated); - There is not inserted row at the 'SELECT * FROM test' results. - cache.get(key) returns inserted object; 2. Invalid key object type: 2.1 Non-primitive object is passed and binary representation doesn't contain 'id' field. - Query is executed without error and returns '1' (one row updated); - The inserted row is available by 'SELECT *' and the row contains id = null; 2.2 Non-primitive object is passed and binary representation contains 'id' field. - The inserted row is available by 'SELECT *' and the row contains expected 'id' field; - The cache entry cannot be gathered by 'cache.get' operation with the corresponding 'PersonKey(id)' (keys differ). I propose to check type of the user's input object. I guess that using _key/_val columns works close to 'cache.put()' but it looks like significant usability issue. To confuse the 'PersonKey.class.getName()' and 'node.binary().builder("PersonKey")' is a typical mistake of Ignite newcomers. One more argument for check: SQL INSERT sematic means the row is inserted into the specified TABLE, not into the cache. So, throw IgniteSQLException is expected behavior in this case, i think. [1]. https://issues.apache.org/jira/browse/IGNITE-5250 -- Taras Ledkov Mail-To: tledkov@gridgain.com