Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16:/tmp/cvs-serv4863/src/server

Modified Files:
      Tag: SQL_2-16
        sql_schema.mx sql_select.mx 
Log Message:
approved some more output

fixed bug in single row view's


Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.175.2.8
retrieving revision 1.175.2.9
diff -u -d -r1.175.2.8 -r1.175.2.9
--- sql_select.mx       31 Mar 2007 20:34:02 -0000      1.175.2.8
+++ sql_select.mx       19 Apr 2007 11:48:48 -0000      1.175.2.9
@@ -56,6 +56,7 @@
 
 extern stmt *sql_subquery(mvc *sql, scope *scp, symbol *sq, exp_kind ek);
 extern stmt *scope_subquery(mvc *sql, scope *scp, symbol *sq, exp_kind ek );
+extern stmt *scope_subtable(mvc *sql, scope *scp, symbol *sq, exp_kind ek );
 extern stmt *flat_subquery(mvc *sql, symbol *sq);
 extern stmt *sql_reorder(stmt *order, stmt *s);
 
@@ -120,7 +121,10 @@
 
        /* colum or table function */
        st = tail_type(sq);
-       assert(st->comp_type);
+       if (!st->comp_type) {
+               (void) sql_error(sql, 02, "SELECT: '%s' does not return a 
table", tname);
+               return NULL;
+       }
        tv = scope_add_table(scp, sq, tname, NULL);
 
        /* foreach column add column name */
@@ -251,6 +255,34 @@
 }
 
 stmt *
+scope_subtable(mvc *sql, scope *scp, symbol *sq, exp_kind ek)
+{
+       stmt *s;
+
+       scp = scope_open(scp);
+       s = sql_subquery(sql, scp, sq, ek);
+       /* create a table from a single value subquery result */
+       if (s->key && s->nrcols == 0) {
+               list *l = create_stmt_list();
+               node *n;
+
+               for (n = s->op1.lval->h; n; n = n->next) {
+                       stmt *ns = stmt_dup(n->data);
+                       char *cname = column_name(ns);
+                       stmt *temp = stmt_temp(tail_type(ns));
+
+                       ns = stmt_append(temp, ns);
+                       ns = stmt_alias(ns, table_name(ns), cname);
+                       list_append(l, ns);
+               }
+               stmt_destroy(s);
+               s = stmt_list(l);
+       }
+       scp = scope_close(scp);
+       return s;
+}
+
+stmt *
 scope_subquery(mvc *sql, scope *scp, symbol *sq, exp_kind ek)
 {
        stmt *s;

Index: sql_schema.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_schema.mx,v
retrieving revision 1.111.2.6
retrieving revision 1.111.2.7
diff -u -d -r1.111.2.6 -r1.111.2.7
--- sql_schema.mx       31 Mar 2007 08:07:48 -0000      1.111.2.6
+++ sql_schema.mx       19 Apr 2007 11:48:47 -0000      1.111.2.7
@@ -769,7 +769,7 @@
                sql->depth++;
                if (sql->depth > SQL_MAXDEPTH)
                        return sql_error(sql, 02, "CREATE VIEW: too many nested 
VIEWS");
-               sq = scope_subquery(sql, NULL, query, ek );
+               sq = scope_subtable(sql, NULL, query, ek );
                sql->depth--;
                if (!sq)
                        return NULL;
@@ -1588,7 +1588,7 @@
                int with_data = as_sq->h->next->next->data.ival;
                sql_table *t = NULL; 
 
-               sq = scope_subquery(sql, NULL, subquery, ek);
+               sq = scope_subtable(sql, NULL, subquery, ek);
                /* make sure we get a list of ordered columns */
                if (sq && sq->type == st_ordered) {
                        stmt *order = stmt_dup(sq->op1.stval);


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to