Changeset: 7ea23908ca99 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7ea23908ca99
Modified Files:
Branch: default
Log Message:
Merge with Oct2010 branch.
diffs (123 lines):
diff -r 55a845164ef4 -r 7ea23908ca99 clients/src/mapiclient/dump.c
--- a/clients/src/mapiclient/dump.c Thu Sep 09 13:12:14 2010 +0200
+++ b/clients/src/mapiclient/dump.c Thu Sep 09 14:14:47 2010 +0200
@@ -106,6 +106,42 @@
}
static int
+has_systemfunctions(Mapi mid)
+{
+ MapiHdl hdl;
+ int ret;
+
+ if ((hdl = mapi_query(mid,
+ "SELECT \"t\".\"id\" "
+ "FROM \"_tables\" \"t\", \"schemas\" \"s\" "
+ "WHERE \"t\".\"name\" = 'systemfunctions' AND "
+ "\"t\".\"schema_id\" = \"s\".\"id\" AND "
+ "\"s\".\"name\" = 'sys'")) == NULL ||
+ mapi_error(mid))
+ goto bailout;
+ ret = mapi_get_row_count(hdl) == 1;
+ while ((mapi_fetch_row(hdl)) != 0) {
+ if (mapi_error(mid))
+ goto bailout;
+ }
+ if (mapi_error(mid))
+ goto bailout;
+ mapi_close_handle(hdl);
+ return ret;
+
+ bailout:
+ if (hdl) {
+ if (mapi_result_error(hdl))
+ mapi_explain_result(hdl, stderr);
+ else
+ mapi_explain_query(hdl, stderr);
+ mapi_close_handle(hdl);
+ } else
+ mapi_explain(mid, stderr);
+ return 0;
+}
+
+static int
dump_foreign_keys(Mapi mid, char *schema, char *tname, stream *toConsole)
{
MapiHdl hdl = NULL;
@@ -880,20 +916,19 @@
"\"sys\".\"functions\" \"f\" "
"WHERE \"f\".\"id\" > 2000 AND "
"\"s\".\"id\" = \"f\".\"schema_id\""
- "%s%s%s "
+ "%s%s%s%s "
"ORDER BY \"f\".\"id\"";
MapiHdl hdl;
char *q;
+ size_t l;
- if (sname != NULL) {
- size_t l = sizeof(functions) + strlen(sname) + 20;
-
- q = malloc(l);
- snprintf(q, l, functions, " AND \"s\".\"name\" = '", sname,
"'");
- } else {
- q = malloc(sizeof(functions));
- snprintf(q, sizeof(functions), functions, "", "", "");
- }
+ l = sizeof(functions) + (sname ? strlen(sname) : 0) + 100;
+ q = malloc(l);
+ snprintf(q, l, functions,
+ sname ? " AND \"s\".\"name\" = '" : "",
+ sname ? sname : "",
+ sname ? "'" : "",
+ has_systemfunctions(mid) ? " AND \"f\".\"id\" NOT IN (SELECT
\"function_id\" FROM \"sys\".\"systemfunctions\")" : "");
hdl = mapi_query(mid, q);
free(q);
if (hdl == NULL || mapi_error(mid))
@@ -1046,6 +1081,7 @@
"\"sys\".\"functions\" \"f\" "
"WHERE \"f\".\"sql\" = TRUE AND "
"\"s\".\"id\" = \"f\".\"schema_id\" "
+ "%s"
"UNION "
"SELECT \"s\".\"name\" AS \"sname\", "
"\"t\".\"name\" AS \"name\", "
@@ -1073,6 +1109,7 @@
MapiHdl hdl;
int create_hash_func = 0;
int rc = 0;
+ char query[1024];
/* start a transaction for the dump */
if (!describe)
@@ -1230,7 +1267,9 @@
mapi_close_handle(hdl);
/* dump tables */
- if ((hdl = mapi_query(mid, tables_and_functions)) == NULL ||
+ snprintf(query, sizeof(query), tables_and_functions,
+ has_systemfunctions(mid) ? "AND \"f\".\"id\" NOT IN (SELECT
\"function_id\" FROM \"sys\".\"systemfunctions\") " : "");
+ if ((hdl = mapi_query(mid, query)) == NULL ||
mapi_error(mid))
goto bailout;
diff -r 55a845164ef4 -r 7ea23908ca99 sql/src/sql/createdb.mx
--- a/sql/src/sql/createdb.mx Thu Sep 09 13:12:14 2010 +0200
+++ b/sql/src/sql/createdb.mx Thu Sep 09 14:14:47 2010 +0200
@@ -90,4 +90,6 @@
parts.sql -- testing only
replication.sql -- testing only
@sql
+...@include system.sql
+
commit;
diff -r 55a845164ef4 -r 7ea23908ca99 sql/src/sql/system.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sql/src/sql/system.sql Thu Sep 09 14:14:47 2010 +0200
@@ -0,0 +1,6 @@
+create table systemfunctions (function_id)
+ as (select id from functions) with data;
+update _tables
+ set system = true
+ where name = 'systemfunctions'
+ and schema_id = (select id from schemas where name = 'sys');
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list