Changeset: 40a042bd8329 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/40a042bd8329
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_user.c
sql/storage/bat/bat_storage.c
Branch: iso
Log Message:
Merged with Jul2021
diffs (truncated from 2485 to 300 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -5753,6 +5753,7 @@ stdout of test 'MAL-signatures` in direc
[ "batcalc", "uuid", "command batcalc.uuid(X_0:bat[:str],
X_1:bat[:oid]):bat[:uuid] ", "UUIDstr2uuid_bulk;", "" ]
[ "batcalc", "uuid", "command batcalc.uuid(X_0:bat[:uuid],
X_1:bat[:oid]):bat[:uuid] ", "UUIDuuid2uuid_bulk;", "" ]
[ "batcalc", "wkb", "command batcalc.wkb(X_0:bat[:wkb], X_1:bat[:oid],
X_2:int, X_3:int):bat[:wkb] ", "geom_2_geom_bat;", "" ]
+[ "batcalc", "wkb", "command batcalc.wkb(X_0:bat[:str], X_1:bat[:oid],
X_2:int, X_3:int):bat[:wkb] ", "wkbFromText_bat_cand;", "" ]
[ "batcalc", "xml", "command batcalc.xml(X_0:bat[:str]):bat[:xml] ",
"BATXMLstr2xml;", "" ]
[ "batcalc", "xor", "pattern batcalc.xor(X_0:bat[:bit],
X_1:bat[:bit]):bat[:bit] ", "CMDbatXOR;", "" ]
[ "batcalc", "xor", "pattern batcalc.xor(X_0:bat[:bit], X_1:bat[:bit],
X_2:bat[:oid], X_3:bat[:oid]):bat[:bit] ", "CMDbatXOR;", "" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -8277,6 +8277,7 @@ stdout of test 'MAL-signatures` in direc
[ "batcalc", "uuid", "command batcalc.uuid(X_0:bat[:str],
X_1:bat[:oid]):bat[:uuid] ", "UUIDstr2uuid_bulk;", "" ]
[ "batcalc", "uuid", "command batcalc.uuid(X_0:bat[:uuid],
X_1:bat[:oid]):bat[:uuid] ", "UUIDuuid2uuid_bulk;", "" ]
[ "batcalc", "wkb", "command batcalc.wkb(X_0:bat[:wkb], X_1:bat[:oid],
X_2:int, X_3:int):bat[:wkb] ", "geom_2_geom_bat;", "" ]
+[ "batcalc", "wkb", "command batcalc.wkb(X_0:bat[:str], X_1:bat[:oid],
X_2:int, X_3:int):bat[:wkb] ", "wkbFromText_bat_cand;", "" ]
[ "batcalc", "xml", "command batcalc.xml(X_0:bat[:str]):bat[:xml] ",
"BATXMLstr2xml;", "" ]
[ "batcalc", "xor", "pattern batcalc.xor(X_0:bat[:bit],
X_1:bat[:bit]):bat[:bit] ", "CMDbatXOR;", "" ]
[ "batcalc", "xor", "pattern batcalc.xor(X_0:bat[:bit], X_1:bat[:bit],
X_2:bat[:oid], X_3:bat[:oid]):bat[:bit] ", "CMDbatXOR;", "" ]
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -331,6 +331,8 @@
#include <limits.h> /* for *_MIN and *_MAX */
#include <float.h> /* for FLT_MAX and DBL_MAX */
+typedef enum { GDK_FAIL, GDK_SUCCEED } gdk_return;
+
#include "gdk_system.h"
#include "gdk_posix.h"
#include "stream.h"
@@ -524,8 +526,6 @@ typedef size_t BUN;
/*
* @- Checking and Error definitions:
*/
-typedef enum { GDK_FAIL, GDK_SUCCEED } gdk_return;
-
#define ATOMextern(t) (ATOMstorage(t) >= TYPE_str)
typedef enum {
@@ -1592,6 +1592,8 @@ gdk_export BAT *BBPquickdesc(bat b, bool
#include "gdk_tracer.h"
+gdk_export gdk_return GDKtracer_fill_comp_info(BAT *id, BAT *component, BAT
*log_level);
+
#define GDKerror(format, ...) \
GDKtracer_log(__FILE__, __func__, __LINE__, M_ERROR, \
GDK, NULL, format, ##__VA_ARGS__)
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2335,7 +2335,7 @@ log_constant(logger *lg, int type, ptr v
static gdk_return
string_writer(logger *lg, BAT *b, lng offset, lng nr)
{
- int sz = 0;
+ size_t sz = 0;
BUN end = (BUN)(offset + nr);
BATiter bi = bat_iterator(b);
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -179,6 +179,7 @@ gdk_export int MT_join_thread(MT_Id t);
#define USE_NATIVE_LOCKS 1
#ifdef LOCK_STATS
+#include "gdk_tracer.h"
#define _DBG_LOCK_COUNT_0(l) \
do { \
diff --git a/gdk/gdk_tracer.h b/gdk/gdk_tracer.h
--- a/gdk/gdk_tracer.h
+++ b/gdk/gdk_tracer.h
@@ -259,6 +259,4 @@ gdk_export void GDKtracer_log(const char
gdk_export gdk_return GDKtracer_flush_buffer(void);
-gdk_export gdk_return GDKtracer_fill_comp_info(BAT *id, BAT *component, BAT
*log_level);
-
#endif /* _GDK_TRACER_H_ */
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -6575,6 +6575,7 @@ static mel_func geom_init_funcs[] = {
command("calc", "wkb", wkbFromWKB, false, "It is called when adding a new
geometry column to an existing table", args(1,2, arg("",wkb),arg("v",wkb))),
command("calc", "wkb", geom_2_geom, false, "Called when inserting values to a
table in order to check if the inserted geometries are of the same type and
srid required by the column definition", args(1,4,
arg("",wkb),arg("geo",wkb),arg("columnType",int),arg("columnSRID",int))),
command("batcalc", "wkb", geom_2_geom_bat, false, "Called when inserting
values to a table in order to check if the inserted geometries are of the same
type and srid required by the column definition", args(1,5,
batarg("",wkb),batarg("geo",wkb),batarg("s",oid),arg("columnType",int),arg("columnSRID",int))),
+ command("batcalc", "wkb", wkbFromText_bat_cand, false, "", args(1,5,
batarg("",wkb),batarg("wkt",str),batarg("s",oid),arg("srid",int),arg("type",int))),
{ .imp=NULL }
};
#include "mal_import.h"
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -60,6 +60,7 @@ geom_export mbr* mbrFromGeos(const GEOSG
geom_export str wkbFromText(wkb **geomWKB, str *geomWKT, int* srid, int *tpe);
geom_export str wkbFromText_bat(bat *outBAT_id, bat *inBAT_id, int *srid, int
*tpe);
+geom_export str wkbFromText_bat_cand(bat *outBAT_id, bat *inBAT_id, bat *cand,
int *srid, int *tpe);
geom_export str wkbMLineStringToPolygon(wkb** geomWKB, str *geomWKT, int*
srid, int* flag);
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -104,54 +104,92 @@ bailout:
str
wkbFromText_bat(bat *outBAT_id, bat *inBAT_id, int *srid, int *tpe)
{
- BAT *outBAT = NULL, *inBAT = NULL;
- char *inWKB = NULL;
- BUN p = 0, q = 0;
- BATiter inBAT_iter;
+ return wkbFromText_bat_cand(outBAT_id, inBAT_id, NULL, srid, tpe);
+}
+
+str
+wkbFromText_bat_cand(bat *outBAT_id, bat *inBAT_id, bat *cand, int *srid, int
*tpe)
+{
+ BAT *b = NULL, *s = NULL, *dst = NULL;
+ BATiter bi;
+ str msg = MAL_SUCCEED;
+ struct canditer ci;
+ BUN q = 0;
+ oid off = 0;
+ bool nils = false;
//get the descriptor of the BAT
- if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
- throw(MAL, "batgeom.wkbFromText", SQLSTATE(38000)
RUNTIME_OBJECT_MISSING);
+ if ((b = BATdescriptor(*inBAT_id)) == NULL) {
+ msg = createException(MAL, "batgeom.wkbFromText",
SQLSTATE(HY005) RUNTIME_OBJECT_MISSING);
+ goto bailout;
}
-
- //create a new for the output BAT
- if ((outBAT = COLnew(inBAT->hseqbase, ATOMindex("wkb"),
BATcount(inBAT), TRANSIENT)) == NULL) {
- BBPunfix(inBAT->batCacheid);
- throw(MAL, "batgeom.wkbFromText", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ bi = bat_iterator(b);
+ if (cand && !is_bat_nil(*cand) && (s = BATdescriptor(*cand)) == NULL) {
+ msg = createException(MAL, "batgeom.wkbFromText",
SQLSTATE(HY005) RUNTIME_OBJECT_MISSING);
+ goto bailout;
+ }
+ off = b->hseqbase;
+ q = canditer_init(&ci, b, s);
+ //create a new BAT, aligned with input BAT
+ if (!(dst = COLnew(ci.hseq, ATOMindex("wkb"), q, TRANSIENT))) {
+ msg = createException(MAL, "batgeom.wkbFromText",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ goto bailout;
}
- //iterator over the input BAT
- inBAT_iter = bat_iterator(inBAT);
- BATloop(inBAT, p, q) { //iterate over all valid elements
- str err = NULL;
- wkb *outSingle;
+ if (ci.tpe == cand_dense) {
+ for (BUN i = 0; i < q; i++) {
+ oid p = (canditer_next_dense(&ci) - off);
+ str inWKB = (str) BUNtvar(bi, p);
+ wkb *outSingle;
- inWKB = (char *) BUNtvar(inBAT_iter, p);
- if ((err = wkbFromText(&outSingle, &inWKB, srid, tpe)) !=
MAL_SUCCEED) {
- bat_iterator_end(&inBAT_iter);
- BBPunfix(inBAT->batCacheid);
- BBPunfix(outBAT->batCacheid);
- return err;
+ if ((msg = wkbFromText(&outSingle, &inWKB, srid, tpe))
!= MAL_SUCCEED)
+ goto bailout;
+ if (tfastins_nocheckVAR(dst, i, outSingle, Tsize(dst))
!= GDK_SUCCEED) {
+ GDKfree(outSingle);
+ msg = createException(MAL,
"batgeom.wkbFromText", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+ nils |= is_wkb_nil(outSingle);
+ GDKfree(outSingle);
+ outSingle = NULL;
}
- if (BUNappend(outBAT, outSingle, false) != GDK_SUCCEED) {
- bat_iterator_end(&inBAT_iter);
- BBPunfix(inBAT->batCacheid);
- BBPunfix(outBAT->batCacheid);
+ } else {
+ for (BUN i = 0; i < q; i++) {
+ oid p = (canditer_next(&ci) - off);
+ str inWKB = (str) BUNtvar(bi, p);
+ wkb *outSingle;
+
+ if ((msg = wkbFromText(&outSingle, &inWKB, srid, tpe))
!= MAL_SUCCEED)
+ goto bailout;
+ if (tfastins_nocheckVAR(dst, i, outSingle, Tsize(dst))
!= GDK_SUCCEED) {
+ GDKfree(outSingle);
+ msg = createException(MAL,
"batgeom.wkbFromText", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ goto bailout;
+ }
+ nils |= is_wkb_nil(outSingle);
GDKfree(outSingle);
- throw(MAL, "batgeom.wkbFromText", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ outSingle = NULL;
}
- GDKfree(outSingle);
- outSingle = NULL;
}
- bat_iterator_end(&inBAT_iter);
- //set the number of elements in the outBAT
- BATsetcount(outBAT, BATcount(inBAT));
-
- BBPunfix(inBAT->batCacheid);
- BBPkeepref(*outBAT_id = outBAT->batCacheid);
-
- return MAL_SUCCEED;
+bailout:
+ if (b)
+ bat_iterator_end(&bi);
+ if (b)
+ BBPunfix(b->batCacheid);
+ if (s)
+ BBPunfix(s->batCacheid);
+ if (dst && !msg) {
+ BATsetcount(dst, q);
+ dst->tnil = nils;
+ dst->tnonil = !nils;
+ dst->tkey = BATcount(dst) <= 1;
+ dst->tsorted = BATcount(dst) <= 1;
+ dst->trevsorted = BATcount(dst) <= 1;
+ BBPkeepref(*outBAT_id = dst->batCacheid);
+ } else if (dst)
+ BBPreclaim(dst);
+ return msg;
}
/*****************************************************************************/
diff --git a/geom/sql/functions/Tests/All b/geom/sql/functions/Tests/All
--- a/geom/sql/functions/Tests/All
+++ b/geom/sql/functions/Tests/All
@@ -68,3 +68,5 @@ HAVE_GEOM?ST_MakeBox2D
HAVE_GEOM?dropTestGeometries
+
+HAVE_GEOM?geomcasts
diff --git a/geom/sql/functions/Tests/geomcasts.test
b/geom/sql/functions/Tests/geomcasts.test
new file mode 100644
--- /dev/null
+++ b/geom/sql/functions/Tests/geomcasts.test
@@ -0,0 +1,43 @@
+query T rowsort
+SELECT CAST(x as geometry) from (values ('LINESTRING (0 0, 0 9, 9 9, 9 0, 0
0)')) x(x)
+----
+LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)
+
+query T rowsort
+SELECT CAST(x as geometry) from (values ('LINESTRING (0 0, 0 9, 9 9, 9 0, 0
0)'),('LINESTRING (0 0, 0 9, 9 8, 9 0, 0 0)'),('LINESTRING (0 0, 0 4, 9 9, 6 0,
0 0)')) x(x)
+----
+LINESTRING (0 0, 0 4, 9 9, 6 0, 0 0)
+LINESTRING (0 0, 0 9, 9 8, 9 0, 0 0)
+LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)
+
+statement error 38000!Geos operation GEOSWKTReader_read failed
+SELECT CAST(x as geometry) from (values ('LINESTRING (0 0, 0 9, 9 9, 9 0, 0
0)'),('LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)'),('LINESTRING (i am not right)'))
x(x)
+
+query T rowsort
+SELECT CAST(x as point) from (values ('LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)'))
x(x)
+----
+LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)
+
+query T rowsort
+SELECT CAST(x as point) from (values ('LINESTRING (0 0, 0 9, 9 9, 9 0, 0
0)'),('LINESTRING (0 0, 0 9, 9 8, 9 0, 0 0)'),('LINESTRING (0 0, 0 4, 9 9, 6 0,
0 0)')) x(x)
+----
+LINESTRING (0 0, 0 4, 9 9, 6 0, 0 0)
+LINESTRING (0 0, 0 9, 9 8, 9 0, 0 0)
+LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)
+
+statement error 38000!Geos operation GEOSWKTReader_read failed
+SELECT CAST(x as point) from (values ('LINESTRING (0 0, 0 9, 9 9, 9 0, 0
0)'),('LINESTRING (0 0, 0 9, 9 9, 9 0, 0 0)'),('LINESTRING (i am not right)'))
x(x)
+
+query T rowsort
+SELECT CAST(st_point(lon,lat) as point) from (values (1,1)) x(lon,lat)
+----
+POINT (1 1)
+
+query T rowsort
+SELECT CAST(st_point(lon,lat) as point) from (values (1,1),(2,2),(3,3))
x(lon,lat)
+----
+POINT (1 1)
+POINT (2 2)
+POINT (3 3)
+
+
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list