Update of /cvsroot/monetdb/sql/src/storage
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1972/src/storage

Modified Files:
        sql_storage.h store.mx 
Log Message:

A sequence of group new and derives is now closed with a group.done (does
the last step ie a group.new or derive).
This makes the code in merge table a bit cleaner (more could be done later)

sql.bind and append/update/delete now have an extra (first) argument,
making them safe to use in the dataflow (ie solved using variable dependencies)
(BREAKS octopus !)

Implemented read only tables. Use 
ALTER TABLE x SET READ ONLY; 
(cannot be reverted currently)

fixed bug in limit/offset handling, now we have 64 bit wrd instead of int.

The new read only required schema changes, ie backup/restore your db.
We therefor claimed some more oid's for internal functions.



Index: store.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/store.mx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- store.mx    30 Jan 2010 12:33:26 -0000      1.43
+++ store.mx    27 Feb 2010 19:28:11 -0000      1.44
@@ -36,8 +36,8 @@
 
 #include <m4/bpm.h>
 
-/* version 05.00.00 of catalog */
-#define CATALOG_VERSION 50000
+/* version 05.10.00 of catalog */
+#define CATALOG_VERSION 51000
 
 static MT_Lock bs_lock;
 static int store_oid = 0;
@@ -520,6 +520,8 @@
        v = table_funcs.column_find_value(tr, find_sql_column(columns, 
"number"), rid);
        c->colnr = *(int *)v;                   _DELETE(v);
        c->unique = 0;
+       v = table_funcs.column_find_value(tr, find_sql_column(columns, 
"storage"), rid);
+       c->storage_type = *(int *)v;            _DELETE(v);
        c->t = t;
        if (isTable(c->t))
                store_funcs.create_col(tr, c);
@@ -568,6 +570,8 @@
        if (isStream(t))
                t->persistence = SQL_STREAM;
        t->cleared = 0;
+       v = table_funcs.column_find_value(tr, find_sql_column(tables, 
"readonly"),rid);
+       t->readonly = *(bit *)v;        _DELETE(v);
 
        t->pkey = NULL;
        t->cluster = NULL;
@@ -955,11 +959,11 @@
                        sql_table *t = m->data;
                        sht 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);
+                       table_funcs.table_insert(tr, systable, &t->base.id, 
t->base.name, &s->base.id, ATOMnilptr(TYPE_str), &t->type, &t->system, &ca, 
&t->readonly);
                        for (o = t->columns.set->h; o; o = o->next) {
                                sql_column *c = o->data;
 
-                               table_funcs.table_insert(tr, syscolumn, 
&c->base.id, c->base.name, c->type.type->sqlname, &c->type.digits, 
&c->type.scale, &t->base.id, (c->def) ? c->def : ATOMnilptr(TYPE_str), 
&c->null, &c->colnr);
+                               table_funcs.table_insert(tr, syscolumn, 
&c->base.id, c->base.name, c->type.type->sqlname, &c->type.digits, 
&c->type.scale, &t->base.id, (c->def) ? c->def : ATOMnilptr(TYPE_str), 
&c->null, &c->colnr, &c->storage_type);
                        }
                }
        }
@@ -1086,6 +1090,7 @@
        col->colnr = table_next_column_nr(t);
        col->t = t;
        col->unique = 0;
+       col->storage_type = 0;
        cs_add(&t->columns, col, TR_NEW);
 
        if (isTable(col->t))
@@ -1108,6 +1113,7 @@
        t->persistence = (temp_t)persistence;
        t->commit_action = (ca_t)commit_action;
        t->query = NULL;
+       t->readonly = 0;
        (sa)?cs_new(&t->columns, sa):cs_init(&t->columns, (fdestroy) 
&column_destroy);
        (sa)?cs_new(&t->idxs, sa):cs_init(&t->idxs, (fdestroy) &idx_destroy);
        (sa)?cs_new(&t->keys, sa):cs_init(&t->keys, (fdestroy) &key_destroy);
@@ -1134,6 +1140,7 @@
        col->colnr = c->colnr;
        col->t = t;
        col->unique = c->unique;
+       col->storage_type = c->storage_type;
        cs_add(&t->columns, col, TR_NEW);
        return col;
 }
@@ -1273,7 +1280,7 @@
        MT_lock_init(&bs_lock, "SQL_bs_lock");
        types_init(debug);
 
-#define FUNC_OIDS 1061
+#define FUNC_OIDS 2000
        assert( store_oid <= FUNC_OIDS );
        /* we store some spare oids */
        store_oid = FUNC_OIDS;
@@ -1361,8 +1368,9 @@
                bootstrap_create_column(tr, t, "schema_id", "int", 32);
                bootstrap_create_column(tr, t, "query", "varchar", 2048);
                bootstrap_create_column(tr, t, "type", "smallint", 16);
-               bootstrap_create_column(tr, t, "system", "boolean", 0);
-               bootstrap_create_column(tr, t, "commit_action", "smallint", 
16); 
+               bootstrap_create_column(tr, t, "system", "boolean", 1);
+               bootstrap_create_column(tr, t, "commit_action", "smallint", 16);
+               bootstrap_create_column(tr, t, "readonly", "boolean", 1);
 
                t = bootstrap_create_table(tr, s, "_columns");
                bootstrap_create_column(tr, t, "id", "int", 32);
@@ -1372,8 +1380,9 @@
                bootstrap_create_column(tr, t, "type_scale", "int", 32);
                bootstrap_create_column(tr, t, "table_id", "int", 32);
                bootstrap_create_column(tr, t, "default", "varchar", 2048);
-               bootstrap_create_column(tr, t, "null", "boolean", 0);
+               bootstrap_create_column(tr, t, "null", "boolean", 1);
                bootstrap_create_column(tr, t, "number", "int", 32);
+               bootstrap_create_column(tr, t, "storage", "int", 32);
 
                t = bootstrap_create_table(tr, s, "keys");
                bootstrap_create_column(tr, t, "id", "int", 32);
@@ -1795,6 +1804,7 @@
        c->colnr = oc->colnr;
        c->unique = oc->unique;
        c->t = t;
+       c->storage_type = oc->storage_type;
 
        if (isTable(c->t))
                store_funcs.dup_col(tr, oc, c);
@@ -1817,15 +1827,16 @@
                col->def = _strdup(c->def);
        col->null = c->null;
        col->colnr = c->colnr;
-       col->t = t;
        col->unique = c->unique;
+       col->t = t;
+       col->storage_type = c->storage_type;
 
        cs_add(&t->columns, col, TR_NEW);
 
        if (isTable(t))
                store_funcs.create_col(tr, col);
        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);
+               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->storage_type);
        col->base.wtime = t->base.wtime = t->s->base.wtime = tr->wtime = 
tr->stime;
        if (isGlobalTable(t)) 
                tr->schema_updates ++;
@@ -1844,6 +1855,7 @@
        t->system = ot->system;
        t->persistence = ot->persistence;
        t->commit_action = ot->commit_action;
+       t->readonly = ot->readonly;
        t->query = (ot->query) ? _strdup(ot->query) : NULL;
 
        cs_init(&t->columns, (fdestroy) &column_destroy);
@@ -2754,6 +2766,7 @@
 
                        fc->null = pfc->null;
                        fc->unique = pfc->unique;
+                       fc->storage_type = pfc->storage_type;
                        if (fc->def) 
                                _DELETE(fc->def);
                        fc->def = NULL;
@@ -3602,7 +3615,7 @@
        if (!isDeclaredTable(t))
                table_funcs.table_insert(tr, systable, &t->base.id, 
t->base.name, &s->base.id,
                        (t->query) ? t->query : ATOMnilptr(TYPE_str), &t->type,
-                       &t->system, &ca);
+                       &t->system, &ca, &t->readonly);
 
        t->base.wtime = s->base.wtime = tr->wtime = tr->stime;
        if (isGlobalTable(t)) 
@@ -3713,6 +3726,7 @@
        col->colnr = table_next_column_nr(t);
        col->t = t;
        col->unique = 0;
+       col->storage_type = 0;
 
        cs_add(&t->columns, col, TR_NEW);
        return col;
@@ -3793,7 +3807,7 @@
        if (isTable(col->t))
                store_funcs.create_col(tr, col);
        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);
+               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->storage_type);
 
        col->base.wtime = t->base.wtime = t->s->base.wtime = tr->wtime = 
tr->stime;
        if (isGlobalTable(t)) 
@@ -3880,6 +3894,25 @@
        return col;
 }
 
+sql_table *
+sql_trans_alter_readonly(sql_trans *tr, sql_table *t, int readonly)
+{
+       if (t->readonly != readonly) {
+               sql_schema *syss = find_sql_schema(tr, 
isGlobalTable(t)?"sys":"tmp"); 
+               sql_table *systable = find_sql_table(syss, "_tables");
+               oid rid = table_funcs.column_find_row(tr, 
find_sql_column(systable, "id"),
+                                         &t->base.id, NULL);
+
+               assert(rid != oid_nil);
+               table_funcs.column_update_value(tr, find_sql_column(systable, 
"readonly"), rid, &readonly);
+               t->readonly = readonly;
+               t->base.wtime = t->s->base.wtime = tr->wtime = tr->stime;
+               if (isGlobalTable(t)) 
+                       tr->schema_updates ++;
+       }
+       return t;
+}
+
 sql_column *
 sql_trans_alter_default(sql_trans *tr, sql_column *col, char *val)
 {

Index: sql_storage.h
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/sql_storage.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- sql_storage.h       26 Jan 2010 13:25:29 -0000      1.65
+++ sql_storage.h       27 Feb 2010 19:28:11 -0000      1.66
@@ -316,6 +316,7 @@
 
 extern void sql_trans_drop_table(sql_trans *tr, sql_schema *s, int id, int 
drop_action);
 extern BUN sql_trans_clear_table(sql_trans *tr, sql_table *t);
+extern sql_table *sql_trans_alter_readonly(sql_trans *tr, sql_table *t, int 
readonly);
 
 extern sql_column *sql_trans_create_column(sql_trans *tr, sql_table *t, char 
*name, sql_subtype *tpe);
 extern void sql_trans_drop_column(sql_trans *tr, sql_table *t, int id, int 
drop_action);


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to