Changeset: c01f6a68ad0c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c01f6a68ad0c
Modified Files:
        ctest/tools/monetdbe/example1.c
        ctest/tools/monetdbe/example2.c
        ctest/tools/monetdbe/example_append.c
        ctest/tools/monetdbe/example_append_raw.c
        ctest/tools/monetdbe/example_blob.c
        ctest/tools/monetdbe/example_connections.c
        ctest/tools/monetdbe/example_decimals.c
        ctest/tools/monetdbe/example_remote.c
        ctest/tools/monetdbe/example_temporal.c
        tools/monetdbe/monetdbe.c
        tools/monetdbe/monetdbe.h
Branch: Oct2020
Log Message:

change api of is_null(ctype value) -> is_null(ctype *value).


diffs (269 lines):

diff --git a/ctest/tools/monetdbe/example1.c b/ctest/tools/monetdbe/example1.c
--- a/ctest/tools/monetdbe/example1.c
+++ b/ctest/tools/monetdbe/example1.c
@@ -48,7 +48,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example2.c b/ctest/tools/monetdbe/example2.c
--- a/ctest/tools/monetdbe/example2.c
+++ b/ctest/tools/monetdbe/example2.c
@@ -120,7 +120,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_append.c 
b/ctest/tools/monetdbe/example_append.c
--- a/ctest/tools/monetdbe/example_append.c
+++ b/ctest/tools/monetdbe/example_append.c
@@ -56,7 +56,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol[c];
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
@@ -141,7 +141,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol[c];
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_append_raw.c 
b/ctest/tools/monetdbe/example_append_raw.c
--- a/ctest/tools/monetdbe/example_append_raw.c
+++ b/ctest/tools/monetdbe/example_append_raw.c
@@ -39,7 +39,7 @@ main(void)
        int32_t i2 = *(int32_t*)monetdbe_null(mdbe, monetdbe_int32_t);
        int32_t ints[2] = { i1, i2 };
        monetdbe_column col0 = { .type = monetdbe_int32_t, .data = &ints, 
.count = 2 };
-       
+
        // str
        char* dstr[2] = { "Hello", "World" };
        monetdbe_column col1 = { .type = monetdbe_str, .data = &dstr, .count = 
2 };
@@ -52,7 +52,7 @@ main(void)
        monetdbe_data_timestamp tss[2] = { t1, t2 };
        monetdbe_column col2 = { .type = monetdbe_timestamp, .data = &tss, 
.count = 2 };
 
-       // date 
+       // date
        monetdbe_data_date d1 = dt;
        monetdbe_data_date d2 = *(monetdbe_data_date*)monetdbe_null(mdbe, 
monetdbe_date);
        monetdbe_data_date dts[2] = { d1, d2 };
@@ -94,7 +94,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol[c];
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_blob.c 
b/ctest/tools/monetdbe/example_blob.c
--- a/ctest/tools/monetdbe/example_blob.c
+++ b/ctest/tools/monetdbe/example_blob.c
@@ -55,7 +55,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_connections.c 
b/ctest/tools/monetdbe/example_connections.c
--- a/ctest/tools/monetdbe/example_connections.c
+++ b/ctest/tools/monetdbe/example_connections.c
@@ -50,7 +50,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_decimals.c 
b/ctest/tools/monetdbe/example_decimals.c
--- a/ctest/tools/monetdbe/example_decimals.c
+++ b/ctest/tools/monetdbe/example_decimals.c
@@ -119,7 +119,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_remote.c 
b/ctest/tools/monetdbe/example_remote.c
--- a/ctest/tools/monetdbe/example_remote.c
+++ b/ctest/tools/monetdbe/example_remote.c
@@ -49,7 +49,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/ctest/tools/monetdbe/example_temporal.c 
b/ctest/tools/monetdbe/example_temporal.c
--- a/ctest/tools/monetdbe/example_temporal.c
+++ b/ctest/tools/monetdbe/example_temporal.c
@@ -79,7 +79,7 @@ main(void)
                                }
                                case monetdbe_str: {
                                        monetdbe_column_str * col = 
(monetdbe_column_str *) rcol;
-                                       if (col->is_null(col->data[r])) {
+                                       if (col->is_null(col->data+r)) {
                                                printf("NULL");
                                        } else {
                                                printf("%s", (char*) 
col->data[r]);
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -1042,11 +1042,11 @@ cleanup:
 }
 
 #define GENERATE_BASE_HEADERS(type, tpename) \
-       static int tpename##_is_null(type value)
+       static int tpename##_is_null(type *value)
 
 #define GENERATE_BASE_FUNCTIONS(tpe, tpename, mname) \
        GENERATE_BASE_HEADERS(tpe, tpename); \
-       static int tpename##_is_null(tpe value) { return value == mname##_nil; }
+       static int tpename##_is_null(tpe *value) { return *value == 
mname##_nil; }
 
 #ifdef bool
 #undef bool
@@ -1103,7 +1103,7 @@ GENERATE_BASE_HEADERS(monetdbe_data_time
        }
 
 char*
-monetdbe_append(monetdbe_database dbhdl, const char* schema, const char* 
table, monetdbe_column **input /*bat *batids*/, size_t column_count)
+monetdbe_append(monetdbe_database dbhdl, const char* schema, const char* 
table, monetdbe_column **input, size_t column_count)
 {
 
        monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
@@ -1155,7 +1155,6 @@ monetdbe_append(monetdbe_database dbhdl,
        }
 
        /* for now no default values, ie user should supply all columns */
-
        if (column_count != (size_t)list_length(t->columns.set)) {
                mdbe->msg = createException(SQL, "monetdbe.monetdbe_append", 
"Incorrect number of columns");
                goto cleanup;
@@ -1239,7 +1238,7 @@ monetdbe_append(monetdbe_database dbhdl,
 
                        for (size_t j=0; j<cnt; j++){
                                timestamp t = *(timestamp*) nil;
-                               if(!timestamp_is_null(ts[j]))
+                               if(!timestamp_is_null(ts+j))
                                        t = timestamp_from_data(&ts[j]);
 
                                if (store_funcs.append_col(m->session->tr, c, 
&t, mtype) != 0) {
@@ -1252,7 +1251,7 @@ monetdbe_append(monetdbe_database dbhdl,
 
                        for (size_t j=0; j<cnt; j++){
                                date d = *(date*) nil;
-                               if(!date_is_null(de[j]))
+                               if(!date_is_null(de+j))
                                        d = date_from_data(&de[j]);
 
                                if (store_funcs.append_col(m->session->tr, c, 
&d, mtype) != 0) {
@@ -1265,7 +1264,7 @@ monetdbe_append(monetdbe_database dbhdl,
 
                        for (size_t j=0; j<cnt; j++){
                                daytime dt = *(daytime*) nil;
-                               if(!time_is_null(t[j]))
+                               if(!time_is_null(t+j))
                                        dt = time_from_data(&t[j]);
 
                                if (store_funcs.append_col(m->session->tr, c, 
&dt, mtype) != 0) {
@@ -1279,7 +1278,7 @@ monetdbe_append(monetdbe_database dbhdl,
                        for (size_t j=0; j<cnt; j++){
                                blob* b = (blob*) nil;
                                int res;
-                               if (!blob_is_null(be[j])) {
+                               if (!blob_is_null(be+j)) {
                                        size_t len = be[j].size;
                                        b = (blob*) GDKmalloc(blobsize(len));
                                        if (b == NULL)
@@ -1615,38 +1614,38 @@ timestamp_from_data(monetdbe_data_timest
 }
 
 static int
-date_is_null(monetdbe_data_date value)
+date_is_null(monetdbe_data_date *value)
 {
        monetdbe_data_date null_value;
        data_from_date(date_nil, &null_value);
-       return value.year == null_value.year && value.month == null_value.month 
&&
-                  value.day == null_value.day;
+       return value->year == null_value.year && value->month == 
null_value.month &&
+                  value->day == null_value.day;
 }
 
 static int
-time_is_null(monetdbe_data_time value)
+time_is_null(monetdbe_data_time *value)
 {
        monetdbe_data_time null_value;
        data_from_time(daytime_nil, &null_value);
-       return value.hours == null_value.hours &&
-                  value.minutes == null_value.minutes &&
-                  value.seconds == null_value.seconds && value.ms == 
null_value.ms;
+       return value->hours == null_value.hours &&
+                  value->minutes == null_value.minutes &&
+                  value->seconds == null_value.seconds && value->ms == 
null_value.ms;
 }
 
 static int
-timestamp_is_null(monetdbe_data_timestamp value)
+timestamp_is_null(monetdbe_data_timestamp *value)
 {
-       return is_timestamp_nil(timestamp_from_data(&value));
+       return is_timestamp_nil(timestamp_from_data(value));
 }
 
 static int
-str_is_null(char *value)
+str_is_null(char **value)
 {
-       return value == NULL;
+       return !value || *value == NULL;
 }
 
 static int
-blob_is_null(monetdbe_data_blob value)
+blob_is_null(monetdbe_data_blob *value)
 {
-       return value.data == NULL;
+       return !value || value->data == NULL;
 }
diff --git a/tools/monetdbe/monetdbe.h b/tools/monetdbe/monetdbe.h
--- a/tools/monetdbe/monetdbe.h
+++ b/tools/monetdbe/monetdbe.h
@@ -105,7 +105,7 @@ typedef struct {
                char *name;                                \
                ctype null_value;                          \
                double scale;                              \
-               int (*is_null)(ctype value);               \
+               int (*is_null)(ctype *value);               \
        } monetdbe_column_##typename
 
 DEFAULT_STRUCT_DEFINITION(int8_t, bool);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to