Changeset: 7fc25925b391 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7fc25925b391
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
monetdb5/optimizer/optimizer.c
Branch: simplify_scenario
Log Message:
merged with default
diffs (truncated from 340 to 300 lines):
diff --git a/clients/Tests/MAL-signatures-hge.test
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -49699,21 +49699,21 @@ unsafe pattern sql.setVariable(X_0:int,
setVariable;
Set the value of a session variable
sql
-sql
set_count_distinct
-unsafe pattern sql.set_count_distinct(X_0:str, X_1:str, X_2:str, X_3:lng):void
+unsafe pattern sql.set_count_distinct(X_0:str, X_1:str, X_2:str, X_3:lng):void
sql_set_count_distinct;
Set count distinct for column
sql
set_max
-unsafe pattern sql.set_max(X_0:str, X_1:str, X_2:str, X_3:any_1):void
+unsafe pattern sql.set_max(X_0:str, X_1:str, X_2:str, X_3:any_1):void
sql_set_max;
Set max for column
sql
set_min
-unsafe pattern sql.set_min(X_0:str, X_1:str, X_2:str, X_3:any_1):void
+unsafe pattern sql.set_min(X_0:str, X_1:str, X_2:str, X_3:any_1):void
sql_set_min;
Set min for column
+sql
set_protocol
unsafe pattern sql.set_protocol(X_0:int):int
SQLset_protocol;
diff --git a/clients/Tests/MAL-signatures.test
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -38080,17 +38080,17 @@ setVariable;
Set the value of a session variable
sql
set_count_distinct
-unsafe pattern sql.set_count_distinct(X_0:str, X_1:str, X_2:str, X_3:lng):void
+unsafe pattern sql.set_count_distinct(X_0:str, X_1:str, X_2:str, X_3:lng):void
sql_set_count_distinct;
Set count distinct for column
sql
set_max
-unsafe pattern sql.set_max(X_0:str, X_1:str, X_2:str, X_3:any_1):void
+unsafe pattern sql.set_max(X_0:str, X_1:str, X_2:str, X_3:any_1):void
sql_set_max;
Set max for column
sql
set_min
-unsafe pattern sql.set_min(X_0:str, X_1:str, X_2:str, X_3:any_1):void
+unsafe pattern sql.set_min(X_0:str, X_1:str, X_2:str, X_3:any_1):void
sql_set_min;
Set min for column
sql
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -303,126 +303,6 @@ static struct PIPELINES {
static MT_Lock pipeLock = MT_LOCK_INITIALIZER(pipeLock);
-/* the session_pipe is the one defined by the user */
-str
-addPipeDefinition(Client cntxt, const char *name, const char *pipe)
-{
- int i;
- str msg;
- struct PIPELINES oldpipe;
-
- MT_lock_set(&pipeLock);
- for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++)
- if (strcmp(name, pipes[i].name) == 0)
- break;
-
- if (i == MAXOPTPIPES) {
- MT_lock_unset(&pipeLock);
- throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013) "Out
of slots");
- }
- if (pipes[i].name && pipes[i].builtin) {
- MT_lock_unset(&pipeLock);
- throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(42000) "No
overwrite of built in allowed");
- }
-
- /* save old value */
- oldpipe = pipes[i];
- pipes[i].name = GDKstrdup(name);
- pipes[i].def = GDKstrdup(pipe);
- pipes[i].status = GDKstrdup("experimental");
- if(pipes[i].name == NULL || pipes[i].def == NULL || pipes[i].status ==
NULL) {
- GDKfree(pipes[i].name);
- GDKfree(pipes[i].def);
- GDKfree(pipes[i].status);
- pipes[i].name = oldpipe.name;
- pipes[i].def = oldpipe.def;
- pipes[i].status = oldpipe.status;
- MT_lock_unset(&pipeLock);
- throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- }
- pipes[i].mb = NULL;
- MT_lock_unset(&pipeLock);
- msg = compileOptimizer(cntxt, name);
- if (msg) {
- /* failed: restore old value */
- MT_lock_set(&pipeLock);
- GDKfree(pipes[i].name);
- GDKfree(pipes[i].def);
- GDKfree(pipes[i].status);
- pipes[i] = oldpipe;
- MT_lock_unset(&pipeLock);
- } else {
- /* succeeded: destroy old value */
- if (oldpipe.name)
- GDKfree(oldpipe.name);
- if (oldpipe.def)
- GDKfree(oldpipe.def);
- if (oldpipe.mb)
- freeMalBlk(oldpipe.mb);
- if (oldpipe.status)
- GDKfree(oldpipe.status);
- }
- return msg;
-}
-
-int
-isOptimizerPipe(const char *name)
-{
- int i;
-
- for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++)
- if (strcmp(name, pipes[i].name) == 0)
- return TRUE;
- return FALSE;
-}
-
-str
-getPipeDefinition(str name)
-{
- int i;
-
- for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++)
- if (strcmp(name, pipes[i].name) == 0)
- return GDKstrdup(pipes[i].def);
- return NULL;
-}
-
-str
-getPipeCatalog(bat *nme, bat *def, bat *stat)
-{
- BAT *b, *bn, *bs;
- int i;
-
- b = COLnew(0, TYPE_str, 20, TRANSIENT);
- bn = COLnew(0, TYPE_str, 20, TRANSIENT);
- bs = COLnew(0, TYPE_str, 20, TRANSIENT);
- if (b == NULL || bn == NULL || bs == NULL) {
- BBPreclaim(b);
- BBPreclaim(bn);
- BBPreclaim(bs);
- throw(MAL, "optimizer.getpipeDefinition", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- }
-
- for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) {
- if (BUNappend(b, pipes[i].name, false) != GDK_SUCCEED ||
- BUNappend(bn, pipes[i].def, false) != GDK_SUCCEED ||
- BUNappend(bs, pipes[i].status, false) != GDK_SUCCEED) {
- BBPreclaim(b);
- BBPreclaim(bn);
- BBPreclaim(bs);
- throw(MAL, "optimizer.getpipeDefinition",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
- }
- }
-
- *nme = b->batCacheid;
- BBPkeepref(b);
- *def = bn->batCacheid;
- BBPkeepref(bn);
- *stat = bs->batCacheid;
- BBPkeepref(bs);
- return MAL_SUCCEED;
-}
-
static str
validatePipe(MalBlkPtr mb)
{
@@ -500,7 +380,7 @@ validateOptimizerPipes(void)
* Compile (the first time) an optimizer pipe string
* then copy the statements to the end of the MAL plan
*/
-str
+static str
compileOptimizer(Client cntxt, const char *name)
{
int i, j;
@@ -531,18 +411,115 @@ compileOptimizer(Client cntxt, const cha
return msg;
}
+/* the session_pipe is the one defined by the user */
str
-compileAllOptimizers(Client cntxt)
+addPipeDefinition(Client cntxt, const char *name, const char *pipe)
{
int i;
- str msg = MAL_SUCCEED;
+ str msg;
+ struct PIPELINES oldpipe;
+
+ MT_lock_set(&pipeLock);
+ for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++)
+ if (strcmp(name, pipes[i].name) == 0)
+ break;
+
+ if (i == MAXOPTPIPES) {
+ MT_lock_unset(&pipeLock);
+ throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013) "Out
of slots");
+ }
+ if (pipes[i].name && pipes[i].builtin) {
+ MT_lock_unset(&pipeLock);
+ throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(42000) "No
overwrite of built in allowed");
+ }
- for(i=0;pipes[i].def && msg == MAL_SUCCEED; i++){
- msg =compileOptimizer(cntxt,pipes[i].name);
+ /* save old value */
+ oldpipe = pipes[i];
+ pipes[i].name = GDKstrdup(name);
+ pipes[i].def = GDKstrdup(pipe);
+ pipes[i].status = GDKstrdup("experimental");
+ if(pipes[i].name == NULL || pipes[i].def == NULL || pipes[i].status ==
NULL) {
+ GDKfree(pipes[i].name);
+ GDKfree(pipes[i].def);
+ GDKfree(pipes[i].status);
+ pipes[i].name = oldpipe.name;
+ pipes[i].def = oldpipe.def;
+ pipes[i].status = oldpipe.status;
+ MT_lock_unset(&pipeLock);
+ throw(MAL, "optimizer.addPipeDefinition", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ }
+ pipes[i].mb = NULL;
+ MT_lock_unset(&pipeLock);
+ msg = compileOptimizer(cntxt, name);
+ if (msg) {
+ /* failed: restore old value */
+ MT_lock_set(&pipeLock);
+ GDKfree(pipes[i].name);
+ GDKfree(pipes[i].def);
+ GDKfree(pipes[i].status);
+ pipes[i] = oldpipe;
+ MT_lock_unset(&pipeLock);
+ } else {
+ /* succeeded: destroy old value */
+ if (oldpipe.name)
+ GDKfree(oldpipe.name);
+ if (oldpipe.def)
+ GDKfree(oldpipe.def);
+ if (oldpipe.mb)
+ freeMalBlk(oldpipe.mb);
+ if (oldpipe.status)
+ GDKfree(oldpipe.status);
}
return msg;
}
+int
+isOptimizerPipe(const char *name)
+{
+ int i;
+
+ for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++)
+ if (strcmp(name, pipes[i].name) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+str
+getPipeCatalog(bat *nme, bat *def, bat *stat)
+{
+ BAT *b, *bn, *bs;
+ int i;
+
+ b = COLnew(0, TYPE_str, 20, TRANSIENT);
+ bn = COLnew(0, TYPE_str, 20, TRANSIENT);
+ bs = COLnew(0, TYPE_str, 20, TRANSIENT);
+ if (b == NULL || bn == NULL || bs == NULL) {
+ BBPreclaim(b);
+ BBPreclaim(bn);
+ BBPreclaim(bs);
+ throw(MAL, "optimizer.getpipeDefinition", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ }
+
+ for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) {
+ if (BUNappend(b, pipes[i].name, false) != GDK_SUCCEED ||
+ BUNappend(bn, pipes[i].def, false) != GDK_SUCCEED ||
+ BUNappend(bs, pipes[i].status, false) != GDK_SUCCEED) {
+ BBPreclaim(b);
+ BBPreclaim(bn);
+ BBPreclaim(bs);
+ throw(MAL, "optimizer.getpipeDefinition",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ }
+ }
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]