James Hawkins : msi: Handle sorting an empty table.

Alexandre Julliard julliard at winehq.org
Wed Apr 2 06:55:36 CDT 2008


Module: wine
Branch: master
Commit: bed661aef47c0e565bb61961098a6f52238ce092
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bed661aef47c0e565bb61961098a6f52238ce092

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Wed Apr  2 03:47:24 2008 -0500

msi: Handle sorting an empty table.

---

 dlls/msi/table.c    |    3 +++
 dlls/msi/tests/db.c |   16 ++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index a8f0f40..572cad6 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -2054,6 +2054,9 @@ static UINT TABLE_sort(struct tagMSIVIEW *view, column_info *columns)
     if (r != ERROR_SUCCESS)
         return r;
 
+    if (rows == 0)
+        return ERROR_SUCCESS;
+
     order = msi_alloc_zero(sizeof(MSIORDERINFO) + sizeof(UINT) * cols);
     if (!order)
         return ERROR_OUTOFMEMORY;
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c
index ac15d24..aee2e80 100644
--- a/dlls/msi/tests/db.c
+++ b/dlls/msi/tests/db.c
@@ -4777,6 +4777,10 @@ static void test_order(void)
     hdb = create_db();
     ok(hdb, "failed to create db\n");
 
+    query = "CREATE TABLE `Empty` ( `A` SHORT NOT NULL PRIMARY KEY `A`)";
+    r = run_query(hdb, 0, query);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
     query = "CREATE TABLE `Mesa` ( `A` SHORT NOT NULL, `B` SHORT, `C` SHORT PRIMARY KEY `A`)";
     r = run_query(hdb, 0, query);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
@@ -4964,6 +4968,18 @@ static void test_order(void)
 
     MsiViewClose(hview);
     MsiCloseHandle(hview);
+
+    query = "SELECT * FROM `Empty` ORDER BY `A`";
+    r = MsiDatabaseOpenView(hdb, query, &hview);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+    r = MsiViewExecute(hview, 0);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+    r = MsiViewFetch(hview, &hrec);
+    ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+
+    MsiViewClose(hview);
+    MsiCloseHandle(hview);
     MsiCloseHandle(hdb);
 }
 




More information about the wine-cvs mailing list