Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18004/src/backends/monet5
Modified Files:
Tag: SQL_2-24
sql.mx sql_gencode.mx sql_optimizer.mx
Log Message:
we need to drop declared tables when we leave the scope.
THis fixes bug mdb_starts_with_sql_debug_64.SF-1999354.sql.
U sql_gencode.mx
Index: sql_gencode.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_gencode.mx,v
retrieving revision 1.275.2.4
retrieving revision 1.275.2.5
diff -u -d -r1.275.2.4 -r1.275.2.5
--- sql_gencode.mx 13 Jul 2008 14:43:08 -0000 1.275.2.4
+++ sql_gencode.mx 15 Jul 2008 14:20:44 -0000 1.275.2.5
@@ -200,6 +200,16 @@
return nr;
}
+static int
+drop_table(MalBlkPtr mb, str n)
+{
+ InstrPtr k = newStmt1(mb, sqlRef, "dropDeclaredTable");
+ int nr = getDestVar(k);
+
+ k = pushStr(mb, k, n);
+ return nr;
+}
+
@-
The dump_cols produces a sequence of instructions for
@@ -1814,6 +1824,11 @@
case st_return: {
int c = _dumpstmt(sql,mb, s->op1.stval);
int tt = tail_type(s->op1.stval)->type->localtype;
+
+ if (s->flag) { /* drop declared tables */
+ InstrPtr k = newStmt1(mb, sqlRef,
"dropDeclaredTables");
+ k = pushInt(mb, k, s->flag);
+ }
q = newInstruction(mb,RETURNsymbol);
if (tt == TYPE_bat) {
tt = newBatType(TYPE_str,TYPE_bat);
@@ -1825,11 +1840,19 @@
pushInstruction(mb, q);
} break;
case st_assign: {
- int r = _dumpstmt(sql,mb, s->op2.stval);
+ int r = -1;
+
+ if (s->op2.stval)
+ r = _dumpstmt(sql,mb, s->op2.stval);
if (!VAR_GLOBAL(s->flag)) { /* globals */
- char *vn = atom2string(s->op1.stval->op1.aval);
- char *buf;
+ char *buf, *vn =
atom2string(s->op1.stval->op1.aval);
+ if (!s->op2.stval) {
+ /* drop declared table */
+ s->nr = drop_table(mb, vn);
+ _DELETE(vn);
+ break;
+ }
buf = alloca(SMALLBUFSIZ);
(void) snprintf(buf, SMALLBUFSIZ, "A%s", vn);
q = newInstruction(mb,ASSIGNsymbol);
U sql_optimizer.mx
Index: sql_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_optimizer.mx,v
retrieving revision 1.181.2.1
retrieving revision 1.181.2.2
diff -u -d -r1.181.2.1 -r1.181.2.2
--- sql_optimizer.mx 4 Jun 2008 20:19:14 -0000 1.181.2.1
+++ sql_optimizer.mx 15 Jul 2008 14:20:45 -0000 1.181.2.2
@@ -327,6 +327,10 @@
sql_bpm *bpm = NULL;
sql_schema *s = mvc_bind_schema(m, sname);
+ if (!s || strcmp(s->base.name, dt_schema) == 0) {
+ pushInstruction(mb,p);
+ continue;
+ }
if (f == binddbatRef) {
mode = getVarConstant(mb, getArg(p,3)).val.ival;
} else {
U sql.mx
Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.263.2.4
retrieving revision 1.263.2.5
diff -u -d -r1.263.2.4 -r1.263.2.5
--- sql.mx 22 Jun 2008 13:45:35 -0000 1.263.2.4
+++ sql.mx 15 Jul 2008 14:20:41 -0000 1.263.2.5
@@ -185,6 +185,14 @@
command dtColumn{unsafe}(rs:int, tname:str, name:str, typename:str,
digits:int, scale:int) :void
address mvc_declared_table_column_wrap;
+command dropDeclaredTable{unsafe}( name:str ) :void
+address mvc_drop_declared_table_wrap
+comment "drop a declared table";
+
+command dropDeclaredTables{unsafe}( nr:int ) :void
+address mvc_drop_declared_tables_wrap
+comment "drop top n declared tables";
+
command exportResult{unsafe}(s:streams, res_id:int, w:str) :void
address mvc_export_result_wrap
comment "Export a result (in order) to stream s";
@@ -715,6 +723,8 @@
sql5_export str mvc_declared_table_wrap(int *res_id, str *name);
sql5_export str mvc_declared_table_column_wrap(int *ret, int *rs, str *tname,
str *name, str *type, int *digits, int *scale);
+sql5_export str mvc_drop_declared_table_wrap(int *d, str *name);
+sql5_export str mvc_drop_declared_tables_wrap(int *d, int *nr);
sql5_export str mvc_result_value_wrap(MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
sql5_export str mvc_affected_rows_wrap(int *r, lng *nr, str *w);
@@ -1684,7 +1694,7 @@
if (msg)
return msg;
- s = mvc_bind_schema(m, "%dt%");
+ s = mvc_bind_schema(m, dt_schema);
(void)mvc_create_table(m, s, *name, TRUE, SQL_DECLARED_TABLE, CA_DROP,
0);
*res_id = 0;
return MAL_SUCCEED;
@@ -1706,13 +1716,51 @@
throw(SQL, "sql.dtColumn", "Cannot access declared table");
if (!sql_find_subtype(&tpe, *type, *digits, *scale))
throw(SQL, "sql.dtColumn", "Cannot find column type");
- s = mvc_bind_schema(m, "%dt%");
+ s = mvc_bind_schema(m, dt_schema);
t = mvc_bind_table(m, s, *tname);
(void)mvc_create_column(m, t, *name, &tpe);
return MAL_SUCCEED;
}
str
+mvc_drop_declared_table_wrap(int *d, str *name)
+{
+ mvc *m = NULL;
+ str msg = getContext(&m, NULL);
+ sql_schema *s = NULL;
+ sql_table *t = NULL;
+
+ if (msg)
+ return msg;
+ s = mvc_bind_schema(m, dt_schema);
+ t = mvc_bind_table(m, s, *name);
+ (void)mvc_drop_table(m, s, t, 0);
+ (void)d;
+ return MAL_SUCCEED;
+}
+
+str
+mvc_drop_declared_tables_wrap(int *d, int *nr)
+{
+ int i = *nr;
+ mvc *m = NULL;
+ str msg = getContext(&m, NULL);
+ sql_schema *s = NULL;
+ sql_table *t = NULL;
+
+ if (msg)
+ return msg;
+ s = mvc_bind_schema(m, dt_schema);
+ while(i && s->tables.set->t) {
+ t = s->tables.set->t->data;
+ (void)mvc_drop_table(m, s, t, 0);
+ i--;
+ }
+ (void)d;
+ return MAL_SUCCEED;
+}
+
+str
mvc_affected_rows_wrap(int *r, lng *nr, str *w)
{
backend *b = NULL;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins