Changeset: d9db2840e7f0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d9db2840e7f0
Modified Files:
sql/backends/monet5/sql_cat.c
sql/server/rel_psm.c
sql/server/rel_schema.c
sql/test/Tests/ifexists-views.sql
testing/Mtest.py.in
Branch: default
Log Message:
Merged with linear-hashing
diffs (153 lines):
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -719,9 +719,9 @@ drop_func(mvc *sql, char *sname, char *n
if (mvc_drop_func(sql, s, func, action))
throw(SQL,"sql.drop_func", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
}
- } else if (fid == -2) { //if exists option
+ } else if (fid == -2) { /* if exists option */
return MAL_SUCCEED;
- } else { //fid == -1
+ } else { /* fid == -1 */
node *n = NULL;
list *list_func = schema_bind_func(sql, s, name, type);
int res;
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -1113,21 +1113,21 @@ rel_drop_func(mvc *sql, dlist *qname, dl
char *F = NULL, *fn = NULL;
FUNC_TYPE_STR(type)
- (void) fn;
- if (sname && !(s = mvc_bind_schema(sql, sname)))
+ if (sname && !(s = mvc_bind_schema(sql, sname)) && !if_exists)
return sql_error(sql, 02, SQLSTATE(3F000) "DROP %s: no such
schema '%s'", F, sname);
- func = resolve_func(sql, s, name, typelist, type, "DROP", if_exists);
+ if (s)
+ func = resolve_func(sql, s, name, typelist, type, "DROP",
if_exists);
if (!func && !sname) {
s = tmp_schema(sql);
func = resolve_func(sql, s, name, typelist, type, "DROP",
if_exists);
}
- if (func)
+ if (func && s)
return rel_drop_function(sql->sa, s->base.name, name,
func->base.id, type, drop_action);
- else if (if_exists && !sql->session->status)
- return rel_drop_function(sql->sa, s->base.name, name, -2, type,
drop_action);
- return NULL;
+ if (if_exists)
+ return rel_drop_function(sql->sa, sname, name, -2, type,
drop_action);
+ return sql_error(sql, 02, SQLSTATE(42000) "DROP %s: %s %s not found",
F, fn, name);
}
static sql_rel*
@@ -1346,8 +1346,11 @@ drop_trigger(mvc *sql, dlist *qname, int
const char *tname = qname_table(qname);
sql_schema *ss = cur_schema(sql);
- if (sname && !(ss = mvc_bind_schema(sql, sname)))
+ if (sname && !(ss = mvc_bind_schema(sql, sname))) {
+ if (if_exists)
+ return rel_drop_trigger(sql, sname, tname, if_exists);
return sql_error(sql, 02, SQLSTATE(3F000) "DROP TRIGGER: no
such schema '%s'", sname);
+ }
if (!mvc_schema_privs(sql, ss))
return sql_error(sql, 02, SQLSTATE(3F000) "DROP TRIGGER: access
denied for %s to schema '%s'", stack_get_string(sql, "current_user"),
ss->base.name);
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
@@ -1057,12 +1057,10 @@ rel_create_table(sql_query *query, sql_s
sname = s->base.name;
if (mvc_bind_table(sql, s, name)) {
- if (if_not_exists) {
+ char *cd = (temp == SQL_DECLARED_TABLE)?"DECLARE":"CREATE";
+ if (if_not_exists)
return rel_psm_block(sql->sa, new_exp_list(sql->sa));
- } else {
- char *cd = (temp ==
SQL_DECLARED_TABLE)?"DECLARE":"CREATE";
- return sql_error(sql, 02, SQLSTATE(42S01) "%s TABLE:
name '%s' already in use", cd, name);
- }
+ return sql_error(sql, 02, SQLSTATE(42S01) "%s TABLE: name '%s'
already in use", cd, name);
} else if (temp != SQL_DECLARED_TABLE && (!mvc_schema_privs(sql, s) &&
!(isTempSchema(s) && temp == SQL_LOCAL_TEMP))){
return sql_error(sql, 02, SQLSTATE(42000) "CREATE TABLE:
insufficient privileges for user '%s' in schema '%s'", stack_get_string(sql,
"current_user"), s->base.name);
} else if (table_elements_or_subquery->token == SQL_CREATE_TABLE) {
@@ -1379,24 +1377,17 @@ rel_create_schema(sql_query *query, dlis
char *auth = schema_auth(auth_name);
sqlid auth_id = sql->role_id;
- if (auth && (auth_id = sql_find_auth(sql, auth)) < 0) {
- sql_error(sql, 02, SQLSTATE(28000) "CREATE SCHEMA: no such
authorization '%s'", auth);
- return NULL;
- }
- if (sql->user_id != USER_MONETDB && sql->role_id != ROLE_SYSADMIN) {
- sql_error(sql, 02, SQLSTATE(42000) "CREATE SCHEMA: insufficient
privileges for user '%s'", stack_get_string(sql, "current_user"));
- return NULL;
- }
+ if (auth && (auth_id = sql_find_auth(sql, auth)) < 0)
+ return sql_error(sql, 02, SQLSTATE(28000) "CREATE SCHEMA: no
such authorization '%s'", auth);
+ if (sql->user_id != USER_MONETDB && sql->role_id != ROLE_SYSADMIN)
+ return sql_error(sql, 02, SQLSTATE(42000) "CREATE SCHEMA:
insufficient privileges for user '%s'", stack_get_string(sql, "current_user"));
if (!name)
name = auth;
assert(name);
if (mvc_bind_schema(sql, name)) {
- if (!if_not_exists) {
- sql_error(sql, 02, SQLSTATE(3F000) "CREATE SCHEMA: name
'%s' already in use", name);
- return NULL;
- } else {
- return rel_psm_block(sql->sa, new_exp_list(sql->sa));
- }
+ if (!if_not_exists)
+ return sql_error(sql, 02, SQLSTATE(3F000) "CREATE
SCHEMA: name '%s' already in use", name);
+ return rel_psm_block(sql->sa, new_exp_list(sql->sa));
} else {
sql_schema *os = sql->session->schema;
dnode *n;
@@ -1456,7 +1447,7 @@ sql_alter_table(sql_query *query, dlist
if ((t = mvc_bind_table(sql, s, tname)) == NULL) {
if (mvc_bind_table(sql, mvc_bind_schema(sql, "tmp"), tname) !=
NULL)
return sql_error(sql, 02, SQLSTATE(42S02) "ALTER TABLE:
not supported on TEMPORARY table '%s'", tname);
- if(if_exists)
+ if (if_exists)
return rel_psm_block(sql->sa, new_exp_list(sql->sa));
return sql_error(sql, 02, SQLSTATE(42S02) "ALTER TABLE: no such
table '%s' in schema '%s'", tname, s->base.name);
} else {
diff --git a/sql/test/Tests/ifexists-views.sql
b/sql/test/Tests/ifexists-views.sql
--- a/sql/test/Tests/ifexists-views.sql
+++ b/sql/test/Tests/ifexists-views.sql
@@ -14,4 +14,9 @@ DROP VIEW IF EXISTS view2;
DROP VIEW view2; -- should fail
SELECT * FROM view2; -- should fail
+DROP FUNCTION IF EXISTS "idontexist"."idontexist"();
+DROP FUNCTION IF EXISTS "idontexist"."idontexist"(INT);
+DROP FUNCTION IF EXISTS "sys"."idontexist"();
+DROP FUNCTION IF EXISTS "sys"."idontexist"(INT);
+
DROP TABLE tab0;
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2855,12 +2855,15 @@ class ServerClass:
return self.proc.poll()
def terminate(self):
+ self.timer.cancel()
+ t = Timer(60, killProc, args = [self.proc, self.errfile, self.cmd])
+ t.start()
if os.name == 'nt':
self.proc.send_signal(signal.CTRL_BREAK_EVENT)
else:
self.proc.terminate()
self.proc.wait()
- self.timer.cancel()
+ t.cancel()
self.code = returnCode(self.proc, self.errfile)
def LaunchIt(self):
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list