Update of /cvsroot/monetdb/sql/src/storage
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32040/src/storage

Modified Files:
      Tag: SQL_2-24
        sql_storage.h store.mx 
Log Message:
changed handling of declared tables to fix the schema_from_declared_table
bug.


U store.mx
Index: store.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/store.mx,v
retrieving revision 1.11.2.2
retrieving revision 1.11.2.3
diff -u -d -r1.11.2.2 -r1.11.2.3
--- store.mx    28 May 2008 17:20:03 -0000      1.11.2.2
+++ store.mx    4 Jun 2008 20:19:20 -0000       1.11.2.3
@@ -38,8 +38,8 @@
 #define CATALOG_VERSION 40000
 
 static MT_Lock bs_lock;
-static lng store_oid = 0;
-static lng prev_oid = 0;
+static int store_oid = 0;
+static int prev_oid = 0;
 static int nr_sessions = 0;
 static int transactions = 0;
 sql_trans *gtrans = NULL;
@@ -904,7 +904,7 @@
        table_funcs.rids_destroy(schemas);
 }
 
-static int
+static sqlid
 next_oid(void)
 {
        lng id = 0;
@@ -932,6 +932,8 @@
        for (n = tr->schemas.set->h; n; n = n->next) {
                sql_schema *s = n->data;
 
+               if (strcmp(s->base.name, "%dt%") == 0) 
+                       continue;
                table_funcs.table_insert(tr, sysschema, &s->base.id, 
s->base.name, &s->auth_id, &s->owner);
                for (m = s->tables.set->h; m; m = m->next) {
                        sql_table *t = m->data;
@@ -976,7 +978,8 @@
                sql_func *f = n->data;
                bit sql = f->sql;
                bit se = f->side_effect;
-               int id, number = 0;
+               sqlid id;
+               int number = 0;
                char arg_nme[] = "arg_0";
 
                if (f->s)
@@ -1016,7 +1019,8 @@
                char *name1 = "result";
                char *name2 = "arg";
                sql_func *aggr = n->data;
-               int id, number = 0;
+               sqlid id;
+               int number = 0;
 
                if (aggr->s)
                        table_funcs.table_insert(tr, sysfunc, &aggr->base.id, 
aggr->base.name, aggr->imp, aggr->mod, &F, &T, &F, &aggr->s->base.id);
@@ -1159,6 +1163,7 @@
 store_init(int debug, store_type store, char *logdir, char *dbname, 
backend_stack stk)
 {
        sqlid id = 0;
+       lng lng_store_oid;
        int first = 1;
        sql_schema *s, *p = NULL;
        sql_table *t, *types, *funcs, *args;
@@ -1332,6 +1337,8 @@
                }
        }
 
+       s = bootstrap_create_schema(tr, "%dt%", ROLE_SYSADMIN, USER_MONETDB);
+
        if (first) {
                insert_types(tr, types);
                insert_functions(tr, funcs, args);
@@ -1344,8 +1351,8 @@
        }
 
        id = store_oid; /* db objects up till id are allready created */
-       logger_funcs.get_sequence(OBJ_SID, &store_oid);
-       prev_oid = store_oid;
+       logger_funcs.get_sequence(OBJ_SID, &lng_store_oid);
+       prev_oid = store_oid = (sqlid)lng_store_oid;
 
        /* load remaining schemas, tables, columns etc */
        if (!first)
@@ -3216,14 +3223,14 @@
        table_funcs.table_insert(tr, sysfunc, &t->base.id, t->base.name, 
t->imp, t->mod, &sql, &aggr, &se, &s->base.id);
        if (t->res.type) {
                char *name = "result";
-               oid id = next_oid();
+               sqlid id = next_oid();
 
                table_funcs.table_insert(tr, sysarg, &id, &t->base.id, name, 
t->res.type->sqlname, &t->res.digits, &t->res.scale, &number);
                number++;
        }
        if (t->ops) for (n = t->ops->h; n; n = n->next, number++) {
                sql_arg *a = n->data;
-               oid id = next_oid();
+               sqlid id = next_oid();
 
                table_funcs.table_insert(tr, sysarg, &id, &t->base.id, a->name, 
a->type.type->sqlname, &a->type.type->digits, &a->type.type->scale, &number);
        }
@@ -3364,7 +3371,8 @@
        sht ca;
 
        /* temps all belong to a special tmp schema */
-       assert( !isTempTable(t) || (strcmp(s->base.name, "tmp") == 0));
+       assert( !isTempTable(t) || (strcmp(s->base.name, "tmp") == 0)
+               || isDeclaredTable(t));
 
        t->s = s;
        t->sz = sz;
@@ -3375,7 +3383,8 @@
        cs_add(&s->tables, t, TR_NEW);
        t->base.wtime = s->base.wtime = tr->wtime = tr->stime;
        ca = t->commit_action;
-       table_funcs.table_insert(tr, systable, &t->base.id, t->base.name, 
&s->base.id, ATOMnilptr(TYPE_str), &t->type, &t->system, &ca);
+       if (!isDeclaredTable(t))
+               table_funcs.table_insert(tr, systable, &t->base.id, 
t->base.name, &s->base.id, ATOMnilptr(TYPE_str), &t->type, &t->system, &ca);
        if (isGlobalTable(t)) 
                tr->schema_updates ++;
        return t;
@@ -3458,7 +3467,8 @@
                list_append(tr->dropped, local_id);
        }
                
-       sys_drop_table(tr, t, drop_action);
+       if (!isDeclaredTable(t))
+               sys_drop_table(tr, t, drop_action);
 
        t->base.wtime = s->base.wtime = tr->wtime = tr->stime;
        if (isGlobalTable(t) || (t->commit_action != CA_DROP)) 
@@ -3469,7 +3479,6 @@
                list_destroy(tr->dropped);
                tr->dropped = NULL;
        }
-
 }
 
 size_t
@@ -3518,7 +3527,8 @@
 
        if (isTable(col->t))
                store_funcs.create_col(tr, col);
-       table_funcs.table_insert(tr, syscolumn, &col->base.id, col->base.name, 
col->type.type->sqlname, &col->type.digits, &col->type.scale, &t->base.id, 
(col->def) ? col->def : ATOMnilptr(TYPE_str), &col->null, &col->colnr);
+       if (!isDeclaredTable(t))
+               table_funcs.table_insert(tr, syscolumn, &col->base.id, 
col->base.name, col->type.type->sqlname, &col->type.digits, &col->type.scale, 
&t->base.id, (col->def) ? col->def : ATOMnilptr(TYPE_str), &col->null, 
&col->colnr);
 
        col->base.wtime = t->base.wtime = t->s->base.wtime = tr->wtime = 
tr->stime;
        if (isGlobalTable(t)) 
@@ -3553,7 +3563,6 @@
                list_destroy(tr->dropped);
                tr->dropped = NULL;
        }
-       
 }
 
 sql_column *
@@ -4105,6 +4114,7 @@
        if (!s->tr)
                return;
 
+       /* TODO cleanup "dt" schema */
        tmp = find_sql_schema(s->tr, "tmp");
                
        if (tmp->tables.set) {

U sql_storage.h
Index: sql_storage.h
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/sql_storage.h,v
retrieving revision 1.46.4.1
retrieving revision 1.46.4.2
diff -u -d -r1.46.4.1 -r1.46.4.2
--- sql_storage.h       27 May 2008 20:44:05 -0000      1.46.4.1
+++ sql_storage.h       4 Jun 2008 20:19:19 -0000       1.46.4.2
@@ -29,6 +29,7 @@
 #define isGlobalTable(x) (x->persistence!=SQL_LOCAL_TEMP)
 #define isGlobalTemp(x) (x->persistence==SQL_GLOBAL_TEMP)
 #define isTempSchema(x)  (strcmp(x->base.name,"tmp") == 0)
+#define isDeclaredTable(x)  (x->persistence==SQL_DECLARED_TABLE)
 
 typedef enum store_type {
        store_bat,      /* delta bats, ie multi user read/write */


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to