Changeset: 6adf30a20074 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6adf30a20074
Modified Files:
        monetdb5/mal/mal_profiler.mx
        monetdb5/modules/kernel/batcast.mx
        monetdb5/modules/mal/tablet.mx
        sql/backends/monet5/sql.mx
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_result.mx
        sql/backends/monet5/sql_user.c
        sql/server/rel_bin.c
        sql/server/sql_statement.c
        sql/server/sql_statement.h
        sql/sql/16_tracelog.sql
        sql/test/BugTracker-2010/Tests/mat.slice_limit1.Bug-2645.sql
        sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
        sql/test/leaks/Tests/check0.stable.out
        sql/test/leaks/Tests/check1.stable.out
        sql/test/leaks/Tests/check2.stable.out
        sql/test/leaks/Tests/check3.stable.out
        sql/test/leaks/Tests/check4.stable.out
        sql/test/leaks/Tests/check5.stable.out
        sql/test/leaks/Tests/drop3.stable.out
        sql/test/leaks/Tests/temp1.stable.out
        sql/test/leaks/Tests/temp2.stable.out
        sql/test/leaks/Tests/temp3.stable.out
        sql/test/mapi/Tests/php_monetdb.stable.out
Branch: default
Log Message:

table returning functions now return multiple bats instead of a bat
of bats.


diffs (truncated from 1649 to 300 lines):

diff --git a/monetdb5/mal/mal_profiler.mx b/monetdb5/mal/mal_profiler.mx
--- a/monetdb5/mal/mal_profiler.mx
+++ b/monetdb5/mal/mal_profiler.mx
@@ -271,7 +271,7 @@ mal_export int malProfileMode;
 mal_export void clearTrace(void);
 mal_export BAT *getTrace(str ev);
 mal_export int getTraceType(str nme);
-mal_export BAT * TRACEtable(void);
+mal_export void TRACEtable(BAT **r);
 
 mal_export lng getDiskSpace(void);
 mal_export lng getDiskReads(void);
@@ -1007,31 +1007,25 @@ static BAT *TRACE_id_writes = 0;
 static BAT *TRACE_id_thread = 0;
 static BAT *TRACE_id_user = 0;
 
-BAT *
-TRACEtable(void)
+void
+TRACEtable(BAT **r)
 {
-       BAT *t;
-
        if (initTrace())
-               return NULL;
-       t = BATnew(TYPE_str, TYPE_bat, 9);
-       if (t == NULL)
-               return NULL;
+               return ;
        mal_set_lock(mal_profileLock, "profileLock");
-       BUNins(t, "event", &TRACE_id_event->batCacheid, FALSE);
-       BUNins(t, "clk", &TRACE_id_time->batCacheid, FALSE);
-       BUNins(t, "pc", &TRACE_id_pc->batCacheid, FALSE);
-       BUNins(t, "thread", &TRACE_id_thread->batCacheid, FALSE);
-       BUNins(t, "user", &TRACE_id_user->batCacheid, FALSE);
-       BUNins(t, "ticks", &TRACE_id_ticks->batCacheid, FALSE);
-       BUNins(t, "reads", &TRACE_id_reads->batCacheid, FALSE);
-       BUNins(t, "writes", &TRACE_id_writes->batCacheid, FALSE);
-       BUNins(t, "rbytes", &TRACE_id_rbytes->batCacheid, FALSE);
-       BUNins(t, "wbytes", &TRACE_id_wbytes->batCacheid, FALSE);
-       BUNins(t, "type", &TRACE_id_type->batCacheid, FALSE);
-       BUNins(t, "stmt", &TRACE_id_stmt->batCacheid, FALSE);
+       r[0] = TRACE_id_event;
+       r[1] = TRACE_id_time;
+       r[2] = TRACE_id_pc;
+       r[3] = TRACE_id_thread;
+       r[4] = TRACE_id_user;
+       r[5] = TRACE_id_ticks;
+       r[6] = TRACE_id_reads;
+       r[7] = TRACE_id_writes;
+       r[8] = TRACE_id_rbytes;
+       r[9] = TRACE_id_wbytes;
+       r[10] = TRACE_id_type;
+       r[11] = TRACE_id_stmt;
        mal_unset_lock(mal_profileLock, "profileLock");
-       return t;
 }
 
 static BAT *
diff --git a/monetdb5/modules/kernel/batcast.mx 
b/monetdb5/modules/kernel/batcast.mx
--- a/monetdb5/modules/kernel/batcast.mx
+++ b/monetdb5/modules/kernel/batcast.mx
@@ -128,6 +128,9 @@ All Rights Reserved.
        @:coercion(str,bit)@
 
        @:coercion(str,int)@
+
+       @:coercion(int,str)@
+       @:coercion(lng,str)@
        # @-
 @include kprelude.mx
 @h
diff --git a/monetdb5/modules/mal/tablet.mx b/monetdb5/modules/mal/tablet.mx
--- a/monetdb5/modules/mal/tablet.mx
+++ b/monetdb5/modules/mal/tablet.mx
@@ -480,8 +480,9 @@ tablet_export int TABLETcreate_bats(Tabl
 tablet_export BUN TABLETassign_BATs(Tablet * as, BAT *bats);
 tablet_export BUN TABLETload_file(Tablet * as, bstream *b, stream *out);
 tablet_export BUN SQLload_file(Client cntxt, Tablet * as, bstream *b, stream 
*out, char *csep, char *rsep, char quote, lng skip, lng maxrow);
+tablet_export BAT **TABLETcollect(Tablet * as);
 tablet_export BAT *TABLETcollect_bats(Tablet * as);
-tablet_export BAT *TABLETcollect_parts(Tablet * as, BUN offset);
+tablet_export BAT **TABLETcollect_parts(Tablet * as, BUN offset);
 tablet_export void TABLETdestroy_format(Tablet * as);
 tablet_export int TABLEToutput_file(Tablet * as, BAT *order, stream *s);
 
@@ -1344,10 +1345,43 @@ TABLETcollect_bats(Tablet * as)
        return bats;
 }
 
-BAT *
+BAT **
+TABLETcollect(Tablet * as)
+{
+       BAT **bats = GDKmalloc(sizeof(BAT*) * as->nr_attrs);
+       Column *fmt = as->format;
+       BUN i;
+       BUN cnt = BATcount(fmt[0].c[0]);
+
+       if (bats == NULL)
+               return NULL;
+       for (i = 0; i < as->nr_attrs; i++) {
+               bats[i] = fmt[i].c[0];
+               BBPincref(bats[i]->batCacheid, FALSE);
+               BATsetaccess(fmt[i].c[0], BAT_READ);
+               BATaccessBegin(fmt[i].c[0], USE_ALL, MMAP_WILLNEED);
+               BATpropcheck(fmt[i].c[0], BATPROPS_ALL);
+               /* drop the hashes, we don't need them now  and they consume 
space */
+               HASHremove(fmt[i].c[0]);
+
+               BATpropcheck(BATmirror(fmt[i].c[0]), BATPROPS_ALL);
+               /* drop the hashes, we don't need them now  and they consume 
space */
+               HASHremove(BATmirror(fmt[i].c[0]));
+               BATaccessEnd(fmt[i].c[0], USE_ALL, MMAP_WILLNEED);
+
+               if (cnt != BATcount(fmt[i].c[0])) {
+                       if ( as->error == 0) /* a new error */
+                               GDKerror("Error: column " BUNFMT "  count " 
BUNFMT " differs from " BUNFMT "\n",i,BATcount(fmt[i].c[0]),cnt);
+                       return NULL;
+               }
+       }
+       return bats;
+}
+
+BAT **
 TABLETcollect_parts(Tablet * as, BUN offset)
 {
-       BAT *bats = BATnew(TYPE_str, TYPE_bat, as->nr_attrs);
+       BAT **bats = GDKmalloc(sizeof(BAT*) * as->nr_attrs);
        Column *fmt = as->format;
        BUN i;
        BUN cnt = BATcount(fmt[0].c[0]);
@@ -1361,7 +1395,7 @@ TABLETcollect_parts(Tablet * as, BUN off
 
                BATsetaccess(b, BAT_READ);
                bv = BATslice(b, offset, BATcount(b));
-               BUNins(bats, (ptr) fmt[i].name, (ptr) &bv->batCacheid, FALSE);
+               bats[i] = bv;
                /* we "mis"use BATpropcheck to set rather than verify 
properties on 
                 * the newly loaded slice; hence, we locally disable property 
errors */
                GDKdebug &= ~PROPMASK;
@@ -1391,10 +1425,8 @@ TABLETcollect_parts(Tablet * as, BUN off
                if (cnt != BATcount(b)) {
                        if ( as->error == 0) /* a new error */
                                GDKerror("Error: column " BUNFMT "  count " 
BUNFMT " differs from " BUNFMT "\n",i,BATcount(b),cnt);
-                       BBPunfix(bats->batCacheid);
                        return NULL;
                }
-               BBPunfix(bv->batCacheid);
        }
        return bats;
 }
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -239,10 +239,6 @@ pattern delete{unsafe}(mvc:int, sname:st
 address mvc_delete_wrap
 comment "delete from table";
 
-command columnBind(b:bat[:str,:bat], nme:str) :bat[:oid,:any_1]
-address mvc_bind_single_wrap
-comment "Bind the column bat into the focus ";
-
 # @-
 # The Monet 5 code generator uses several SQL specific wrapper functions.
 pattern resultSet{unsafe}( nr_cols:int, sep:str, rsep:str, ssep:str, ns:str, 
order:any_1 ) :int 
@@ -312,64 +308,28 @@ pattern exportValue{unsafe}(qtype:int, t
 address mvc_export_value_wrap 
 comment "export a single value onto the stream s";
 
-pattern importTable{unsafe}( s:bstream, sname:str, tname:str, 
-       sep:str, rsep:str, ssep:str, ns:str, nr:lng, offset:lng, locked:int) 
:bat[:str,:bat]
+pattern copy_from{unsafe}( sname:str, tname:str, 
+       sep:str, rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, 
locked:int)(:bat[:oid,:any]...)
 address mvc_import_table_wrap
 comment "Import a table from bstream s with the 
        given tuple and seperators (sep/rsep)";
 
+pattern copyfrom{unsafe}( sname:str, tname:str, 
+       sep:str, rsep:str, ssep:str, ns:str, nr:lng, offset:lng, 
locked:int)(:bat[:oid,:any]...)
+address mvc_import_table_stdin
+comment "Import a table from bstream s with the 
+       given tuple and seperators (sep/rsep)";
+
 function single(x:any_2):bat[:oid,:any_2];
        b := bat.new(0:oid, x);
        c := bat.append(b, x);
        return c;
 end single;
 
-function copy_from(
-       sname:str,
-       tname:str,
-       tsep:str,
-       rsep:str,
-       ssep:str,
-       ns:str,
-       fname:str,
-       nr:lng,
-       offset:lng,
-       locked:int
-):bat[:str,:bat];
-       cs := str.codeset();
-       f  := str.iconv(fname, "UTF-8", cs);
-       s  := streams.openRead(f);
-       #bs := bstream.create(s, 1048576);
-       #bs := bstream.create(s, 8388608);
-       bs := bstream.create(s, 33554432);
-       #bs := bstream.create(s, 67108864);
-
-       res := sql.importTable(bs, sname, tname, tsep, rsep, ssep, ns, nr, 
offset, locked);
-       bstream.destroy(bs);
-       return res;
-end copy_from;
-
-function copyfrom(
-       sname:str,
-       tname:str,
-       tsep:str,
-       rsep:str,
-       ssep:str,
-       ns:str,
-       nr:lng,
-       offset:lng,
-       locked:int
-):bat[:str,:bat];
-       in := io.stdin();
-       res := sql.importTable(in, sname, tname, tsep, rsep, ssep, ns, nr, 
offset, locked);
-       return res;
-end copyfrom;
-
-pattern importTable{unsafe}( sname:str, tname:str, fname:str... ) 
:bat[:str,:bat]
+pattern importTable{unsafe}( sname:str, tname:str, fname:str... 
)(:bat[:oid,:any]...)
 address mvc_bin_import_table_wrap
 comment "Import a table from the files (fname)";
 
-
 command zero_or_one( col:bat[:any_2,:any_1]) :any_1
 address zero_or_one
 comment "if col contains exactly one value return this. Incase of more raise 
an exception else return nil";
@@ -430,78 +390,61 @@ pattern argRecord(a:any...):str
 address SQLargRecord
 comment "Glue together the calling sequence";
 
-function sql_environment{inline}():bat[:str,:bat];
-       b := bat.new(:str,:bat,2);
+function sql_environment{inline}()(name:bat[:oid,:str],value:bat[:oid,:str]);
        e := inspect.getEnvironment();
        n := algebra.markT(e, 0:oid);
        r := bat.reverse(n);
        v := algebra.markH(e, 0:oid);
-       b1:= bat.insert(b, "name", r);
-       b2:= bat.insert(b1, "value", v);
-       return sql_environment := b2;
+       return (r,v);
 end sql_environment;
 
-function clients{inline}():bat[:str,:bat];
-       b := bat.new(:str,:bat,5);
-       u:= clients.getUsers();
-       b1:= bat.insert(b,"user",u);
-       l:= clients.getLogins();
-       b2:= bat.insert(b1,"login",l);
-       c:= clients.getLastCommand();
-       b3:= bat.insert(b2,"lastcommand",c);
-       a:= clients.getActions();
-       b4:= bat.insert(b3,"actions",a);
-       t:= clients.getTime();
-       b5:= bat.insert(b4,"seconds",t);
-       return clients := b5;
+function clients{inline}()( user:bat[:oid,:str], login:bat[:oid,:str], 
lastcommand:bat[:oid,:str], actions:bat[:oid,:int], seconds:bat[:oid,:lng]);
+       U:= clients.getUsers();
+       u:= algebra.markH(U);
+       L:= clients.getLogins();
+       l:= algebra.markH(L);
+       C:= clients.getLastCommand();
+       c:= algebra.markH(C);
+       A:= clients.getActions();
+       a:= algebra.markH(A);
+       T:= clients.getTime();
+       t:= algebra.markH(T);
+       return (u,l,c,a,t);
 end clients;
 
-function bbp{inline}():bat[:str,:bat];
-       b := bat.new(:str,:bat,12);
+function bbp{inline}()( id:bat[:oid,:int], name:bat[:oid,:str], 
htype:bat[:oid,:str], ttype:bat[:oid,:str], count:bat[:oid,:lng], 
refcnt:bat[:oid,:int], lrefcnt:bat[:oid,:int], location:bat[:oid,:str], 
heat:bat[:oid,:int], dirty:bat[:oid,:str], status:bat[:oid,:str], 
kind:bat[:oid,:str]);
        ns := bbp.getNames();
        ri := algebra.markT(ns, 0:oid);
        i := bat.reverse(ri);
        n := algebra.markH(ns, 0:oid);
-       b1:= bat.insert(b, "id", i);
-       b2:= bat.insert(b1, "name", n);
        iht := bbp.getHeadType();
        ht := algebra.markH(iht, 0:oid);
-       b3:= bat.insert(b2, "htype", ht);
        itt := bbp.getTailType();
        tt := algebra.markH(itt, 0:oid);
-       b4:= bat.insert(b3, "ttype", tt);
        icnt := bbp.getCount();
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to