Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18004/src/server
Modified Files:
Tag: SQL_2-24
sql_mvc.mx sql_psm.mx sql_statement.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_psm.mx
Index: sql_psm.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_psm.mx,v
retrieving revision 1.53.2.1
retrieving revision 1.53.2.2
diff -u -d -r1.53.2.1 -r1.53.2.2
--- sql_psm.mx 4 Jun 2008 20:19:16 -0000 1.53.2.1
+++ sql_psm.mx 15 Jul 2008 14:20:51 -0000 1.53.2.2
@@ -358,7 +358,23 @@
res = sql_value_exp(sql, scp, return_sym, NULL, NULL, sql_sel, ek);
if (!res || (res = check_types(sql, restype, res, type_equal)) == NULL)
return NULL;
- return stmt_return(res);
+ return stmt_return(res, stack_nr_of_declared_tables(sql));
+}
+
+static int
+has_return(stmt *s )
+{
+ if (s->type == st_return) {
+ return 1;
+ } else if (s->type == st_if) {
+ int res = has_return(s->op2.stval); /* ifstmts */
+ if (res && s->op3.stval)
+ res = has_return(s->op3.stval); /* elsestmts */
+ return res;
+ } else if (s->type == st_list) { /* sequential block */
+ return has_return(s->op1.lval->t->data);
+ }
+ return 0;
}
stmt *
@@ -366,6 +382,7 @@
{
list *l=0;
dnode *n;
+ int i;
if (THRhighwater())
return sql_error(sql, 10, "SELECT: too many nested operators");
@@ -376,6 +393,7 @@
for (n = blk->h; n; n = n->next ) {
stmt *res = NULL;
symbol *s = n->data.sym;
+
switch (s->token) {
case SQL_SET:
res = psm_set(sql, scp, s->data.lval->h);
@@ -435,6 +453,16 @@
}
list_append(l, res);
}
+ /* drop the declared tables of this frame */
+ if (l && l->t && !has_return(l->t->data)) {
+ i = sql->topvars;
+ while(sql->vars[--i].s) {
+ sql_var *v = &sql->vars[i];
+
+ if (v->type.comp_type && !v->view)
+ list_append(l, stmt_assign(v->name, NULL,
sql->frame));
+ }
+ }
stack_pop_frame(sql);
if (l)
return stmt_list(l);
@@ -477,22 +505,6 @@
return NULL;
}
-static int
-has_return(stmt *s )
-{
- if (s->type == st_return) {
- return 1;
- } else if (s->type == st_if) {
- int res = has_return(s->op2.stval); /* ifstmts */
- if (res && s->op3.stval)
- res = has_return(s->op3.stval); /* elsestmts */
- return res;
- } else if (s->type == st_list) { /* sequential block */
- return has_return(s->op1.lval->t->data);
- }
- return 0;
-}
-
list *
create_type_list(dlist *params, int param)
{
U sql_mvc.mx
Index: sql_mvc.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_mvc.mx,v
retrieving revision 1.201.2.1
retrieving revision 1.201.2.2
diff -u -d -r1.201.2.1 -r1.201.2.2
--- sql_mvc.mx 4 Jun 2008 20:19:15 -0000 1.201.2.1
+++ sql_mvc.mx 15 Jul 2008 14:20:49 -0000 1.201.2.2
@@ -215,6 +215,7 @@
/* find var in current frame */
extern int frame_find_var(mvc *sql, char *name);
extern int stack_find_frame(mvc *sql, char *name);
+extern int stack_nr_of_declared_tables(mvc *sql);
extern ValRecord * stack_get_var(mvc *sql, char *name);
extern void stack_set_var(mvc *sql, char *name, ValRecord *v);
@@ -756,6 +757,9 @@
if (!tr)
return NULL;
+ /* declared tables */
+ if (strcmp(sname, str_nil) == 0)
+ sname = dt_schema;
if (m->last && m->last->t->s &&
strcmp(m->last->t->s->base.name, sname) == 0)
s = m->last->t->s;
@@ -778,8 +782,8 @@
sql_subtype *tpe = stack_find_type(m, tname);
if (tpe) {
t = tpe->comp_type;
- } else { /* during exection they are in the '%dt%' schema */
- s = mvc_bind_schema(m, "%dt%");
+ } else { /* during exection they are in the declared table
schema */
+ s = mvc_bind_schema(m, dt_schema);
return mvc_bind_table(m, s, tname);
}
} else if (m->last && m->last->t->s == s &&
@@ -1522,6 +1526,22 @@
return 0;
}
+int
+stack_nr_of_declared_tables(mvc *sql)
+{
+ int i, dt = 0;
+
+ for (i = sql->topvars-1; i >= 0; i--) {
+ /* frame has no statement and only sometimes a name */
+ if (sql->vars[i].s && !sql->vars[i].view) {
+ sql_var *v = &sql->vars[i];
+ if (v->type.comp_type)
+ dt++;
+ }
+ }
+ return dt;
+}
+
void
stack_set_string(mvc *sql, char *name, char *val)
{
U sql_statement.mx
Index: sql_statement.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_statement.mx,v
retrieving revision 1.165.2.3
retrieving revision 1.165.2.4
diff -u -d -r1.165.2.3 -r1.165.2.4
--- sql_statement.mx 1 Jul 2008 10:23:01 -0000 1.165.2.3
+++ sql_statement.mx 15 Jul 2008 14:20:52 -0000 1.165.2.4
@@ -302,7 +302,7 @@
/* flow control statements */
extern stmt *stmt_while(stmt *cond, stmt *whilestmts );
extern stmt *stmt_if(stmt *cond, stmt *ifstmts, stmt *elsestmts);
-extern stmt *stmt_return(stmt *val);
+extern stmt *stmt_return(stmt *val, int nr_of_declared_tables);
extern stmt *stmt_assign(char *varname, stmt *val, int level);
extern sql_subtype *head_type(stmt *st);
@@ -2714,11 +2714,12 @@
return s;
}
-stmt *stmt_return(stmt *val)
+stmt *stmt_return(stmt *val, int nr_declared_tables)
{
stmt *s = stmt_create(st_return);
s->op1.stval = val;
+ s->flag = nr_declared_tables;
return s;
}
-------------------------------------------------------------------------
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