Changeset: 541220c5cdec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=541220c5cdec
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_gencode.c
sql/server/rel_dump.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/sql_privileges.c
sql/server/sql_semantic.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
Branch: default
Log Message:
Merged with linear-hashing
diffs (truncated from 630 to 300 lines):
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
@@ -193,7 +193,7 @@ static int
char buf[64];
if (e->type == e_atom)
- snprintf(buf,64,"A%d",e->flag);
+ snprintf(buf,64,"A%u",e->flag);
else
snprintf(buf,64,"A%s",exp_name(e));
varid = newVariable(curBlk, (char *)buf, strlen(buf),
type);
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -156,7 +156,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
list *l = e->f;
exps_print(sql, fout, l, depth, refs, 0, 0);
} else { /* numbered arguments */
- mnstr_printf(fout, "A%d", e->flag);
+ mnstr_printf(fout, "A%u", e->flag);
}
}
} break;
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
@@ -358,9 +358,12 @@ column_constraint_type(mvc *sql, const c
}
*/
- if (rsname)
- rs = mvc_bind_schema(sql, rsname);
- else
+ if (rsname) {
+ if (!(rs = mvc_bind_schema(sql, rsname))) {
+ (void) sql_error(sql, 02, SQLSTATE(3F000)
"CONSTRAINT FOREIGN KEY: no such schema '%s'", rsname);
+ return res;
+ }
+ } else
rs = cur_schema(sql);
rt = _bind_table(t, ss, rs, rtname);
if (!rt) {
@@ -532,9 +535,13 @@ table_foreign_key(mvc *sql, char *name,
sql_schema *fs;
sql_table *ft;
- if (rsname)
- fs = mvc_bind_schema(sql, rsname);
- else
+
+ if (rsname) {
+ if (!(fs = mvc_bind_schema(sql, rsname))) {
+ (void) sql_error(sql, 02, SQLSTATE(3F000) "CONSTRAINT
FOREIGN KEY: no such schema '%s'", rsname);
+ return SQL_ERR;
+ }
+ } else
fs = ss;
ft = mvc_bind_table(sql, fs, rtname);
/* self referenced table */
@@ -1151,7 +1158,7 @@ rel_create_view(sql_query *query, sql_sc
mvc *sql = query->sql;
char *name = qname_table(qname);
char *sname = qname_schema(qname);
- sql_schema *s = NULL;
+ sql_schema *s = cur_schema(sql);
sql_table *t = NULL;
int instantiate = (sql->emode == m_instantiate || !persistent);
int deps = (sql->emode == m_deps);
@@ -1162,12 +1169,9 @@ rel_create_view(sql_query *query, sql_sc
(void) check; /* Stefan: unused!? */
if (sname && !(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, 02, SQLSTATE(3F000) "CREATE VIEW: no such
schema '%s'", sname);
- if (s == NULL)
- s = cur_schema(sql);
- if (create && (!mvc_schema_privs(sql, s) && !(isTempSchema(s) &&
persistent == SQL_LOCAL_TEMP))) {
+ if (create && (!mvc_schema_privs(sql, s) && !(isTempSchema(s) &&
persistent == SQL_LOCAL_TEMP)))
return sql_error(sql, 02, SQLSTATE(42000) "%s VIEW: access
denied for %s to schema '%s'", base, stack_get_string(sql, "current_user"),
s->base.name);
- }
if (create && (t = mvc_bind_table(sql, s, name)) != NULL) {
if (replace) {
@@ -1288,12 +1292,10 @@ rel_drop_type(mvc *sql, dlist *qname, in
{
char *name = qname_table(qname);
char *sname = qname_schema(qname);
- sql_schema *s = NULL;
+ sql_schema *s = cur_schema(sql);
if (sname && !(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, 02, SQLSTATE(3F000) "DROP TYPE: no such
schema '%s'", sname);
- if (s == NULL)
- s = cur_schema(sql);
if (schema_bind_type(sql, s, name) == NULL) {
return sql_error(sql, 02, SQLSTATE(42S01) "DROP TYPE: type '%s'
does not exist", name);
@@ -1308,12 +1310,10 @@ rel_create_type(mvc *sql, dlist *qname,
{
char *name = qname_table(qname);
char *sname = qname_schema(qname);
- sql_schema *s = NULL;
+ sql_schema *s = cur_schema(sql);
if (sname && !(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, 02, SQLSTATE(3F000) "CREATE TYPE: no such
schema '%s'", sname);
- if (s == NULL)
- s = cur_schema(sql);
if (schema_bind_type(sql, s, name) != NULL) {
return sql_error(sql, 02, SQLSTATE(42S01) "CREATE TYPE: name
'%s' already in use", name);
@@ -1452,16 +1452,14 @@ sql_alter_table(sql_query *query, dlist
mvc *sql = query->sql;
char *sname = qname_schema(qname);
char *tname = qname_table(qname);
- sql_schema *s = NULL;
+ sql_schema *s = cur_schema(sql);
sql_table *t = NULL;
- if (sname && !(s=mvc_bind_schema(sql, sname))) {
- if(if_exists)
+ if (sname && !(s = mvc_bind_schema(sql, sname))) {
+ if (if_exists)
return rel_psm_block(sql->sa, new_exp_list(sql->sa));
return sql_error(sql, 02, SQLSTATE(3F000) "ALTER TABLE: no such
schema '%s'", sname);
}
- if (!s)
- s = cur_schema(sql);
if ((t = mvc_bind_table(sql, s, tname)) == NULL) {
if (mvc_bind_table(sql, mvc_bind_schema(sql, "tmp"), tname) !=
NULL)
@@ -1853,9 +1851,10 @@ rel_grant_func(mvc *sql, sql_schema *cur
sql_schema *s = NULL;
sql_func *func = NULL;
- if (sname)
- s = mvc_bind_schema(sql, sname);
- else
+ if (sname) {
+ if (!(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "GRANT: no
such schema '%s'", sname);
+ } else
s = cur;
func = resolve_func(sql, s, fname, typelist, type, "GRANT", 0);
if (!func)
@@ -1905,9 +1904,9 @@ rel_grant_privs(mvc *sql, sql_schema *cu
char *tname = qname_table(qname);
sql_schema *s = cur;
- if (sname)
- s = mvc_bind_schema(sql, sname);
- if (s && mvc_bind_table(sql, s, tname) != NULL)
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "GRANT: no
such schema '%s'", sname);
+ if (s && mvc_bind_table(sql, s, tname))
token = SQL_TABLE;
}
@@ -2035,12 +2034,12 @@ rel_revoke_func(mvc *sql, sql_schema *cu
char *sname = qname_schema(qname);
char *fname = qname_func(qname);
sql_func *func = NULL;
-
sql_schema *s = NULL;
- if (sname)
- s = mvc_bind_schema(sql, sname);
- else
+ if (sname) {
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "REVOKE: no
such schema '%s'", sname);
+ } else
s = cur;
func = resolve_func(sql, s, fname, typelist, type, "REVOKE", 0);
if (!func)
@@ -2089,9 +2088,9 @@ rel_revoke_privs(mvc *sql, sql_schema *c
char *tname = qname_table(qname);
sql_schema *s = cur;
- if (sname)
- s = mvc_bind_schema(sql, sname);
- if (s && mvc_bind_table(sql, s, tname) != NULL)
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "GRANT: no
such schema '%s'", sname);
+ if (s && mvc_bind_table(sql, s, tname))
token = SQL_TABLE;
}
@@ -2119,7 +2118,7 @@ rel_revoke_privs(mvc *sql, sql_schema *c
static sql_rel *
rel_create_index(mvc *sql, char *iname, idx_type itype, dlist *qname, dlist
*column_list)
{
- sql_schema *s = NULL;
+ sql_schema *s = cur_schema(sql);
sql_table *t, *nt;
sql_rel *r, *res;
sql_exp **updates, *e;
@@ -2130,8 +2129,6 @@ rel_create_index(mvc *sql, char *iname,
if (sname && !(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, 02, SQLSTATE(3F000) "CREATE INDEX: no
such schema '%s'", sname);
- if (!s)
- s = cur_schema(sql);
i = mvc_bind_idx(sql, s, iname);
if (i)
return sql_error(sql, 02, SQLSTATE(42S11) "CREATE INDEX: name
'%s' already in use", iname);
@@ -2222,8 +2219,7 @@ current_or_designated_schema(mvc *sql, c
if (!name)
return cur_schema(sql);
- s = mvc_bind_schema(sql, name);
- if (!s) {
+ if (!(s = mvc_bind_schema(sql, name))) {
sql_error(sql, 02, SQLSTATE(3F000) "COMMENT ON:no such schema:
%s", name);
return NULL;
}
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
@@ -608,7 +608,10 @@ rel_named_table_function(sql_query *quer
char *fname = qname_fname(l->data.lval);
char *sname = qname_schema(l->data.lval);
node *en;
- sql_schema *s = sql->session->schema;
+ sql_schema *s = cur_schema(sql);
+
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: no such
schema '%s'", sname);
tl = sa_list(sql->sa);
exps = new_exp_list(sql->sa);
@@ -655,8 +658,6 @@ rel_named_table_function(sql_query *quer
}
}
- if (sname)
- s = mvc_bind_schema(sql, sname);
e = find_table_function(sql, s, fname, exps, tl);
if (!e)
return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such
operator '%s'", fname);
@@ -869,7 +870,7 @@ table_ref(sql_query *query, sql_rel *rel
dlist *name = tableref->data.lval->h->data.lval;
sql_rel *temp_table = NULL;
char *sname = qname_schema(name);
- sql_schema *s = NULL;
+ sql_schema *s = cur_schema(sql);
int allowed = 1;
tname = qname_table(name);
@@ -877,7 +878,7 @@ table_ref(sql_query *query, sql_rel *rel
if (dlist_length(name) > 2)
return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: only
a schema and table name expected");
- if (sname && !(s=mvc_bind_schema(sql,sname)))
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: no
such schema '%s'", sname);
if (!t && !sname) {
t = stack_find_table(sql, tname);
@@ -885,8 +886,6 @@ table_ref(sql_query *query, sql_rel *rel
temp_table = stack_find_rel_view(sql, tname);
}
if (!t && !temp_table) {
- if (!s)
- s = cur_schema(sql);
t = mvc_bind_table(sql, s, tname);
if (!t && !sname) {
s = tmp_schema(sql);
@@ -1507,7 +1506,7 @@ rel_filter(mvc *sql, sql_rel *rel, list
node *n;
sql_exp *L = l->h->data, *R = r->h->data, *e = NULL;
sql_subfunc *f = NULL;
- sql_schema *s = sql->session->schema;
+ sql_schema *s = cur_schema(sql);
list *tl, *exps;
exps = sa_list(sql->sa);
@@ -1524,8 +1523,8 @@ rel_filter(mvc *sql, sql_rel *rel, list
list_append(exps, e);
list_append(tl, exp_subtype(e));
}
- if (sname)
- s = mvc_bind_schema(sql, sname);
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: no such
schema '%s'", sname);
/* find filter function */
f = sql_bind_func_(sql->sa, s, filter_op, tl, F_FILT);
@@ -2124,11 +2123,11 @@ rel_logical_value_exp(sql_query *query,
char *fname = qname_fname(filter_op);
char *sname = qname_schema(filter_op);
list *exps, *tl;
- sql_schema *s = sql->session->schema;
+ sql_schema *s = cur_schema(sql);
sql_subtype *obj_type = NULL;
- if (sname)
- s = mvc_bind_schema(sql, sname);
+ if (sname && !(s = mvc_bind_schema(sql, sname)))
+ return sql_error(sql, 02, SQLSTATE(3F000) "SELECT: no
such schema '%s'", sname);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list