Changeset: 1926517e41cc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1926517e41cc
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_bat.c
gdk/gdk_heap.c
gdk/gdk_logger.c
geom/monetdb5/geom.c
geom/monetdb5/geom_upgrade.c
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_client.c
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_exception.c
monetdb5/mal/mal_import.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_listing.c
monetdb5/mal/mal_resolve.c
monetdb5/mal/mal_runtime.c
monetdb5/mal/mal_session.c
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/color.c
monetdb5/modules/atoms/identifier.c
monetdb5/modules/atoms/inet.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/streams.c
monetdb5/modules/atoms/url.c
monetdb5/modules/atoms/uuid.c
monetdb5/modules/atoms/xml.c
monetdb5/modules/mal/mal_io.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/tablet.h
monetdb5/modules/mal/txtsim.c
monetdb5/optimizer/opt_emptybind.c
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_macro.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_multiplex.c
monetdb5/optimizer/opt_support.c
monetdb5/scheduler/run_adder.c
sql/backends/monet5/UDF/pyapi/convert_loops.h
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_upgrades.c
sql/backends/monet5/sql_user.c
sql/backends/monet5/vaults/bam/bam_export.c
sql/backends/monet5/vaults/bam/bam_globals.h
sql/backends/monet5/vaults/bam/bam_wrapper.c
sql/common/sql_mem.c
tools/merovingian/daemon/controlrunner.c
tools/mserver/mserver5.c
Branch: malparsing
Log Message:
Merge with default branch.
diffs (truncated from 1954 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
@@ -1801,7 +1801,6 @@ str SYSmem_usage(bat *ret, bat *ret2, co
str SYSsetmem_maxsize(void *ret, const lng *num);
str SYSsetvm_maxsize(void *ret, const lng *num);
str SYSvm_usage(bat *ret, bat *ret2, const lng *minsize);
-void *TABLETadt_frStr(Column *c, int type, char *s, char *e, char quote);
int TABLETadt_toStr(void *extra, char **buf, int *len, int type, ptr a);
str TABLETcollect(BAT **bats, Tablet *as);
str TABLETcollect_parts(BAT **bats, Tablet *as, BUN offset);
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -289,7 +289,14 @@ BATattach(int tt, const char *heapfile,
while ((c = getc(f)) != EOF) {
if (n == m) {
m += 4096;
- p = GDKrealloc(p, m);
+ s = GDKrealloc(p, m);
+ if (s == NULL) {
+ GDKfree(p);
+ BBPreclaim(bn);
+ fclose(f);
+ return NULL;
+ }
+ p = s;
s = p + n;
}
if (c == '\n' && n > 0 && s[-1] == '\r') {
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -216,13 +216,13 @@ HEAPextend(Heap *h, size_t size, int may
/* try GDKrealloc if the heap size stays within
* reasonable limits */
if (!must_mmap) {
- void *p = h->base;
h->newstorage = h->storage = STORE_MEM;
h->base = GDKrealloc(h->base, size);
- HEAPDEBUG fprintf(stderr, "#HEAPextend: extending
malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->size,
PTRFMTCAST p, PTRFMTCAST h->base);
+ HEAPDEBUG fprintf(stderr, "#HEAPextend: extending
malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->size,
PTRFMTCAST bak.base, PTRFMTCAST h->base);
h->size = size;
if (h->base)
return GDK_SUCCEED; /* success */
+ /* bak.base is still valid and may get restored */
failure = "h->storage == STORE_MEM && !must_map &&
!h->base";
}
/* too big: convert it to a disk-based temporary heap */
@@ -631,7 +631,7 @@ HEAPload_intern(Heap *h, const char *nme
{
size_t minsize;
int ret = 0;
- char *srcpath, *dstpath;
+ char *srcpath, *dstpath, *tmp;
int t0;
h->storage = h->newstorage = h->size < 4 * GDK_mmap_pagesize ?
STORE_MEM : STORE_MMAP;
@@ -678,7 +678,14 @@ HEAPload_intern(Heap *h, const char *nme
* takes precedence. */
srcpath = GDKfilepath(h->farmid, BATDIR, nme, ext);
dstpath = GDKfilepath(h->farmid, BATDIR, nme, ext);
- srcpath = GDKrealloc(srcpath, strlen(srcpath) + strlen(suffix) + 1);
+ if (srcpath == NULL ||
+ dstpath == NULL ||
+ (tmp = GDKrealloc(srcpath, strlen(srcpath) + strlen(suffix) + 1))
== NULL) {
+ GDKfree(srcpath);
+ GDKfree(dstpath);
+ return GDK_FAIL;
+ }
+ srcpath = tmp;
strcat(srcpath, suffix);
t0 = GDKms();
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -1745,10 +1745,15 @@ dumpPointsPoint(BAT *idBAT, BAT *geomBAT
int lvlDigitsNum = 10; //MAX_UNIT = 4,294,967,295
str err = MAL_SUCCEED;
+ if (pointWKB == NULL)
+ throw(MAL, "geom.Dump", MAL_MALLOC_FAIL);
+
(*lvl)++;
newPath = GDKmalloc(pathLength + lvlDigitsNum + 1);
- if( newPath == NULL)
- throw(MAL, "geom.PointsPoint", MAL_MALLOC_FAIL);
+ if (newPath == NULL) {
+ GDKfree(pointWKB);
+ throw(MAL, "geom.Dump", MAL_MALLOC_FAIL);
+ }
sprintf(newPath, "%s%u", path, *lvl);
if (BUNappend(idBAT, newPath, TRUE) != GDK_SUCCEED ||
@@ -1776,7 +1781,7 @@ dumpPointsLineString(BAT *idBAT, BAT *ge
if (err != MAL_SUCCEED)
return err;
- for (i = 0; i < pointsNum; i++) {
+ for (i = 0; i < pointsNum && err == MAL_SUCCEED; i++) {
GEOSGeometry *pointGeometry = GEOSGeomGetPointN(geosGeometry,
i);
if (pointGeometry == NULL)
@@ -1803,13 +1808,13 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
//get the exterior ring of the polygon
exteriorRingGeometry = GEOSGetExteriorRing(geosGeometry);
- if (!exteriorRingGeometry)
+ if (exteriorRingGeometry == NULL)
throw(MAL, "geom.DumpPoints", "GEOSGetExteriorRing failed");
(*lvl)++;
newPath = GDKmalloc(pathLength + lvlDigitsNum + extraLength + 1);
- if( newPath == NULL)
- throw(MAL,"geom.dumpPointsPolygon",MAL_MALLOC_FAIL);
+ if (newPath == NULL)
+ throw(MAL, "geom.DumpPoints", MAL_MALLOC_FAIL);
sprintf(newPath, "%s%u%s", path, *lvl, extraStr);
//get the points in the exterior ring
@@ -1821,7 +1826,7 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
//check the interior rings
numInteriorRings = GEOSGetNumInteriorRings(geosGeometry);
if (numInteriorRings == -1)
- throw(MAL, "geom.NumPoints", "GEOSGetNumInteriorRings failed");
+ throw(MAL, "geom.DumpPoints", "GEOSGetNumInteriorRings failed");
// iterate over the interiorRing and transform each one of them
for (i = 0; i < numInteriorRings; i++) {
@@ -1829,6 +1834,8 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
lvlDigitsNum = 10; //MAX_UNIT = 4,294,967,295
newPath = GDKmalloc(pathLength + lvlDigitsNum + extraLength +
1);
+ if (newPath == NULL)
+ throw(MAL, "geom.DumpPoints", MAL_MALLOC_FAIL);
sprintf(newPath, "%s%u%s", path, *lvl, extraStr);
err = dumpPointsLineString(idBAT, geomBAT,
GEOSGetInteriorRingN(geosGeometry, i), newPath);
@@ -1862,8 +1869,8 @@ dumpPointsMultiGeometry(BAT *idBAT, BAT
lvl++;
newPath = GDKmalloc(pathLength + lvlDigitsNum + extraLength +
1);
- if( newPath == NULL)
- throw(MAL,"geom.dumpPointsGeometry",MAL_MALLOC_FAIL);
+ if (newPath == NULL)
+ throw(MAL, "geom.DumpPoints", MAL_MALLOC_FAIL);
sprintf(newPath, "%s%u%s", path, lvl, extraStr);
//*secondLevel = 0;
@@ -2171,8 +2178,8 @@ wkbFROMSTR_withSRID(char *geomWKT, int *
size_t sizeOfInfo = strlen(geomWKT) - strlen(polyhedralSurface);
geomWKT_original = geomWKT;
geomWKT = GDKmalloc(sizeOfInfo + strlen(multiPolygon) + 1);
- if( geomWKT == NULL)
- throw(MAL,"geomWKT",MAL_MALLOC_FAIL);
+ if (geomWKT == NULL)
+ throw(MAL, "wkb.FromText", MAL_MALLOC_FAIL);
strcpy(geomWKT, multiPolygon);
memcpy(geomWKT + strlen(multiPolygon),
&geomWKT_original[strlen(polyhedralSurface)], sizeOfInfo);
geomWKT[sizeOfInfo + strlen(multiPolygon)] = '\0';
@@ -2180,13 +2187,23 @@ wkbFROMSTR_withSRID(char *geomWKT, int *
////////////////////////// UP TO HERE ///////////////////////////
WKT_reader = GEOSWKTReader_create();
+ if (WKT_reader == NULL) {
+ if (geomWKT_original)
+ GDKfree(geomWKT);
+ throw(MAL, "wkb.FromText", "GEOSWKTReader_create failed");
+ }
geosGeometry = GEOSWKTReader_read(WKT_reader, geomWKT);
GEOSWKTReader_destroy(WKT_reader);
- if (geosGeometry == NULL)
+ if (geosGeometry == NULL) {
+ if (geomWKT_original)
+ GDKfree(geomWKT);
throw(MAL, "wkb.FromText", "GEOSWKTReader_read failed");
+ }
if (GEOSGeomTypeId(geosGeometry) == -1) {
+ if (geomWKT_original)
+ GDKfree(geomWKT);
GEOSGeom_destroy(geosGeometry);
throw(MAL, "wkb.FromText", "GEOSGeomTypeId failed");
}
@@ -2199,8 +2216,11 @@ wkbFROMSTR_withSRID(char *geomWKT, int *
* want to get the wkb out of it */
*geomWKB = geos2wkb(geosGeometry);
GEOSGeom_destroy(geosGeometry);
- if (*geomWKB == NULL)
+ if (*geomWKB == NULL) {
+ if (geomWKT_original)
+ GDKfree(geomWKT);
throw(MAL, "wkb.FromText", "geos2wkb failed");
+ }
*len = (int) wkb_size((*geomWKB)->len);
@@ -2227,10 +2247,8 @@ wkbaFROMSTR_withSRID(char *fromStr, int
memcpy(&items, fromStr, sizeof(int));
skipBytes += sizeof(int);
*toArray = GDKmalloc(wkba_size(items));
- if( *toArray == NULL){
- GDKerror("FROMSTR_withSRID" MAL_MALLOC_FAIL);
+ if (*toArray == NULL)
return 0;
- }
for (i = 0; i < items; i++) {
size_t parsedBytes;
@@ -4605,10 +4623,14 @@ wkbBox2D(mbr **box, wkb **point1, wkb **
} else {
//Assign the coordinates. Ensure that they are in correct order
*box = GDKmalloc(sizeof(mbr));
- (*box)->xmin = (float) (xmin < xmax ? xmin : xmax);
- (*box)->ymin = (float) (ymin < ymax ? ymin : ymax);
- (*box)->xmax = (float) (xmax > xmin ? xmax : xmin);
- (*box)->ymax = (float) (ymax > ymin ? ymax : ymin);
+ if (*box == NULL) {
+ err = createException(MAL, "geom.MakeBox2D",
MAL_MALLOC_FAIL);
+ } else {
+ (*box)->xmin = (float) (xmin < xmax ? xmin : xmax);
+ (*box)->ymin = (float) (ymin < ymax ? ymin : ymax);
+ (*box)->xmax = (float) (xmax > xmin ? xmax : xmin);
+ (*box)->ymax = (float) (ymax > ymin ? ymax : ymin);
+ }
}
GEOSGeom_destroy(point1_geom);
GEOSGeom_destroy(point2_geom);
@@ -5061,25 +5083,21 @@ wkbTOSTR(char **geomWKT, int *len, wkb *
}
if (wkt) {
- if (*len < (int) dstStrLen + 1) {
+ if (*len < (int) dstStrLen + 1 || *geomWKT == NULL) {
*len = (int) dstStrLen + 1;
GDKfree(*geomWKT);
- *geomWKT = GDKmalloc(*len);
- if( *geomWKT == NULL){
- GDKerror("wkbTOSTR" MAL_MALLOC_FAIL);
+ if ((*geomWKT = GDKmalloc(*len)) == NULL) {
+ GEOSFree(wkt);
return 0;
}
}
snprintf(*geomWKT, *len, "\"%s\"", wkt);
GEOSFree(wkt);
} else {
- if (*len < 4) {
+ if (*len < 4 || *geomWKT == NULL) {
GDKfree(*geomWKT);
- *geomWKT = GDKmalloc(*len = 4);
- if( *geomWKT == NULL){
- GDKerror("wkbTOSTR" MAL_MALLOC_FAIL);
+ if ((*geomWKT = GDKmalloc(*len = 4)) == NULL)
return 0;
- }
}
strcpy(*geomWKT, "nil");
}
@@ -5237,11 +5255,8 @@ mbrTOSTR(char **dst, int *len, mbr *atom
if (*len < (int) dstStrLen + 1 || *dst == NULL) {
GDKfree(*dst);
- *dst = GDKmalloc(*len = (int) dstStrLen + 1);
- if( *dst == NULL){
- GDKerror("mbrTOSTR" MAL_MALLOC_FAIL);
+ if ((*dst = GDKmalloc(*len = (int) dstStrLen + 1)) == NULL)
return 0;
- }
}
if (dstStrLen > 3)
@@ -5279,14 +5294,10 @@ mbrFROMSTR(char *src, int *len, mbr **at
} else if (!nil && (geosMbr = GEOSGeomFromWKT(src)) == NULL)
return 0;
- if (*len < (int) sizeof(mbr)) {
- if (*atom)
- GDKfree(*atom);
- *atom = GDKmalloc(*len = sizeof(mbr));
- if( *atom == NULL){
- GDKerror("mbrFROMSTR" MAL_MALLOC_FAIL);
+ if (*len < (int) sizeof(mbr) || *atom == NULL) {
+ GDKfree(*atom);
+ if ((*atom = GDKmalloc(*len = sizeof(mbr))) == NULL)
return 0;
- }
}
if (nil) {
nchars = 3;
@@ -5420,19 +5431,31 @@ wkbaTOSTR(char **toStr, int *len, wkba *
char *nilStr = "nil";
char *toStrPtr = NULL, *itemsNumStr = GDKmalloc((itemsNumDigits + 1) *
sizeof(char));
- if( itemsNumStr == NULL){
- GDKerror("wkbaTOSTR" MAL_MALLOC_FAIL);
+ if (itemsNumStr == NULL)
return 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list