Changeset: 678a575cd10f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/678a575cd10f
Branch: smapi
Log Message:
Merge with default
diffs (truncated from 5947 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -794,7 +794,6 @@ void TABLETdestroy_format(Tablet *as);
int TABLEToutput_file(Tablet *as, BAT *order, stream *s);
int TRACEtable(Client cntxt, BAT **r);
int TYPE_xml;
-InstrPtr addArgument(MalBlkPtr mb, InstrPtr p, int varid);
void addMalException(MalBlkPtr mb, str msg);
str addOptimizerPipe(Client cntxt, MalBlkPtr mb, const char *name);
str addPipeDefinition(Client cntxt, const char *name, const char *pipe);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1095,6 +1095,9 @@ log_close_input(logger *lg)
static inline void
log_close_output(logger *lg)
{
+ if (lg->flushing_output_log)
+ return;
+
if (!LOG_DISABLED(lg))
close_stream(lg->output_log);
lg->output_log = NULL;
@@ -2806,10 +2809,21 @@ log_delta(logger *lg, BAT *uid, BAT *uva
#define LOG_LARGE (LL_CONSTANT(2)*1024*1024*1024)
static gdk_return
-new_logfile(logger *lg)
+new_logfile(logger *lg, stream* output_log, ulng id)
{
assert(!LOG_DISABLED(lg));
+ MT_lock_set(&lg->rotation_lock);
+ assert(lg->flushing_output_log);
+ lg->flushing_output_log = false;
+ if (lg->id != id) {
+ /* lg->output_log was rotated during the flush */
+ assert(lg->output_log != output_log && lg->id > id);
+ close_stream(output_log);
+ MT_lock_unset(&lg->rotation_lock);
+ return GDK_SUCCEED;
+ }
+ MT_lock_unset(&lg->rotation_lock);
const lng log_large = (GDKdebug & FORCEMITOMASK)?LOG_MINI:LOG_LARGE;
@@ -2928,7 +2942,12 @@ log_tflush(logger* lg, ulng log_file_id,
return GDK_SUCCEED;
}
- if (log_file_id == lg->id) {
+
+ ulng id;
+ MT_lock_set(&lg->rotation_lock);
+ id = lg->id;
+ MT_lock_unset(&lg->rotation_lock);
+ if (log_file_id == id) {
unsigned int number = request_number_flush_queue(lg);
MT_lock_set(&lg->flush_lock);
@@ -2938,10 +2957,16 @@ log_tflush(logger* lg, ulng log_file_id,
const int fqueue_length = flush_queue_length(lg);
/* flush + fsync */
MT_lock_set(&lg->rotation_lock);
- if (mnstr_flush(lg->output_log, MNSTR_FLUSH_DATA) ||
- (!(GDKdebug & NOSYNCMASK) &&
mnstr_fsync(lg->output_log)) ||
- new_logfile(lg) != GDK_SUCCEED) {
+ lg->flushing_output_log = true;
+ stream* output_log = lg->output_log;
+ id = lg->id;
+ MT_lock_unset(&lg->rotation_lock);
+ if (mnstr_flush(output_log, MNSTR_FLUSH_DATA) ||
+ (!(GDKdebug & NOSYNCMASK) &&
mnstr_fsync(output_log)) ||
+ new_logfile(lg, output_log, id) !=
GDK_SUCCEED) {
/* flush failed */
+ MT_lock_set(&lg->rotation_lock);
+ lg->flushing_output_log = false;
MT_lock_unset(&lg->rotation_lock);
MT_lock_unset(&lg->flush_lock);
(void) ATOMIC_DEC(&lg->refcount);
@@ -2949,7 +2974,6 @@ log_tflush(logger* lg, ulng log_file_id,
}
else {
/* flush succeeded */
- MT_lock_unset(&lg->rotation_lock);
left_truncate_flush_queue(lg, fqueue_length);
}
}
@@ -3132,7 +3156,7 @@ log_tstart(logger *lg, bool flushnow, ul
{
MT_lock_set(&lg->rotation_lock);
log_lock(lg);
- if (flushnow || (lg->request_rotation && ATOMIC_GET(&lg->refcount) ==
0)) {
+ if ((flushnow || (lg->request_rotation && ATOMIC_GET(&lg->refcount) ==
0)) && lg->end > 0) {
lg->id++;
log_close_output(lg);
/* start new file */
diff --git a/gdk/gdk_logger_internals.h b/gdk/gdk_logger_internals.h
--- a/gdk/gdk_logger_internals.h
+++ b/gdk/gdk_logger_internals.h
@@ -47,6 +47,7 @@ struct logger {
lng end; /* end of pre-allocated blocks for faster
f(data)sync */
ATOMIC_TYPE refcount; /* Number of active writers and flushers in the
logger */ // TODO check refcount in c->log and c->end
+ bool flushing_output_log; /* prevent output_log that is currently being
flushed from being closed */
MT_Lock rotation_lock;
MT_Lock lock;
/* Store log_bids (int) to circumvent trouble with reference counting */
diff --git a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
--- a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
+++ b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
@@ -182,19 +182,27 @@ OPTsql_appendImplementation(Client cntxt
/* it will be added to the block and
even my
* re-use MAL instructions */
q1 =
newInstruction(mb,aggrRef,countRef);
- getArg(q1,0) = newTmpVariable(mb,
TYPE_lng);
- q1 = pushArgument(mb, q1, getArg(p, 5));
- pushInstruction(mb, q1);
+ if (q1) {
+ getArg(q1,0) =
newTmpVariable(mb, TYPE_lng);
+ q1 = pushArgument(mb, q1,
getArg(p, 5));
+ }
}
/* push new v2 := algebra.slice( v0, 0, v1 ); */
/* use mal_builder.h primitives
* q1 = newStmt(mb, algebraRef,sliceRef); */
q2 = newInstruction(mb,algebraRef, sliceRef);
+ if (q1 == NULL || q2 == NULL) {
+ freeInstruction(q1);
+ freeInstruction(q2);
+ i--;
+ break;
+ }
getArg(q2,0) = newTmpVariable(mb, TYPE_any);
q2 = pushArgument(mb, q2, getArg(p, 5));
q2 = pushLng(mb, q2, 0);
q2 = pushArgument(mb, q2, getArg(q1, 0));
+ pushInstruction(mb, q1);
pushInstruction(mb, q2);
/* push modified v3 := sql.append( ..., ...,
..., ..., v2 ); */
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -36,9 +36,10 @@ newAssignmentArgs(MalBlkPtr mb, int args
str msg = createException(MAL, "newAssignment", "Can not
allocate variable");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
} else
getArg(q,0) = k;
- pushInstruction(mb, q);
return q;
}
@@ -69,8 +70,9 @@ newStmtArgs(MalBlkPtr mb, const char *mo
str msg = createException(MAL, "newStmtArgs", "Can not allocate
variable");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
}
- pushInstruction(mb, q);
return q;
}
@@ -87,10 +89,11 @@ newReturnStmt(MalBlkPtr mb)
str msg = createException(MAL, "newReturnStmt", "Can not
allocate return variable");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
} else
getArg(q,0) = k;
q->barrier= RETURNsymbol;
- pushInstruction(mb, q);
return q;
}
@@ -100,10 +103,12 @@ newFcnCallArgs(MalBlkPtr mb, const char
InstrPtr q = newAssignmentArgs(mb, args);
const char *fcnName, *modName;
- modName = putName(mod);
- fcnName = putName(fcn);
- setModuleId(q, modName);
- setFunctionId(q, fcnName);
+ if (q != NULL) {
+ modName = putName(mod);
+ fcnName = putName(fcn);
+ setModuleId(q, modName);
+ setFunctionId(q, fcnName);
+ }
return q;
}
@@ -128,15 +133,18 @@ newComment(MalBlkPtr mb, const char *val
str msg = createException(MAL, "newComment", "Can not allocate
comment");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
} else {
k = defConstant(mb, TYPE_str, &cst);
- if( k >= 0){
- getArg(q,0) = k;
- clrVarConstant(mb,getArg(q,0));
- setVarDisabled(mb,getArg(q,0));
+ if (k < 0) {
+ GDKfree(q);
+ return NULL;
}
+ getArg(q,0) = k;
+ clrVarConstant(mb,getArg(q,0));
+ setVarDisabled(mb,getArg(q,0));
}
- pushInstruction(mb, q);
return q;
}
@@ -156,6 +164,8 @@ newCatchStmt(MalBlkPtr mb, const char *n
str msg = createException(MAL, "newCatchStmt", "Can not
allocate variable");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
}else{
getArg(q,0) = k;
}
@@ -179,6 +189,8 @@ newRaiseStmt(MalBlkPtr mb, const char *n
str msg = createException(MAL, "newRaiseStmt", "Can not
allocate variable");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
} else
getArg(q,0) = k;
} else
@@ -202,6 +214,8 @@ newExitStmt(MalBlkPtr mb, const char *nm
str msg = createException(MAL, "newExitStmt", "Can not
allocate variable");
addMalException(mb, msg);
freeException(msg);
+ GDKfree(q);
+ return NULL;
}else
getArg(q,0) = k;
} else
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -558,8 +558,6 @@ setVariableScope(MalBlkPtr mb)
for (pc = 0; pc < mb->stop; pc++) {
p = getInstrPtr(mb, pc);
- if( p->token == NOOPsymbol)
- continue;
if( blockStart(p)){
if (getModuleId(p) && getFunctionId(p) &&
strcmp(getModuleId(p),"language")==0 && strcmp(getFunctionId(p),"dataflow")==0){
@@ -718,7 +716,7 @@ chkDeclarations(MalBlkPtr mb){
for(pc=1;pc<mb->stop; pc++){
p= getInstrPtr(mb,pc);
- if ( p->token == REMsymbol || p->token == NOOPsymbol)
+ if ( p->token == REMsymbol)
continue;
/* check correct use of the arguments*/
for(k=p->retc;k<p->argc; k++) {
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -105,7 +105,7 @@ malLoadScript(str name, bstream **fdin)
*fdin = bstream_create(fd, sz == 0 ? (size_t) (2 * 128 * BLOCK) : sz);
if(*fdin == NULL) {
close_stream(fd);
- throw(MAL, "malInclude", MAL_MALLOC_FAIL);
+ throw(MAL, "malInclude", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
if (bstream_next(*fdin) < 0) {
bstream_destroy(*fdin);
@@ -175,10 +175,10 @@ malIncludeString(Client c, const char *n
stream* mal_stream;
if ((mal_buf = GDKmalloc(sizeof(buffer))) == NULL)
- throw(MAL, "malIncludeString", MAL_MALLOC_FAIL);
+ throw(MAL, "malIncludeString", SQLSTATE(HY013) MAL_MALLOC_FAIL);
if ((mal_stream = buffer_rastream(mal_buf, name)) == NULL) {
GDKfree(mal_buf);
- throw(MAL, "malIncludeString", MAL_MALLOC_FAIL);
+ throw(MAL, "malIncludeString", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
buffer_init(mal_buf, mal, mal_len);
c->srcFile = name;
@@ -187,7 +187,7 @@ malIncludeString(Client c, const char *n
if ((c->fdin = bstream_create(mal_stream, mal_len)) == NULL) {
mnstr_destroy(mal_stream);
GDKfree(mal_buf);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]