Changeset: 51a75188092d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=51a75188092d
Modified Files:
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql_cat.c
        sql/backends/monet5/sql_gencode.c
Branch: oltp
Log Message:

it compiles again


diffs (truncated from 2855 to 300 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -127,23 +127,6 @@ sql_symbol2relation(mvc *c, symbol *sym)
        return r;
 }
 
-stmt *
-sql_relation2stmt(mvc *c, sql_rel *r)
-{
-       stmt *s = NULL;
-
-       if (!r) {
-               return NULL;
-       } else {
-               if (c->emode == m_plan) {
-                       rel_print(c, r, 0);
-               } else {
-                       s = output_rel_bin(c, r);
-               }
-       }
-       return s;
-}
-
 /*
  * After the SQL statement has been executed, its data structures
  * should be garbage collected. For successful actions we have to finish
@@ -451,8 +434,8 @@ cleanup:
     return msg;
 }
 
-static BAT *
-mvc_bind(mvc *m, char *sname, char *tname, char *cname, int access)
+BAT *
+mvc_bind(mvc *m, const char *sname, const char *tname, const char *cname, int 
access)
 {
        sql_trans *tr = m->session->tr;
        BAT *b = NULL;
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -56,8 +56,8 @@
 
 extern int sqlcleanup(mvc *c, int err);
 extern sql_rel *sql_symbol2relation(mvc *c, symbol *sym);
-extern stmt *sql_relation2stmt(mvc *c, sql_rel *r);
 
+extern BAT *mvc_bind(mvc *m, const char *sname, const char *tname, const char 
*cname, int access);
 extern BAT *mvc_bind_idxbat(mvc *m, const char *sname, const char *tname, 
const char *iname, int access);
 
 sql5_export str SQLmvc(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -687,14 +687,15 @@ UPGcreate_func(Client cntxt, MalBlkPtr m
        str sname = *getArgReference_str(stk, pci, 1), osname;
        str func = *getArgReference_str(stk, pci, 2);
        stmt *s;
+       backend *be;
 
-       if ((msg = getSQLContext(cntxt, mb, &sql, NULL)) != NULL)
+       if ((msg = getSQLContext(cntxt, mb, &sql, &be)) != NULL)
                return msg;
        if ((msg = checkSQLContext(cntxt)) != NULL)
                return msg;
        osname = cur_schema(sql)->base.name;
        mvc_set_schema(sql, sname);
-       s = sql_parse(sql, sa_create(), func, 0);
+       s = sql_parse(be, sa_create(), func, 0);
        if (s && s->type == st_catalog) {
                char *schema = 
((stmt*)s->op1->op4.lval->h->data)->op4.aval->data.val.sval;
                sql_func *func = 
(sql_func*)((stmt*)s->op1->op4.lval->t->data)->op4.aval->data.val.pval;
@@ -716,14 +717,15 @@ UPGcreate_view(Client cntxt, MalBlkPtr m
        str sname = *getArgReference_str(stk, pci, 1), osname;
        str view = *getArgReference_str(stk, pci, 2);
        stmt *s;
+       backend *be;
 
-       if ((msg = getSQLContext(cntxt, mb, &sql, NULL)) != NULL)
+       if ((msg = getSQLContext(cntxt, mb, &sql, &be)) != NULL)
                return msg;
        if ((msg = checkSQLContext(cntxt)) != NULL)
                return msg;
        osname = cur_schema(sql)->base.name;
        mvc_set_schema(sql, sname);
-       s = sql_parse(sql, sa_create(), view, 0);
+       s = sql_parse(be, sa_create(), view, 0);
        if (s && s->type == st_catalog) {
                char *schema = 
((stmt*)s->op1->op4.lval->h->data)->op4.aval->data.val.sval;
                sql_table *v = 
(sql_table*)((stmt*)s->op1->op4.lval->h->next->data)->op4.aval->data.val.pval;
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -45,32 +45,12 @@
 #include <rel_prop.h>
 #include <rel_rel.h>
 #include <rel_exp.h>
+#include <rel_psm.h>
 #include <rel_bin.h>
 #include <rel_dump.h>
 #include <rel_remote.h>
 
-static int _dumpstmt(backend *sql, MalBlkPtr mb, stmt *s);
-
-/*
- * @+ MAL code support
- * To simplify construction of the MAL program use the following
- * macros
- *
- * @+ MAL initialization
- * Many instructions have a more or less fixed structure, therefore
- * they can be assembled in a pre-compiled block. Each time we need it,
- * a copy can be extracted and included in the MAL block
- *
- * The catalog relations should be maintained in a MAL box, which
- * provides the handle for transaction management.
- *
- * The atoms produced by the parser should be converted back into
- * MAL constants. Ideally, this should not be necessary when the
- * SQL parser keeps the string representation around.
- * This involves regeneration of their string as well and
- * trimming the enclosing string quotes.
- */
-static int
+int
 constantAtom(backend *sql, MalBlkPtr mb, atom *a)
 {
        int idx;
@@ -84,35 +64,6 @@ constantAtom(backend *sql, MalBlkPtr mb,
        return idx;
 }
 
-static InstrPtr
-pushPtr(MalBlkPtr mb, InstrPtr q, ptr val)
-{
-       int _t;
-       ValRecord cst;
-
-       if (q == NULL)
-               return NULL;
-       cst.vtype= TYPE_ptr;
-       cst.val.pval = val;
-       cst.len = 0;
-       _t = defConstant(mb, TYPE_ptr, &cst);
-       return pushArgument(mb, q, _t);
-}
-
-static int
-argumentZero(MalBlkPtr mb, int tpe)
-{
-       ValRecord cst;
-       str msg;
-
-       cst.vtype = TYPE_int;
-       cst.val.ival = 0;
-       msg = convertConstant(tpe, &cst);
-       if( msg)
-               GDKfree(msg); // will not be called
-       return defConstant(mb, tpe, &cst);
-}
-
 /*
  * To speedup code generation we freeze the references to the major module 
names.
  */
@@ -124,235 +75,7 @@ initSQLreferences(void)
                GDKfatal("error initSQLreferences");
 }
 
-/*
- * The dump_header produces a sequence of instructions for
- * the front-end to prepare presentation of a result table.
- *
- * A secondary scheme is added to assemblt all information
- * in columns first. Then it can be returned to the environment.
- */
-#define NEWRESULTSET
-
-#define meta(Id,Tpe) \
-q = newStmt(mb, batRef, newRef);\
-q= pushType(mb,q, Tpe);\
-Id = getArg(q,0); \
-list = pushArgument(mb,list,Id);
-
-#define metaInfo(Id,Tpe,Val)\
-p = newStmt(mb, batRef, appendRef);\
-p = pushArgument(mb,p, Id);\
-p = push##Tpe(mb,p, Val);\
-Id = getArg(p,0);
-
-
-static int
-dump_header(mvc *sql, MalBlkPtr mb, stmt *s, list *l)
-{
-       node *n;
-       InstrPtr q;
-       int ret = -1;
-       // gather the meta information
-       int tblId, nmeId, tpeId, lenId, scaleId, k;
-       InstrPtr p = NULL, list;
-
-       list = newInstruction(mb,sqlRef, resultSetRef);
-       getArg(list,0) = newTmpVariable(mb,TYPE_int);
-       k = list->argc;
-       meta(tblId,TYPE_str);
-       meta(nmeId,TYPE_str);
-       meta(tpeId,TYPE_str);
-       meta(lenId,TYPE_int);
-       meta(scaleId,TYPE_int);
-
-       (void) s;
-
-       for (n = l->h; n; n = n->next) {
-               stmt *c = n->data;
-               sql_subtype *t = tail_type(c);
-               const char *tname = table_name(sql->sa, c);
-               const char *sname = schema_name(sql->sa, c);
-               const char *_empty = "";
-               const char *tn = (tname) ? tname : _empty;
-               const char *sn = (sname) ? sname : _empty;
-               const char *cn = column_name(sql->sa, c);
-               const char *ntn = sql_escape_ident(tn);
-               const char *nsn = sql_escape_ident(sn);
-               size_t fqtnl;
-               char *fqtn;
-
-               if (ntn && nsn && (fqtnl = strlen(ntn) + 1 + strlen(nsn) + 1) ){
-                       fqtn = NEW_ARRAY(char, fqtnl);
-                       snprintf(fqtn, fqtnl, "%s.%s", nsn, ntn);
-
-                       metaInfo(tblId,Str,fqtn);
-                       metaInfo(nmeId,Str,cn);
-                       metaInfo(tpeId,Str,(t->type->localtype == TYPE_void ? 
"char" : t->type->sqlname));
-                       metaInfo(lenId,Int,t->digits);
-                       metaInfo(scaleId,Int,t->scale);
-                       list = pushArgument(mb,list,c->nr);
-                       _DELETE(fqtn);
-               } else
-                       q = NULL;
-               c_delete(ntn);
-               c_delete(nsn);
-               if (q == NULL)
-                       return -1;
-       }
-       // add the correct variable ids
-       getArg(list,k++) = tblId;
-       getArg(list,k++) = nmeId;
-       getArg(list,k++) = tpeId;
-       getArg(list,k++) = lenId;
-       getArg(list,k) = scaleId;
-       ret = getArg(list,0);
-       pushInstruction(mb,list);
-       return ret;
-}
-
-static int
-dump_export_header(mvc *sql, MalBlkPtr mb, list *l, int file, str format, str 
sep,str rsep,str ssep,str ns)
-{
-       node *n;
-       InstrPtr q;
-       int ret = -1;
-       // gather the meta information
-       int tblId, nmeId, tpeId, lenId, scaleId, k;
-       InstrPtr p= NULL, list;
-
-       list = newInstruction(mb, sqlRef, export_tableRef);
-       getArg(list,0) = newTmpVariable(mb,TYPE_int);
-       if( file >= 0){
-               list  = pushArgument(mb, list, file);
-               list  = pushStr(mb, list, format);
-               list  = pushStr(mb, list, sep);
-               list  = pushStr(mb, list, rsep);
-               list  = pushStr(mb, list, ssep);
-               list  = pushStr(mb, list, ns);
-       }
-       k = list->argc;
-       meta(tblId,TYPE_str);
-       meta(nmeId,TYPE_str);
-       meta(tpeId,TYPE_str);
-       meta(lenId,TYPE_int);
-       meta(scaleId,TYPE_int);
-
-       for (n = l->h; n; n = n->next) {
-               stmt *c = n->data;
-               sql_subtype *t = tail_type(c);
-               const char *tname = table_name(sql->sa, c);
-               const char *sname = schema_name(sql->sa, c);
-               const char *_empty = "";
-               const char *tn = (tname) ? tname : _empty;
-               const char *sn = (sname) ? sname : _empty;
-               const char *cn = column_name(sql->sa, c);
-               const char *ntn = sql_escape_ident(tn);
-               const char *nsn = sql_escape_ident(sn);
-               size_t fqtnl;
-               char *fqtn;
-
-               if (ntn && nsn && (fqtnl = strlen(ntn) + 1 + strlen(nsn) + 1) ){
-                       fqtn = NEW_ARRAY(char, fqtnl);
-                       snprintf(fqtn, fqtnl, "%s.%s", nsn, ntn);
-
-                       metaInfo(tblId,Str,fqtn);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to