1

If I execute two queries SELECT * WHERE A AND B and SELECT * WHERE B AND A. I could not get the same results. It happens under the version of v4.5.1 for both GriddB server and c_client library. (It is the same for other versions > 4.2.1.) However, when I execute the same query under 4.2.1 GridDB (+ v4.2.0 c_client library), I can get the expected output.

We can reproduce this issue using the below program

    #include "gridstore.h"
    #include 
    #include 
    
    typedef struct {
            int c1;
    } Test;
    
    GS_STRUCT_BINDING(Test, GS_STRUCT_BINDING_KEY(c1, GS_TYPE_INTEGER));
    
    static void execute(GSCollection *col, char *tql)
    {
            GSQuery *query; GSRowSet *rs; GSResult ret; Test test;
            ret = gsQuery(col, tql, &query); if (!GS_SUCCEEDED(ret)) exit(-1);
            ret = gsFetch(query, GS_TRUE, &rs); if (!GS_SUCCEEDED(ret)) exit(-1);
            printf("query: %s\n", tql);
            while (gsHasNextRow(rs)) {
                    gsGetNextRow(rs, &test);
                    ret = gsUpdateCurrentRow(rs, &test); if (!GS_SUCCEEDED(ret)) exit(-1);
                    printf(" c1=%d\n", test.c1);
            }
    }
    
    void main(void)
    {
            GSGridStore *store; GSCollection *col; GSResult ret; Test test; int i;
            const GSPropertyEntry props[] = { { "notificationAddress", "239.0.0.1" },
                                              { "notificationPort", "31999" },
                                              { "clusterName", "griddbfdwTestCluster" },
                                              { "user", "admin" },
                                              { "password", "testadmin" } };
            const size_t propCount = sizeof(props) / sizeof(*props);
    
            gsGetGridStore(gsGetDefaultFactory(), props, propCount, &store);
            gsPutCollection(store, "test01", GS_GET_STRUCT_BINDING(Test), NULL, GS_FALSE, &col);
            gsSetAutoCommit(col, GS_FALSE);
            for (i=0; i <10; i++) {
              test.c1 = i; gsPutRow(col, NULL, &test, NULL);
            }
            gsCommit(col);
            execute(col, "SELECT * WHERE (c1 >  AND (c1 > 1)");
            execute(col, "SELECT * WHERE (c1 > 1) AND (c1 > ");
            gsCommit(col);
            gsCloseGridStore(&store, GS_TRUE);
    }

In 4.5.1 I got the following results.

query: SELECT * WHERE (c1 >  AND (c1 > 1)
 c1=2
 c1=3
 c1=4
 c1=5
 c1=6
 c1=7
 c1=8
 c1=9
query: SELECT * WHERE (c1 > 1) AND (c1 > 
 c1=9

Expected behavior: The result should be below.

query: SELECT * WHERE (c1 >  AND (c1 > 1)
 c1=9
query: SELECT * WHERE (c1 > 1) AND (c1 > 
 c1=9
Philippe Remy
  • 2,967
  • 4
  • 25
  • 39

0 Answers0