Changeset: 647c9f34e028 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=647c9f34e028
Modified Files:
        clients/examples/C/sample0.c
        clients/examples/C/sample1.c
        clients/examples/C/sample2.c
        clients/examples/C/sample3.c
        clients/examples/C/sample4.c
        clients/perl/Tests/malsample.pl.in
        monetdb5/modules/mal/batExtensions.mal
        monetdb5/modules/mal/transaction.mal
        monetdb5/tests/gdkTests/Tests/cross.mal
        monetdb5/tests/gdkTests/Tests/cross.stable.out
        monetdb5/tests/mapi/Tests/perl_dbi.stable.out
        monetdb5/tests/mapi/Tests/sample0.stable.out
        monetdb5/tests/mapi/Tests/sample3.stable.out
        monetdb5/tests/suite_00/Tests/test_15.mal
Branch: default
Log Message:

Enabling the :oid in bat new operations
At the MAL level BATs should be created with :oid head.


diffs (truncated from 642 to 300 lines):

diff --git a/clients/examples/C/sample0.c b/clients/examples/C/sample0.c
--- a/clients/examples/C/sample0.c
+++ b/clients/examples/C/sample0.c
@@ -35,15 +35,14 @@
 int
 main(int argc, char **argv)
 {
-       Mapi dbh= NULL;
-       MapiHdl hdl= NULL;
+       Mapi dbh;
+       MapiHdl hdl = NULL;
 
        if (argc != 4) {
                printf("usage:%s <host> <port> <language>\n", argv[0]);
                exit(-1);
        }
 
-       printf("# Start %s test on %s\n", argv[3], argv[1]);
        dbh = mapi_connect(argv[1], atoi(argv[2]), "monetdb", "monetdb", 
argv[3], NULL);
        if (dbh == NULL || mapi_error(dbh))
                die(dbh, hdl);
@@ -53,7 +52,7 @@ main(int argc, char **argv)
                /* switch of autocommit */
                if (mapi_setAutocommit(dbh, 0) != MOK || mapi_error(dbh))
                        die(dbh,NULL);
-               if ((hdl = mapi_query(dbh, "create table emp(name varchar(20), 
age int)")) == NULL || mapi_error(dbh)) 
+               if ((hdl = mapi_query(dbh, "create table emp(name varchar(20), 
age int)")) == NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
@@ -67,32 +66,43 @@ main(int argc, char **argv)
                        die(dbh, hdl);
                if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               while (mapi_fetch_row(hdl)) {
+                       char *nme = mapi_fetch_field(hdl, 0);
+                       char *age = mapi_fetch_field(hdl, 1);
+
+                       printf("%s is %s\n", nme, age);
+               }
        } else if (strcmp(argv[3], "mal") == 0) {
-               if ((hdl = mapi_query(dbh, "emp := bat.new(:str,:int);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "age := bat.new(:oid,:int);")) == 
NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp,\"John\",23);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "bat.append(emp, \"John\");")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "bat.append(age, 23);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp,\"Mary\",22);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "bat.append(emp, \"Mary\");")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "bat.append(age, 22);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL || 
mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               while (mapi_fetch_row(hdl)) {
+                       char *nme = mapi_fetch_field(hdl, 1);
+                       char *age = mapi_fetch_field(hdl, 2);
+                       printf("%s is %s\n", nme, age);
+               }
        } else {
                fprintf(stderr, "%s: unknown language, only mal and sql 
supported\n", argv[0]);
                exit(1);
        }
 
-       while (mapi_fetch_row(hdl)) {
-               char *nme = mapi_fetch_field(hdl, 0);
-               char *age = mapi_fetch_field(hdl, 1);
-
-               printf("%s is %s\n", nme, age);
-       }
        if (mapi_error(dbh))
                die(dbh, hdl);
        /* mapi_stat(dbh);
diff --git a/clients/examples/C/sample1.c b/clients/examples/C/sample1.c
--- a/clients/examples/C/sample1.c
+++ b/clients/examples/C/sample1.c
@@ -67,32 +67,43 @@ main(int argc, char **argv)
                        die(dbh, hdl);
                if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               while (mapi_fetch_row(hdl)) {
+                       char *nme = mapi_fetch_field(hdl, 0);
+                       char *age = mapi_fetch_field(hdl, 1);
+
+                       printf("%s is %s\n", nme, age);
+               }
        } else if (strcmp(argv[3], "mal") == 0) {
-               if ((hdl = mapi_query(dbh, "emp := bat.new(:str,:int);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "age := bat.new(:oid,:int);")) == 
NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp, \"John\",23);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "bat.append(emp, \"John\");")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "bat.append(age, 23);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp, \"Mary\",22);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "bat.append(emp, \"Mary\");")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "bat.append(age, 22);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL || 
mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               while (mapi_fetch_row(hdl)) {
+                       char *nme = mapi_fetch_field(hdl, 1);
+                       char *age = mapi_fetch_field(hdl, 2);
+                       printf("%s is %s\n", nme, age);
+               }
        } else {
                fprintf(stderr, "%s: unknown language, only mal and sql 
supported\n", argv[0]);
                exit(1);
        }
 
-       while (mapi_fetch_row(hdl)) {
-               char *nme = mapi_fetch_field(hdl, 0);
-               char *age = mapi_fetch_field(hdl, 1);
-
-               printf("%s is %s\n", nme, age);
-       }
        if (mapi_error(dbh))
                die(dbh, hdl);
        /* mapi_stat(dbh);
diff --git a/clients/examples/C/sample2.c b/clients/examples/C/sample2.c
--- a/clients/examples/C/sample2.c
+++ b/clients/examples/C/sample2.c
@@ -38,7 +38,8 @@ main(int argc, char **argv)
        /* a parameter binding test */
        char *nme = 0;
        int age = 0;
-       char *parm[] = { "peter", "25", 0 };
+       char *parm[] = { "peter", 0 };
+       char *parm2[] = { "25", 0 };
        Mapi dbh= NULL;
        MapiHdl hdl = NULL;
 
@@ -66,29 +67,40 @@ main(int argc, char **argv)
                        die(dbh, hdl);
                if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               if (mapi_bind(hdl, 0, &nme))
+                       die(dbh, hdl);
+               if (mapi_bind_var(hdl, 1, MAPI_INT, &age))
+                       die(dbh, hdl);
+               while (mapi_fetch_row(hdl)) {
+                       printf("%s is %d\n", nme, age);
+               }
        } else if (strcmp(argv[3], "mal") == 0) {
-               if ((hdl = mapi_query(dbh, "emp := bat.new(:str,:int);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "age := bat.new(:oid,:int);")) == 
NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query_array(dbh, "bat.insert(emp,\"?\",?);", 
parm)) == NULL || mapi_error(dbh))
+               if ((hdl = mapi_query_array(dbh, "bat.append(emp,\"?\");", 
parm)) == NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query_array(dbh, "bat.append(age,?);", parm2)) 
== NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL || 
mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               if (mapi_bind(hdl, 1, &nme))
+                       die(dbh, hdl);
+               if (mapi_bind_var(hdl, 2, MAPI_INT, &age))
+                       die(dbh, hdl);
+               while (mapi_fetch_row(hdl)) {
+                       printf("%s is %d\n", nme, age);
+               }
        } else {
                fprintf(stderr, "%s: unknown language, only mal and sql 
supported\n", argv[0]);
                exit(1);
        }
 
-       if (mapi_bind(hdl, 0, &nme))
-               die(dbh, hdl);
-       if (mapi_bind_var(hdl, 1, MAPI_INT, &age))
-               die(dbh, hdl);
-       while (mapi_fetch_row(hdl)) {
-               printf("%s is %d\n", nme, age);
-       }
        if (mapi_error(dbh))
                die(dbh, hdl);
        if (mapi_close_handle(hdl) != MOK)
diff --git a/clients/examples/C/sample3.c b/clients/examples/C/sample3.c
--- a/clients/examples/C/sample3.c
+++ b/clients/examples/C/sample3.c
@@ -43,6 +43,8 @@ main(int argc, char **argv)
        Mapi dbh;
        MapiHdl hdl = NULL;
        mapi_int64 rows, i;
+       char *parm[] = { "peter", 0 };
+       char *parm2[] = { "25", 0 };
        int j;
 
        if (argc != 4) {
@@ -74,19 +76,19 @@ main(int argc, char **argv)
                if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
        } else if (strcmp(argv[3], "mal") == 0) {
-               if ((hdl = mapi_query(dbh, "emp := bat.new(:str,:int);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "age := bat.new(:oid,:int);")) == 
NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp,\"John\",23);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query_array(dbh, "bat.append(emp,\"?\");", 
parm)) == NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query_array(dbh, "bat.append(age,?);", parm2)) 
== NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp,\"Mary\",22);")) == 
NULL || mapi_error(dbh))
-                       die(dbh, hdl);
-               if (mapi_close_handle(hdl) != MOK)
-                       die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL || 
mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
        } else {
                fprintf(stderr, "%s: unknown language, only mal and sql 
supported\n", argv[0]);
diff --git a/clients/examples/C/sample4.c b/clients/examples/C/sample4.c
--- a/clients/examples/C/sample4.c
+++ b/clients/examples/C/sample4.c
@@ -74,36 +74,52 @@ main(int argc, char **argv)
                        die(dbh, hdl);
                if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               rows = mapi_fetch_all_rows(hdl);
+               if (mapi_error(dbh))
+                       die(dbh, hdl);
+               printf("rows received " LLFMT "\n", rows);
+               while (mapi_fetch_row(hdl)) {
+                       char *nme = mapi_fetch_field(hdl, 0);
+                       char *age = mapi_fetch_field(hdl, 1);
+
+                       printf("%s is %s\n", nme, age);
+               }
        } else if (strcmp(argv[3], "mal") == 0) {
-               if ((hdl = mapi_query(dbh, "emp := bat.new(:str,:int);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "age := bat.new(:oid,:int);")) == 
NULL || mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp,\"John\",23);")) == 
NULL)
+               if ((hdl = mapi_query(dbh, "bat.append(emp, \"John\");")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "bat.append(age, 23);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "bat.insert(emp,\"Mary\",22);")) == 
NULL || mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "bat.append(emp, \"Mary\");")) == 
NULL || mapi_error(dbh))
+                       die(dbh, hdl);
+               if ((hdl = mapi_query(dbh, "bat.append(age, 22);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
                if (mapi_close_handle(hdl) != MOK)
                        die(dbh, hdl);
-               if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL || 
mapi_error(dbh))
+               if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || 
mapi_error(dbh))
                        die(dbh, hdl);
+               rows = mapi_fetch_all_rows(hdl);
+               if (mapi_error(dbh))
+                       die(dbh, hdl);
+               printf("rows received " LLFMT "\n", rows);
+               while (mapi_fetch_row(hdl)) {
+                       char *nme = mapi_fetch_field(hdl, 1);
+                       char *age = mapi_fetch_field(hdl, 2);
+
+                       printf("%s is %s\n", nme, age);
+               }
        } else {
                fprintf(stderr, "%s: unknown language, only mal and sql 
supported\n", argv[0]);
                exit(1);
        }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to