From patchwork Sat Aug 11 03:29:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 956518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N75oAyaB"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41nSq30Nzpz9s82 for ; Sat, 11 Aug 2018 13:56:46 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2B4BEBDB; Sat, 11 Aug 2018 03:56:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 977E9BCF for ; Sat, 11 Aug 2018 03:56:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F1BCB174 for ; Sat, 11 Aug 2018 03:56:40 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id y10-v6so5358659pfn.8 for ; Fri, 10 Aug 2018 20:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/zrDhMWfF9sm9KRixjZ/7xMQrEYnwcwpyLO+ht/zKoY=; b=N75oAyaB8ZxkOqpIRrEYwIVvqYy/FKIAv6t0drHXamfRmvglPn7iQqE+0B/a4kYkYQ zI9vNj3iWiRAC01PGjLC2BK0JjpnCVfhhsL3TX92LEOxbkXlcAHQIbI6fkdrSsziDIHW GJWvmUsz8DiuW3SH75y/qzMFddaB7VfytZxSWEAkzxZOxW4F2II1CwCTa5kSyH/ObjOB 9rxmGhg3Km9t4h30a4nHg68iyYhxYG65YRB0IOfNu1U6z9Me0PjQMxwYKlGtPKfFozjk 4mvphd6R3Urt9Vz87CeUDfNeoET5qlEa1psW9EAZ+3lkkVHoWSHAzOAuk3aPHUzK2Bqr vRfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/zrDhMWfF9sm9KRixjZ/7xMQrEYnwcwpyLO+ht/zKoY=; b=BRXyRu8YG4vOFTJZUUBgmzRpXChWHfqXONJaxklbUWafBPU34+KTZXizM9uBFyLHzU yGyXexh9+K0RhOsTtWLNGTUHjMlgKtI0lXyB4D7M34DhLk9MYbms00Q1o/6LU5xxI808 Vn0fPAVstKHuPGHJ5Q+mO504ocu233cAYG+3/KtL0amhZmOsvslM333ScAkI4/q+Sav8 gW7TCA8v9ScA5F3LA4WS1viwheVa+gEXUF7JK46u0peR8I0btnBjFNAFKAs6/xmKB57j 2EhJoKg3p9+5MRM4gCjrkxVC6isWqaG14cGDbcxpEPX4gdyBAMEBXbHZyC9VkSxvod5M ymlw== X-Gm-Message-State: AOUpUlGQbayRWDHdRrtop8J5jmo4MfMIyRDtN2Ilm4t50Dh27/XeiQLB HZ2m3RdXzl5AAzBw64yCSptDC3DO X-Google-Smtp-Source: AA+uWPx6ZrSqwNKktn1ihD58MCFcM/dGbTdh9FXEjfMHjCV36/rGae7eVZgxicXXmwcq23hDLK570g== X-Received: by 2002:a63:7007:: with SMTP id l7-v6mr8778697pgc.206.1533959800246; Fri, 10 Aug 2018 20:56:40 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-73-162-150-77.hsd1.ca.comcast.net. [73.162.150.77]) by smtp.gmail.com with ESMTPSA id v3-v6sm31047677pgb.54.2018.08.10.20.56.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 20:56:39 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Fri, 10 Aug 2018 20:29:45 -0700 Message-Id: <1533958186-76425-1-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] test-ovsdb.c: Fix wrong indent. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Han Zhou --- tests/test-ovsdb.c | 164 ++++++++++++++++++++++++++--------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index de94fd0..e4e7d90 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -2827,88 +2827,88 @@ test_idl_compound_index_single_column(struct ovsdb_idl *idl, struct ovsdb_idl_txn *txn; int step = 0; - /* Display records by string index. */ - ++step; - IDLTEST_SIMPLE_FOR_EACH_BYINDEX (myRow, s_index) { - printf("%03d: s=%s i=%"PRId64" b=%s r=%f\n", step, myRow->s, - myRow->i, myRow->b?"True":"False", myRow->r); - } - /* Display records by integer index. */ - ++step; - IDLTEST_SIMPLE_FOR_EACH_BYINDEX (myRow, i_index) { - printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, - myRow->s, myRow->b?"True":"False", myRow->r); - } - /* Display records by string index -> s_index with filtering - * where s=\"List001\ - */ - ++step; - struct idltest_simple *equal = idltest_simple_index_init_row(s_index); - idltest_simple_index_set_s(equal, "List001"); - ovs_assert(strcmp(equal->s, "List001") == 0); - IDLTEST_SIMPLE_FOR_EACH_EQUAL (myRow, equal, s_index) { - printf("%03d: s=%s i=%"PRId64" b=%s r=%f\n", step, myRow->s, - myRow->i, myRow->b?"True":"False", myRow->r); - } - /* Display records by integer index -> i_index with filtering where i=5 */ - ++step; - idltest_simple_index_set_i(equal, 5); - ovs_assert(equal->i == 5); - IDLTEST_SIMPLE_FOR_EACH_EQUAL (myRow, equal, i_index) { - printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, - myRow->s, myRow->b?"True":"False", myRow->r); - } - /* Display records by integer index -> i_index in range i=[3,7] */ - ++step; - struct idltest_simple *from, *to; - from = idltest_simple_index_init_row(i_index); - idltest_simple_index_set_i(from, 3); - ovs_assert(from->i == 3); - to = idltest_simple_index_init_row(i_index); - idltest_simple_index_set_i(to, 7); - ovs_assert(to->i == 7); - IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, from, to, i_index) { - printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, - myRow->s, myRow->b?"True":"False", myRow->r); - } - /* Delete record i=4 and insert i=54 by integer index -> i_index */ - ++step; - struct idltest_simple *toDelete, *toInsert; - toDelete = idltest_simple_index_init_row(i_index); - idltest_simple_index_set_i(toDelete, 4); - ovs_assert(toDelete->i == 4); - myRow = idltest_simple_index_find(i_index, toDelete); - ovs_assert(myRow); - ovs_assert(myRow->i == 4); - txn = ovsdb_idl_txn_create(idl); - idltest_simple_delete(myRow); - toInsert = idltest_simple_insert(txn); - idltest_simple_set_i(toInsert, 54); - idltest_simple_set_s(toInsert, "Lista054"); - ovsdb_idl_txn_commit_block(txn); - ovsdb_idl_txn_destroy(txn); - idltest_simple_index_set_i(to, 60); - printf("Expected 60, stored %"PRId64"\n", to->i); - ovs_assert(to->i == 60); - IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, from, to, i_index) { - printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, - myRow->s, myRow->b?"True":"False", myRow->r); - } - - /* Test special-case range, "from" and "to" are both NULL, - * which is interpreted as the range from -infinity to +infinity. */ - ++step; - IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, NULL, NULL, i_index) { - printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, - myRow->s, myRow->b?"True":"False", myRow->r); - } - - /* Free the temporal rows */ - idltest_simple_index_destroy_row(from); - idltest_simple_index_destroy_row(to); - idltest_simple_index_destroy_row(equal); - idltest_simple_index_destroy_row(toDelete); - return step; + /* Display records by string index. */ + ++step; + IDLTEST_SIMPLE_FOR_EACH_BYINDEX (myRow, s_index) { + printf("%03d: s=%s i=%"PRId64" b=%s r=%f\n", step, myRow->s, + myRow->i, myRow->b?"True":"False", myRow->r); + } + /* Display records by integer index. */ + ++step; + IDLTEST_SIMPLE_FOR_EACH_BYINDEX (myRow, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + /* Display records by string index -> s_index with filtering + * where s=\"List001\ + */ + ++step; + struct idltest_simple *equal = idltest_simple_index_init_row(s_index); + idltest_simple_index_set_s(equal, "List001"); + ovs_assert(strcmp(equal->s, "List001") == 0); + IDLTEST_SIMPLE_FOR_EACH_EQUAL (myRow, equal, s_index) { + printf("%03d: s=%s i=%"PRId64" b=%s r=%f\n", step, myRow->s, + myRow->i, myRow->b?"True":"False", myRow->r); + } + /* Display records by integer index -> i_index with filtering where i=5 */ + ++step; + idltest_simple_index_set_i(equal, 5); + ovs_assert(equal->i == 5); + IDLTEST_SIMPLE_FOR_EACH_EQUAL (myRow, equal, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + /* Display records by integer index -> i_index in range i=[3,7] */ + ++step; + struct idltest_simple *from, *to; + from = idltest_simple_index_init_row(i_index); + idltest_simple_index_set_i(from, 3); + ovs_assert(from->i == 3); + to = idltest_simple_index_init_row(i_index); + idltest_simple_index_set_i(to, 7); + ovs_assert(to->i == 7); + IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, from, to, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + /* Delete record i=4 and insert i=54 by integer index -> i_index */ + ++step; + struct idltest_simple *toDelete, *toInsert; + toDelete = idltest_simple_index_init_row(i_index); + idltest_simple_index_set_i(toDelete, 4); + ovs_assert(toDelete->i == 4); + myRow = idltest_simple_index_find(i_index, toDelete); + ovs_assert(myRow); + ovs_assert(myRow->i == 4); + txn = ovsdb_idl_txn_create(idl); + idltest_simple_delete(myRow); + toInsert = idltest_simple_insert(txn); + idltest_simple_set_i(toInsert, 54); + idltest_simple_set_s(toInsert, "Lista054"); + ovsdb_idl_txn_commit_block(txn); + ovsdb_idl_txn_destroy(txn); + idltest_simple_index_set_i(to, 60); + printf("Expected 60, stored %"PRId64"\n", to->i); + ovs_assert(to->i == 60); + IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, from, to, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + + /* Test special-case range, "from" and "to" are both NULL, + * which is interpreted as the range from -infinity to +infinity. */ + ++step; + IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, NULL, NULL, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + + /* Free the temporal rows */ + idltest_simple_index_destroy_row(from); + idltest_simple_index_destroy_row(to); + idltest_simple_index_destroy_row(equal); + idltest_simple_index_destroy_row(toDelete); + return step; } static int From patchwork Sat Aug 11 03:29:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 956519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="e8FrAGEZ"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41nSqd3l54z9s82 for ; Sat, 11 Aug 2018 13:57:17 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E8179C7B; Sat, 11 Aug 2018 03:56:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 11FE6BCF for ; Sat, 11 Aug 2018 03:56:42 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 99AD7174 for ; Sat, 11 Aug 2018 03:56:41 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id u24-v6so5346025pfn.13 for ; Fri, 10 Aug 2018 20:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8ryeAENisFtuq12bYthlyuHEJOHC1sH5XqZHU1MspBI=; b=e8FrAGEZb35APXZLL14+wVuenFUoFXmlTYkjpzVoHyFQM0azTFYp9J5RAvBt7BsiXp iQvroFtLIXHSl+zMI5Y+XTvDRgsjVl/T0rtem5DOc1FzWofSXs9P6oKsBMwNU5HLQRkl /qrTQy+FaJdVhwcrlw/1f6O04tEDjuxdZvLfKL1QamkvdGcF104OeTEn6wS/aku2hnOO up9xHQZ/u0AaKKTF8J2Ggq3fq8BcDMDYYkFqSMnxQ0094am7QYiAsfSGhsk/xyxgLLaA 3B7yWaSDuec4h4BNvituiDmv/58wwVqPwgsYC1KabVDoksin43AECJ7j28Xl6TONbcqb Ef+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8ryeAENisFtuq12bYthlyuHEJOHC1sH5XqZHU1MspBI=; b=h/3Y5vCger8zr5ELlERSi4yzwua7373ECHzz08QXWtW648riTtKE7fJ9sH8oD+jo45 v8LGTvxo5v1qHOLqpaxDCfODeZyyTx613IwQzw+HOwETaCZ4g/4hnQjGVoUw7FHwORxz k0TK5XeX7ZXZ7IYyaz7joNTpWAG2nnVU6i5OqU6qXwl8lrTfstoUOdV9MUMvgEN6pWU+ vC5uLsQ1TIPJVwgGQ/l5nol6doPI6+8Og2+LFxJtOvTrJo6DmD7hCHc9ocSm/Er2AcIG vgzUdAEXoyoaZH8a/k6nn33b5wF4ql4Kf5jVF2dGPtmZ4bLC/fxduyd/4emlhp+5wOmC 9i9A== X-Gm-Message-State: AOUpUlG7t5A3mdlD5MP2m2fft6P6lZStb0PNWFqeDaJ0pYmD9FAlkPLA WLdEA3+ILZshrvMG24Z4E+/UyljI X-Google-Smtp-Source: AA+uWPy5CGZjXsLVYrzaHASu9yKVvS3Ph39GN+HSGwnuZfYafTKtH9zzIxPSPwBfKBTj1XpQ/AnWFA== X-Received: by 2002:a63:f849:: with SMTP id v9-v6mr8669011pgj.71.1533959801035; Fri, 10 Aug 2018 20:56:41 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-73-162-150-77.hsd1.ca.comcast.net. [73.162.150.77]) by smtp.gmail.com with ESMTPSA id v3-v6sm31047677pgb.54.2018.08.10.20.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 20:56:40 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Fri, 10 Aug 2018 20:29:46 -0700 Message-Id: <1533958186-76425-2-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1533958186-76425-1-git-send-email-hzhou8@ebay.com> References: <1533958186-76425-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/2] ovsdb-idl.c: Fix IDL index problem when rows are updated. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org In current IDL index code it doesn't updated index when handling "update2" messages, which is the default case. The consequence is that when a row is updated, the index is not updated accordingly, and even worse, it causes crash when calling ovsdb_idl_destroy(). It can be easily reproduced by the test cases added in this patch. Signed-off-by: Han Zhou --- lib/ovsdb-idl.c | 2 ++ tests/ovsdb-idl.at | 34 ++++++++++++++++++++++------------ tests/test-ovsdb.c | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 40c29cb..8fdd18f 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -3040,11 +3040,13 @@ ovsdb_idl_modify_row_by_diff(struct ovsdb_idl_row *row, { bool changed; + ovsdb_idl_remove_from_indexes(row); ovsdb_idl_row_unparse(row); ovsdb_idl_row_clear_arcs(row, true); changed = ovsdb_idl_row_apply_diff(row, diff_json, OVSDB_IDL_CHANGE_MODIFY); ovsdb_idl_row_parse(row); + ovsdb_idl_add_to_indexes(row); return changed; } diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index 0143828..8db6aa4 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -1509,16 +1509,21 @@ OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column te 006: i=19 006: i=20 006: i=54 -007: i=1 -007: i=1 -007: i=2 -007: i=2 -007: i=2 007: i=5 -007: i=10 007: i=19 007: i=20 +007: i=30 007: i=54 +008: i=1 +008: i=1 +008: i=2 +008: i=2 +008: i=2 +008: i=5 +008: i=19 +008: i=20 +008: i=30 +008: i=54 ], [002: i=1 s=List000 b=True r=101.000000 002: i=1 s=List001 b=False r=110.000000 @@ -1538,16 +1543,21 @@ OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column te 006: i=20 s=List020 b=True r=220.000000 006: i=5 s=List005 b=True r=130.000000 006: i=54 s=Lista054 b=False r=0.000000 -007: i=1 s=List000 b=True r=101.000000 -007: i=1 s=List001 b=False r=110.000000 -007: i=10 s=List000 b=True r=110.000000 007: i=19 s=List020 b=True r=219.000000 -007: i=2 s=List000 b=False r=102.000000 -007: i=2 s=List001 b=True r=120.000000 -007: i=2 s=List001 b=True r=122.000000 007: i=20 s=List020 b=True r=220.000000 +007: i=30 s=List000 b=True r=110.000000 007: i=5 s=List005 b=True r=130.000000 007: i=54 s=Lista054 b=False r=0.000000 +008: i=1 s=List000 b=True r=101.000000 +008: i=1 s=List001 b=False r=110.000000 +008: i=19 s=List020 b=True r=219.000000 +008: i=2 s=List000 b=False r=102.000000 +008: i=2 s=List001 b=True r=120.000000 +008: i=2 s=List001 b=True r=122.000000 +008: i=20 s=List020 b=True r=220.000000 +008: i=30 s=List000 b=True r=110.000000 +008: i=5 s=List005 b=True r=130.000000 +008: i=54 s=Lista054 b=False r=0.000000 ]) # Tests to verify the functionality of two column compound index. diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index e4e7d90..7932204 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -2895,6 +2895,27 @@ test_idl_compound_index_single_column(struct ovsdb_idl *idl, myRow->s, myRow->b?"True":"False", myRow->r); } + /* Update record i=10 to i=30, make sure index is updated accordingly */ + ++step; + struct idltest_simple *toUpdate; + toUpdate = idltest_simple_index_init_row(i_index); + idltest_simple_index_set_i(toUpdate, 10); + ovs_assert(toUpdate->i == 10); + myRow = idltest_simple_index_find(i_index, toUpdate); + ovs_assert(myRow); + ovs_assert(myRow->i == 10); + txn = ovsdb_idl_txn_create(idl); + idltest_simple_set_i(myRow, 30); + ovsdb_idl_txn_commit_block(txn); + ovsdb_idl_txn_destroy(txn); + idltest_simple_index_set_i(to, 60); + printf("Expected 60, stored %"PRId64"\n", to->i); + ovs_assert(to->i == 60); + IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, from, to, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + /* Test special-case range, "from" and "to" are both NULL, * which is interpreted as the range from -infinity to +infinity. */ ++step; @@ -2908,6 +2929,7 @@ test_idl_compound_index_single_column(struct ovsdb_idl *idl, idltest_simple_index_destroy_row(to); idltest_simple_index_destroy_row(equal); idltest_simple_index_destroy_row(toDelete); + idltest_simple_index_destroy_row(toUpdate); return step; }