Changeset: 74c0d0cf888f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=74c0d0cf888f
Modified Files:
monetdb5/mal/mal_client.c
sql/server/rel_schema.c
sql/test/BugTracker-2018/Tests/temp-table-performance.Bug-6577.sql
Branch: default
Log Message:
Test fixes and defensive lines for mal_client_reset
diffs (150 lines):
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -48,14 +48,16 @@
#include "mal_authorize.h"
int MAL_MAXCLIENTS = 0;
-ClientRec *mal_clients;
+ClientRec *mal_clients = NULL;
void
mal_client_reset(void)
{
MAL_MAXCLIENTS = 0;
- if (mal_clients)
+ if (mal_clients) {
GDKfree(mal_clients);
+ mal_clients = NULL;
+ }
}
bool
@@ -68,7 +70,7 @@ MCinit(void)
maxclients = atoi(max_clients);
if (maxclients <= 0) {
maxclients = 64;
- GDKsetenv("max_clients", "64") ;
+ GDKsetenv("max_clients", "64");
}
MAL_MAXCLIENTS = /* client connections */ maxclients;
@@ -172,11 +174,11 @@ MCgetClient(int id)
static void
MCresetProfiler(stream *fdout)
{
- if (fdout != maleventstream)
- return;
- MT_lock_set(&mal_profileLock);
- maleventstream = 0;
- MT_lock_unset(&mal_profileLock);
+ if (fdout != maleventstream)
+ return;
+ MT_lock_set(&mal_profileLock);
+ maleventstream = 0;
+ MT_lock_unset(&mal_profileLock);
}
void
@@ -185,14 +187,13 @@ MCexitClient(Client c)
finishSessionProfiler(c);
MCresetProfiler(c->fdout);
if (c->father == NULL) { /* normal client */
- if (c->fdout && c->fdout != GDKstdout) {
+ if (c->fdout && c->fdout != GDKstdout)
close_stream(c->fdout);
- }
assert(c->bak == NULL);
if (c->fdin) {
/* protection against closing stdin stream */
- if (c->fdin->s == GDKstdin)
- c->fdin->s = NULL;
+ if (c->fdin->s == GDKstdin)
+ c->fdin->s = NULL;
bstream_destroy(c->fdin);
}
c->fdout = NULL;
@@ -289,7 +290,6 @@ MCinitClient(oid user, bstream *fin, str
return MCinitClientRecord(c, user, fin, fout);
}
-
/*
* The administrator should be initialized to enable interpretation of
* the command line arguments, before it starts servicing statements
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
@@ -133,7 +133,7 @@ view_rename_columns( mvc *sql, char *nam
}
static int
-as_subquery(mvc *sql, sql_table *t, sql_rel *sq, dlist *column_spec, const
char *msg)
+as_subquery(mvc *sql, sql_table *t, table_types tt, sql_rel *sq, dlist
*column_spec, const char *msg)
{
sql_rel *r = sq;
@@ -152,7 +152,7 @@ as_subquery(mvc *sql, sql_table *t, sql_
sql_exp *e = m->data;
sql_subtype *tp = exp_subtype(e);
- if (!isView(t) && cname && cname[0] == '%') {
+ if (tt != tt_view && cname && cname[0] == '%') {
sql_error(sql, 01, SQLSTATE(42000) "%s:
generated labels not allowed in column names, use an alias instead", msg);
return -1;
} else if (mvc_bind_column(sql, t, cname)) {
@@ -173,12 +173,13 @@ as_subquery(mvc *sql, sql_table *t, sql_
const char *cname = exp_name(e);
sql_subtype *tp = exp_subtype(e);
- if (!cname) {
- cname = "v";
- } else if (!isView(t) && cname[0] == '%') {
+ if (tt != tt_view && cname && cname[0] == '%') {
sql_error(sql, 01, SQLSTATE(42000) "%s:
generated labels not allowed in column names, use an alias instead", msg);
return -1;
- } else if (mvc_bind_column(sql, t, cname)) {
+ }
+ if (!cname)
+ cname = "v";
+ if (mvc_bind_column(sql, t, cname)) {
sql_error(sql, 01, SQLSTATE(42S21) "%s:
duplicate column name %s", msg, cname);
return -1;
}
@@ -191,13 +192,13 @@ as_subquery(mvc *sql, sql_table *t, sql_
sql_table *
mvc_create_table_as_subquery( mvc *sql, sql_rel *sq, sql_schema *s, const char
*tname, dlist *column_spec, int temp, int commit_action )
{
- int tt =(temp == SQL_REMOTE)?tt_remote:
+ table_types tt =(temp == SQL_REMOTE)?tt_remote:
(temp == SQL_STREAM)?tt_stream:
(temp == SQL_MERGE_TABLE)?tt_merge_table:
(temp == SQL_REPLICA_TABLE)?tt_replica_table:tt_table;
sql_table *t = mvc_create_table(sql, s, tname, tt, 0,
SQL_DECLARED_TABLE, commit_action, -1, 0);
- if (as_subquery( sql, t, sq, column_spec, "CREATE TABLE") != 0)
+ if (as_subquery(sql, t, tt, sq, column_spec, "CREATE TABLE") != 0)
return NULL;
return t;
}
@@ -1223,7 +1224,7 @@ rel_create_view(sql_query *query, sql_sc
q = query_cleaned(q);
t = mvc_create_view(sql, s, name, SQL_DECLARED_TABLE,
q, 0);
GDKfree(q);
- if (as_subquery(sql, t, sq, column_spec, "CREATE VIEW")
!= 0) {
+ if (as_subquery(sql, t, tt_view, sq, column_spec,
"CREATE VIEW") != 0) {
rel_destroy(sq);
return NULL;
}
diff --git a/sql/test/BugTracker-2018/Tests/temp-table-performance.Bug-6577.sql
b/sql/test/BugTracker-2018/Tests/temp-table-performance.Bug-6577.sql
--- a/sql/test/BugTracker-2018/Tests/temp-table-performance.Bug-6577.sql
+++ b/sql/test/BugTracker-2018/Tests/temp-table-performance.Bug-6577.sql
@@ -11,7 +11,7 @@ create table t2 as (select distinct v1 f
select count(t1.v1) from t1, t2 where t1.v1=t2.v1;
-create temp table t3 as (select count(t1.v1) from t1, t2 where t1.v1=t2.v1) on
commit preserve rows;
+create temp table t3 as (select count(t1.v1) as "mylabel" from t1, t2 where
t1.v1=t2.v1) on commit preserve rows;
drop table t3;
create temp table t3 as (select t1.v1 from t1, t2 where t1.v1=t2.v1) on commit
preserve rows;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list