Changeset: dec26aa15db9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dec26aa15db9
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/examples/C/smack00.c
clients/examples/C/smack01.c
Branch: default
Log Message:
Removed MIL and XQUERY from C examples.
diffs (210 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
@@ -83,20 +83,8 @@
if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL ||
mapi_error(dbh))
die(dbh, hdl);
} else {
- if ((hdl = mapi_query(dbh, "var emp:= new(str,int);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"John\",23);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"Mary\",22);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "print(emp);")) == NULL ||
mapi_error(dbh))
- die(dbh, hdl);
+ fprintf(stderr, "%s: unknown language, only mal and sql
supported\n", argv[0]);
+ exit(1);
}
while (mapi_fetch_row(hdl)) {
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
@@ -83,20 +83,8 @@
if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL ||
mapi_error(dbh))
die(dbh, hdl);
} else {
- if ((hdl = mapi_query(dbh, "var emp:= new(str,int);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"John\",23);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"Mary\",22);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "print(emp);")) == NULL ||
mapi_error(dbh))
- die(dbh, hdl);
+ fprintf(stderr, "%s: unknown language, only mal and sql
supported\n", argv[0]);
+ exit(1);
}
while (mapi_fetch_row(hdl)) {
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
@@ -78,16 +78,8 @@
if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL ||
mapi_error(dbh))
die(dbh, hdl);
} else {
- if ((hdl = mapi_query(dbh, "var emp:= new(str,int);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query_array(dbh, "emp.insert(\"?\",?);", parm))
== NULL || mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "print(emp);")) == NULL ||
mapi_error(dbh))
- die(dbh, hdl);
+ fprintf(stderr, "%s: unknown language, only mal and sql
supported\n", argv[0]);
+ exit(1);
}
if (mapi_bind(hdl, 0, &nme))
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
@@ -89,20 +89,8 @@
if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL ||
mapi_error(dbh))
die(dbh, hdl);
} else {
- if ((hdl = mapi_query(dbh, "var emp:= new(str,int);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"John\",23);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"Mary\",22);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "print(emp);")) == NULL ||
mapi_error(dbh))
- die(dbh, hdl);
+ fprintf(stderr, "%s: unknown language, only mal and sql
supported\n", argv[0]);
+ exit(1);
}
/* Retrieve all tuples in the client cache first */
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
@@ -90,20 +90,8 @@
if ((hdl = mapi_query(dbh, "io.print(emp);")) == NULL ||
mapi_error(dbh))
die(dbh, hdl);
} else {
- if ((hdl = mapi_query(dbh, "var emp:= new(str,int);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"John\",23);")) == NULL)
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "emp.insert(\"Mary\",22);")) == NULL
|| mapi_error(dbh))
- die(dbh, hdl);
- if (mapi_close_handle(hdl) != MOK)
- die(dbh, hdl);
- if ((hdl = mapi_query(dbh, "print(emp);")) == NULL ||
mapi_error(dbh))
- die(dbh, hdl);
+ fprintf(stderr, "%s: unknown language, only mal and sql
supported\n", argv[0]);
+ exit(1);
}
rows = mapi_fetch_all_rows(hdl);
diff --git a/clients/examples/C/smack00.c b/clients/examples/C/smack00.c
--- a/clients/examples/C/smack00.c
+++ b/clients/examples/C/smack00.c
@@ -48,8 +48,8 @@
MapiHdl hdl = NULL;
int i, port, n = 20000;
char buf[40];
- int lang = 0;
- char *l = "mil";
+ int lang = 1;
+ char *l = "sql";
/* char *line; */
@@ -61,12 +61,9 @@
l = argv[2];
if (strcmp(argv[2], "sql") == 0)
lang = 1;
- else if (strcmp(argv[2], "xquery") == 0)
- lang = 2;
else if (strcmp(argv[2], "mal") == 0)
lang = 3;
}
- if (lang == 2) n /= 40; /* xquery is so slow..*/
port = atol(argv[1]);
dbh = mapi_connect("localhost", port, "monetdb", "monetdb", l, NULL);
@@ -78,14 +75,10 @@
die(dbh,NULL);
for (i = 0; i < n; i++) {
- if (lang==2)
- snprintf(buf, 40, "%d", i);
- else if (lang==1)
+ if (lang==1)
snprintf(buf, 40, "select %d;", i);
- else if (lang==3)
+ else
snprintf(buf, 40, "io.print(%d);", i);
- else
- snprintf(buf, 40, "print(%d);", i);
if ((hdl = mapi_query(dbh, buf)) == NULL || mapi_error(dbh))
die(dbh, hdl);
while ( (/*line= */ mapi_fetch_line(hdl)) != NULL) {
diff --git a/clients/examples/C/smack01.c b/clients/examples/C/smack01.c
--- a/clients/examples/C/smack01.c
+++ b/clients/examples/C/smack01.c
@@ -49,8 +49,8 @@
int i;
char buf[40], *line;
int port;
- int lang = 0;
- char *l = "mil";
+ int lang = 1;
+ char *l = "sql";
if (argc != 2 && argc != 3) {
printf("usage: smack01 <port> [<language>]\n");
@@ -60,8 +60,6 @@
l = argv[2];
if (strcmp(argv[2], "sql") == 0)
lang = 1;
- else if (strcmp(argv[2], "xquery") == 0)
- lang = 2;
else if (strcmp(argv[2], "mal") == 0)
lang = 3;
}
@@ -79,14 +77,10 @@
if (lang==1 && (mapi_setAutocommit(dbh, 0) != MOK ||
mapi_error(dbh)))
die(dbh,NULL);
- if (lang==2)
- snprintf(buf, 40, "%d", i);
- else if (lang==1)
+ if (lang==1)
snprintf(buf, 40, "select %d;", i);
- else if (lang==3)
+ else
snprintf(buf, 40, "io.print(%d);", i);
- else
- snprintf(buf, 40, "print(%d);", i);
if ((hdl = mapi_query(dbh, buf)) == NULL || mapi_error(dbh))
die(dbh, hdl);
while ((line = mapi_fetch_line(hdl))) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list