Changeset: 25524a69eb47 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/25524a69eb47
Modified Files:
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/sql_parser.y
sql/storage/store.c
Branch: default
Log Message:
initial support for local temp views.
diffs (125 lines):
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -1559,7 +1559,7 @@ rel_create_table(sql_query *query, int t
}
static sql_rel *
-rel_create_view(sql_query *query, dlist *qname, dlist *column_spec, symbol
*ast, int check, int persistent, int replace)
+rel_create_view(sql_query *query, int temp, dlist *qname, dlist *column_spec,
symbol *ast, int check, int persistent, int replace)
{
mvc *sql = query->sql;
const char *name = qname_schema_object(qname);
@@ -1571,10 +1571,19 @@ rel_create_view(sql_query *query, dlist
int create = (!instantiate && !deps);
sqlid pfoundid = 0, foundid = 0;
const char *base = replace ? "CREATE OR REPLACE VIEW" : "CREATE VIEW";
+ const char *action = (temp == SQL_DECLARED_TABLE)?"DECLARE":"CREATE";
(void) check; /* Stefan: unused!? */
- if (sname && !(s = mvc_bind_schema(sql, sname)))
+ if (temp == SQL_GLOBAL_TEMP)
+ temp = SQL_PERSIST; /* just normal view */
+
+ if (temp == SQL_LOCAL_TEMP || temp == SQL_GLOBAL_TEMP) {
+ if (sname && strcmp(sname, "tmp") != 0)
+ return sql_error(sql, 02, SQLSTATE(3F000) "%s VIEW: %s
temporary views should be stored in the 'tmp' schema",
+ action, (temp ==
SQL_LOCAL_TEMP) ? "local" : "global");
+ s = tmp_schema(sql);
+ } else if (sname && !(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, ERR_NOTFOUND, SQLSTATE(3F000) "%s: no
such schema '%s'", base, sname);
if (create && (!mvc_schema_privs(sql, s) && !(isTempSchema(s) &&
persistent == SQL_LOCAL_TEMP)))
return sql_error(sql, 02, SQLSTATE(42000) "%s: access denied
for %s to schema '%s'", base, get_string_global_var(sql, "current_user"),
s->base.name);
@@ -1641,7 +1650,7 @@ rel_create_view(sql_query *query, dlist
rel_destroy(sq);
return NULL;
}
- return rel_create_view_ddl(sql, ddl_create_view,
s->base.name, t, SQL_PERSIST, replace);
+ return rel_create_view_ddl(sql, ddl_create_view,
s->base.name, t, temp, replace);
}
if (!persistent && column_spec)
sq = view_rename_columns(sql, name, sq, column_spec);
@@ -2955,14 +2964,16 @@ rel_schemas(sql_query *query, symbol *s)
{
dlist *l = s->data.lval;
- assert(l->h->next->next->next->type == type_int);
+ assert(l->h->type == type_int);
assert(l->h->next->next->next->next->type == type_int);
- ret = rel_create_view(query, l->h->data.lval,
+ assert(l->h->next->next->next->next->next->type == type_int);
+ ret = rel_create_view(query, l->h->data.i_val,
l->h->next->data.lval,
-
l->h->next->next->data.sym,
-
l->h->next->next->next->data.i_val,
+
l->h->next->next->data.lval,
+
l->h->next->next->next->data.sym,
l->h->next->next->next->next->data.i_val,
-
l->h->next->next->next->next->next->data.i_val); /* or replace */
+
l->h->next->next->next->next->next->data.i_val,
+
l->h->next->next->next->next->next->next->data.i_val); /* or replace */
} break;
case SQL_DROP_TABLE:
{
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -271,7 +271,7 @@ rel_with_query(sql_query *query, symbol
/* first handle all with's (ie inlined views) */
for (d = d->data.lval->h; d; d = d->next) {
symbol *sym = d->data.sym;
- dnode *dn = sym->data.lval->h;
+ dnode *dn = sym->data.lval->h->next;
char *rname = qname_schema_object(dn->data.lval);
sql_rel *nrel;
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -1739,6 +1739,17 @@ table_def:
append_int(l, $3);
append_symbol(l, NULL); /* only used for merge table */
$$ = _symbol_create_list( SQL_CREATE_TABLE, l ); }
+ | opt_temp VIEW qname opt_column_list AS query_expression_def
opt_with_check_option
+ { dlist *l = L();
+ append_int(l, $1);
+ append_list(l, $3);
+ append_list(l, $4);
+ append_symbol(l, $6);
+ append_int(l, $7);
+ append_int(l, TRUE);
+ append_int(l, FALSE);
+ $$ = _symbol_create_list( SQL_CREATE_VIEW, l );
+ }
;
partition_type:
@@ -2192,6 +2203,7 @@ like_table:
view_def:
create_or_replace VIEW qname opt_column_list AS query_expression_def
opt_with_check_option
{ dlist *l = L();
+ append_int(l, SQL_PERSIST);
append_list(l, $3);
append_list(l, $4);
append_symbol(l, $6);
@@ -3414,6 +3426,7 @@ with_list:
with_list_element:
ident opt_column_list AS subquery_with_orderby
{ dlist *l = L();
+ append_int(l, 0);
append_list(l, append_string(L(), $1));
append_list(l, $2);
append_symbol(l, $4);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1624,7 +1624,7 @@ create_sql_table_with_id(allocator *sa,
assert((persistence==SQL_PERSIST ||
persistence==SQL_DECLARED_TABLE ||
- commit_action) && commit_action>=0);
+ commit_action || type) && commit_action>=0);
assert(id);
base_init(sa, &t->base, id, true, name);
t->type = type;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]