Changeset: 548ac6db1314 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=548ac6db1314
Modified Files:
        sql/backends/monet5/UDF/capi/Tests/capi00.sql
        sql/backends/monet5/UDF/capi/Tests/capi00.stable.out
        sql/backends/monet5/UDF/capi/Tests/capi01.sql
        sql/backends/monet5/UDF/capi/Tests/capi02.sql
        sql/backends/monet5/UDF/capi/Tests/capi03.sql
        sql/backends/monet5/UDF/capi/Tests/capi04.sql
        sql/backends/monet5/UDF/capi/Tests/capi05.sql
        sql/backends/monet5/UDF/capi/Tests/capi06.sql
        sql/backends/monet5/UDF/capi/Tests/capi07.sql
        sql/backends/monet5/UDF/capi/Tests/capi08.sql
        sql/backends/monet5/UDF/capi/Tests/capi09.sql
        sql/backends/monet5/UDF/capi/Tests/capi10.sql
        sql/backends/monet5/UDF/capi/Tests/capi11.sql
        sql/backends/monet5/UDF/capi/Tests/capi12.sql
Branch: jitudf
Log Message:

Move indexes out of for loop declarations for GCC.


diffs (truncated from 592 to 300 lines):

diff --git a/sql/backends/monet5/UDF/capi/Tests/capi00.sql 
b/sql/backends/monet5/UDF/capi/Tests/capi00.sql
--- a/sql/backends/monet5/UDF/capi/Tests/capi00.sql
+++ b/sql/backends/monet5/UDF/capi/Tests/capi00.sql
@@ -3,16 +3,17 @@
 START TRANSACTION;
 
 CREATE FUNCTION capi00(inp INTEGER) RETURNS INTEGER LANGUAGE C {
-       result->initialize(result, inp.count);
-       for(size_t i = 0; i < inp.count; i++) {
-               result->data[i] = inp.data[i] * 2;
-       }
+    size_t i;
+    result->initialize(result, inp.count);
+    for(i = 0; i < inp.count; i++) {
+        result->data[i] = inp.data[i] * 2;
+    }
 };
 
 CREATE TABLE integers(i INTEGER);
 INSERT INTO integers VALUES (1), (2), (3), (4), (5);
 
-SELECT capi00(i) FROM integers;
+SELECT i, capi00(i) FROM integers;
 
 DROP FUNCTION capi00;
 
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi00.stable.out 
b/sql/backends/monet5/UDF/capi/Tests/capi00.stable.out
--- a/sql/backends/monet5/UDF/capi/Tests/capi00.stable.out
+++ b/sql/backends/monet5/UDF/capi/Tests/capi00.stable.out
@@ -73,16 +73,17 @@ Ready.
 #CREATE TABLE integers(i INTEGER);
 #INSERT INTO integers VALUES (1), (2), (3), (4), (5);
 [ 5    ]
-#SELECT capi00(i) FROM integers;
-% sys.L2 # table_name
-% L2 # name
-% int # type
-% 2 # length
-[ 2    ]
-[ 4    ]
-[ 6    ]
-[ 8    ]
-[ 10   ]
+#SELECT i, capi00(i) FROM integers;
+% sys.integers,        sys.L3 # table_name
+% i,   L3 # name
+% int, int # type
+% 1,   2 # length
+[ 1,   2       ]
+[ 2,   4       ]
+[ 3,   6       ]
+[ 4,   8       ]
+[ 5,   10      ]
+#DROP FUNCTION capi00;
 #ROLLBACK;
 
 # 11:56:00 >  
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi01.sql 
b/sql/backends/monet5/UDF/capi/Tests/capi01.sql
--- a/sql/backends/monet5/UDF/capi/Tests/capi01.sql
+++ b/sql/backends/monet5/UDF/capi/Tests/capi01.sql
@@ -5,13 +5,14 @@ CREATE FUNCTION capi01(inp INTEGER) RETU
 language C
 {
 #include <math.h>
-       size_t count = inp.data[0];
-       i->initialize(i, count);
-       d->initialize(d, count);
-       for(size_t j = 0; j < count; j++) {
-               i->data[j] = j;
-               d->data[j] = round(j > 0 ? 42.0 / j : 42.0);
-       }
+    size_t j;
+    size_t count = inp.data[0];
+    i->initialize(i, count);
+    d->initialize(d, count);
+    for(j = 0; j < count; j++) {
+        i->data[j] = j;
+        d->data[j] = round(j > 0 ? 42.0 / j : 42.0);
+    }
 };
 
 SELECT i,d FROM capi01(42) AS R;
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi02.sql 
b/sql/backends/monet5/UDF/capi/Tests/capi02.sql
--- a/sql/backends/monet5/UDF/capi/Tests/capi02.sql
+++ b/sql/backends/monet5/UDF/capi/Tests/capi02.sql
@@ -4,24 +4,25 @@ START TRANSACTION;
 # dates
 # dates have the type
 #typedef struct {
-#      unsigned char day;
-#      unsigned char month;
-#      int year;
+#   unsigned char day;
+#   unsigned char month;
+#   int year;
 #} cudf_data_date;
 
 CREATE FUNCTION capi02_increment_year(d DATE) RETURNS DATE
 language C
 {
-       result->initialize(result, d.count);
-       for(size_t i = 0; i < result->count; i++) {
-               if (d.is_null(d.data[i])) {
-                       result->data[i] = result->null_value;
-               } else {
-                       result->data[i].year = d.data[i].year + 1;
-                       result->data[i].month = d.data[i].month;
-                       result->data[i].day = d.data[i].day;
-               }
-       }
+    size_t i;
+    result->initialize(result, d.count);
+    for(i = 0; i < result->count; i++) {
+        if (d.is_null(d.data[i])) {
+            result->data[i] = result->null_value;
+        } else {
+            result->data[i].year = d.data[i].year + 1;
+            result->data[i].month = d.data[i].month;
+            result->data[i].day = d.data[i].day;
+        }
+    }
 };
 
 
@@ -36,26 +37,27 @@ DROP TABLE dates;
 #time
 #time has the type:
 #typedef struct {
-#      unsigned int ms;
-#      unsigned char seconds;
-#      unsigned char minutes;
-#      unsigned char hours;
+#   unsigned int ms;
+#   unsigned char seconds;
+#   unsigned char minutes;
+#   unsigned char hours;
 #} cudf_data_time;
 
 CREATE FUNCTION capi02_randomize_time(d TIME) RETURNS TIME
 language C
 {
-       result->initialize(result, d.count);
-       for(size_t i = 0; i < result->count; i++) {
-               if (d.is_null(d.data[i])) {
-                       result->data[i] = result->null_value;
-               } else {
-                       result->data[i].hours = (i + 1234) % 24;
-                       result->data[i].minutes = (i + 1234) % 60;
-                       result->data[i].seconds = (i + 1234) % 60;
-                       result->data[i].ms = (i + 1234) % 1000;
-               }
-       }
+    size_t i;
+    result->initialize(result, d.count);
+    for(i = 0; i < result->count; i++) {
+        if (d.is_null(d.data[i])) {
+            result->data[i] = result->null_value;
+        } else {
+            result->data[i].hours = (i + 1234) % 24;
+            result->data[i].minutes = (i + 1234) % 60;
+            result->data[i].seconds = (i + 1234) % 60;
+            result->data[i].ms = (i + 1234) % 1000;
+        }
+    }
 };
 
 
@@ -69,28 +71,29 @@ DROP TABLE times;
 #timestamps
 #timestamps have the type:
 #typedef struct {
-#      cudf_data_date date;
-#      cudf_data_time time;
+#   cudf_data_date date;
+#   cudf_data_time time;
 #} cudf_data_timestamp;
 
 CREATE FUNCTION capi02_increment_timestamp(d TIMESTAMP) RETURNS TIMESTAMP
 language C
 {
-       result->initialize(result, d.count);
-       for(size_t i = 0; i < result->count; i++) {
-               if (d.is_null(d.data[i])) {
-                       result->data[i] = result->null_value;
-               } else {
-                       result->data[i].date.year = d.data[i].date.year + 1;
-                       result->data[i].date.month = d.data[i].date.month;
-                       result->data[i].date.day = d.data[i].date.day;
+    size_t i;
+    result->initialize(result, d.count);
+    for(i = 0; i < result->count; i++) {
+        if (d.is_null(d.data[i])) {
+            result->data[i] = result->null_value;
+        } else {
+            result->data[i].date.year = d.data[i].date.year + 1;
+            result->data[i].date.month = d.data[i].date.month;
+            result->data[i].date.day = d.data[i].date.day;
 
-                       result->data[i].time.hours = (i + 1234) % 24;
-                       result->data[i].time.minutes = (i + 1234) % 60;
-                       result->data[i].time.seconds = (i + 1234) % 60;
-                       result->data[i].time.ms = (i + 1234) % 1000;
-               }
-       }
+            result->data[i].time.hours = (i + 1234) % 24;
+            result->data[i].time.minutes = (i + 1234) % 60;
+            result->data[i].time.seconds = (i + 1234) % 60;
+            result->data[i].time.ms = (i + 1234) % 1000;
+        }
+    }
 };
 
 
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi03.sql 
b/sql/backends/monet5/UDF/capi/Tests/capi03.sql
--- a/sql/backends/monet5/UDF/capi/Tests/capi03.sql
+++ b/sql/backends/monet5/UDF/capi/Tests/capi03.sql
@@ -6,14 +6,15 @@ START TRANSACTION;
 # Return different amount of rows in table-producing functions
 
 CREATE FUNCTION capi03() RETURNS TABLE(i INTEGER, j INTEGER) LANGUAGE C {
-       i->initialize(i, 10);
-       j->initialize(j, 20);
-       for(size_t index = 0; index < i->count; index++) {
-               i->data[index] = 0;
-       }
-       for(size_t index = 0; index < j->count; index++) {
-               j->data[index] = 1;
-       }
+    size_t index;
+    i->initialize(i, 10);
+    j->initialize(j, 20);
+    for(index = 0; index < i->count; index++) {
+        i->data[index] = 0;
+    }
+    for(index = 0; index < j->count; index++) {
+        j->data[index] = 1;
+    }
 };
 
 SELECT * FROM capi03();
@@ -24,7 +25,7 @@ START TRANSACTION;
 
 # No return value
 CREATE FUNCTION capi03(inp INTEGER) RETURNS INTEGER LANGUAGE C {
-       
+    
 };
 
 CREATE TABLE integers(i INTEGER);
@@ -40,7 +41,7 @@ START TRANSACTION;
 # Manually return an error from the function
 
 CREATE FUNCTION capi03(inp INTEGER) RETURNS INTEGER LANGUAGE C {
-       return "Something went wrong!";
+    return "Something went wrong!";
 };
 
 CREATE TABLE integers(i INTEGER);
@@ -54,11 +55,12 @@ START TRANSACTION;
 
 # Modify input data
 CREATE FUNCTION capi03(inp INTEGER) RETURNS INTEGER LANGUAGE C {
-       inp.data[0] = 10;
-       result->initialize(result, inp.count);
-       for(size_t i = 0; i < inp.count; i++) {
-               result->data[i] = inp.data[i] * 2;
-       }
+    size_t i;
+    inp.data[0] = 10;
+    result->initialize(result, inp.count);
+    for(i = 0; i < inp.count; i++) {
+        result->data[i] = inp.data[i] * 2;
+    }
 };
 
 CREATE TABLE integers(i INTEGER);
@@ -72,7 +74,7 @@ START TRANSACTION;
 
 # Trigger a segfault
 CREATE FUNCTION capi03(inp INTEGER) RETURNS INTEGER LANGUAGE C {
-       int x = *((int*)NULL);
+    int x = *((int*)NULL);
 };
 
 CREATE TABLE integers(i INTEGER);
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi04.sql 
b/sql/backends/monet5/UDF/capi/Tests/capi04.sql
--- a/sql/backends/monet5/UDF/capi/Tests/capi04.sql
+++ b/sql/backends/monet5/UDF/capi/Tests/capi04.sql
@@ -4,17 +4,18 @@ START TRANSACTION;
 
 CREATE FUNCTION capi04(inp STRING) RETURNS STRING LANGUAGE C {
 #include <string.h>
+    size_t i;
 
-       result->initialize(result, inp.count);
-       for(size_t i = 0; i < inp.count; i++) {
-               if (inp.is_null(inp.data[i])) {
-                       result->data[i] = result->null_value;
-               } else {
-                       result->data[i] = malloc(strlen(inp.data[i]) + 2);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to