Changeset: 1e531b6297a0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1e531b6297a0 Branch: txtsim Log Message:
merged with default diffs (truncated from 577 to 300 lines): diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c --- a/clients/odbc/driver/SQLGetInfo.c +++ b/clients/odbc/driver/SQLGetInfo.c @@ -1037,15 +1037,16 @@ MNDBGetInfo(ODBCDbc *dbc, break; case SQL_TIMEDATE_ADD_INTERVALS: case SQL_TIMEDATE_DIFF_INTERVALS: - /* SQL_FN_TSI_FRAC_SECOND | - * SQL_FN_TSI_SECOND | - * SQL_FN_TSI_MINUTE | - * SQL_FN_TSI_HOUR | - * SQL_FN_TSI_DAY | - * SQL_FN_TSI_WEEK | - * SQL_FN_TSI_MONTH | - * SQL_FN_TSI_QUARTER | - * SQL_FN_TSI_YEAR */ + /* when server is 11.46 or higher */ + nValue = SQL_FN_TSI_SECOND | + SQL_FN_TSI_MINUTE | + SQL_FN_TSI_HOUR | + SQL_FN_TSI_DAY | + SQL_FN_TSI_WEEK | + SQL_FN_TSI_MONTH | + SQL_FN_TSI_QUARTER | + SQL_FN_TSI_YEAR; + /* SQL_FN_TSI_FRAC_SECOND | */ break; case SQL_TIMEDATE_FUNCTIONS: nValue = SQL_FN_TD_CURRENT_DATE | @@ -1053,7 +1054,7 @@ MNDBGetInfo(ODBCDbc *dbc, SQL_FN_TD_CURRENT_TIMESTAMP | SQL_FN_TD_CURDATE | SQL_FN_TD_CURTIME | - /* SQL_FN_TD_DAYNAME | */ + SQL_FN_TD_DAYNAME | /* when server is 11.46 or higher */ SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK | SQL_FN_TD_DAYOFYEAR | @@ -1061,12 +1062,12 @@ MNDBGetInfo(ODBCDbc *dbc, SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE | SQL_FN_TD_MONTH | - /* SQL_FN_TD_MONTHNAME | */ + SQL_FN_TD_MONTHNAME | /* when server is 11.46 or higher */ SQL_FN_TD_NOW | SQL_FN_TD_QUARTER | SQL_FN_TD_SECOND | - /* SQL_FN_TD_TIMESTAMPADD | */ - /* SQL_FN_TD_TIMESTAMPDIFF | */ + SQL_FN_TD_TIMESTAMPADD | /* when server is 11.46 or higher */ + SQL_FN_TD_TIMESTAMPDIFF | /* when server is 11.46 or higher */ SQL_FN_TD_WEEK | SQL_FN_TD_YEAR; break; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -519,6 +519,9 @@ heapinit(BAT *b, const char *buf, return -1; } + if (strcmp(type, "wkba") == 0) + TRC_WARNING(GDK, "type wkba (SQL name: GeometryA) is deprecated\n"); + if (properties & ~0x0F81) { TRC_CRITICAL(GDK, "unknown properties are set: incompatible database on line %d of BBP.dir\n", lineno); return -1; diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c --- a/gdk/gdk_hash.c +++ b/gdk/gdk_hash.c @@ -100,10 +100,11 @@ HASHclear(Hash *h) memset(h->Bckt, 0xFF, h->nbucket * h->width); } -#define HASH_VERSION 4 -/* this is only for the change of hash function of the UUID type; if - * HASH_VERSION is increased again from 4, the code associated with - * HASH_VERSION_NOUUID must be deleted */ +#define HASH_VERSION 5 +/* this is only for the change of hash function of the UUID type and MBR + * type; if HASH_VERSION is increased again from 5, the code associated + * with HASH_VERSION_NOUUID and HASH_VERSION_NOMBR must be deleted */ +#define HASH_VERSION_NOMBR 4 #define HASH_VERSION_NOUUID 3 #define HASH_HEADER_SIZE 7 /* nr of size_t fields in header */ @@ -500,7 +501,17 @@ BATcheckhash(BAT *b) ((size_t) 1 << 24) | #endif HASH_VERSION_NOUUID) && - strcmp(ATOMname(b->ttype), "uuid") != 0) + strcmp(ATOMname(b->ttype), "uuid") != 0 && + strcmp(ATOMname(b->ttype), "mbr") != 0) +#endif +#ifdef HASH_VERSION_NOMBR + /* if not uuid, also allow previous version */ + || (hdata[0] == ( +#ifdef PERSISTENTHASH + ((size_t) 1 << 24) | +#endif + HASH_VERSION_NOMBR) && + strcmp(ATOMname(b->ttype), "mbr") != 0) #endif ) && hdata[1] > 0 && diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -5169,7 +5169,15 @@ wkbHASH(const void *W) BUN h = 0; for (i = 0; i < (w->len - 1); i += 2) { - int a = *(w->data + i), b = *(w->data + i + 1); + BUN a = ((unsigned char *) w->data)[i]; + BUN b = ((unsigned char *) w->data)[i + 1]; +#if '\377' < 0 /* char is signed? */ + /* maybe sign extend */ + if (a & 0x80) + a |= ~(BUN)0x7f; + if (b & 0x80) + b |= ~(BUN)0x7f; +#endif h = (h << 3) ^ (h >> 11) ^ (h >> 17) ^ (b << 8) ^ a; } return h; @@ -5396,7 +5404,8 @@ static BUN mbrHASH(const void *ATOM) { const mbr *atom = ATOM; - return (BUN) (((int) atom->xmin * (int)atom->ymin) *((int) atom->xmax * (int)atom->ymax)); + return ATOMhash(TYPE_flt, &atom->xmin) ^ ATOMhash(TYPE_flt, &atom->ymin) ^ + ATOMhash(TYPE_flt, &atom->xmax) ^ ATOMhash(TYPE_flt, &atom->ymax); } static const void * @@ -5622,7 +5631,15 @@ wkbaHASH(const void *WARRAY) for (j = 0; j < wArray->itemsNum; j++) { wkb *w = wArray->data[j]; for (i = 0; i < (w->len - 1); i += 2) { - int a = *(w->data + i), b = *(w->data + i + 1); + BUN a = ((unsigned char *) w->data)[i]; + BUN b = ((unsigned char *) w->data)[i + 1]; +#if '\377' < 0 /* char is signed? */ + /* maybe sign extend */ + if (a & 0x80) + a |= ~(BUN)0x7f; + if (b & 0x80) + b |= ~(BUN)0x7f; +#endif h = (h << 3) ^ (h >> 11) ^ (h >> 17) ^ (b << 8) ^ a; } } diff --git a/sql/ChangeLog b/sql/ChangeLog --- a/sql/ChangeLog +++ b/sql/ChangeLog @@ -19,8 +19,10 @@ own query executions. * Wed Feb 15 2023 svetlin <svetlin.stali...@monetdbsolutions.com> -- Added JDBC/ODBC escape sequences implementation to SQL layer. Now all - clients can forward them without further processing. +- Added support of ODBC escape sequences syntax to SQL layer. Now all clients + (including ODBC/JDBC/pymonetdb) can use them without further processing. + For details on ODBC escape sequences syntax see: + https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/odbc-escape-sequences * Thu Nov 10 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> - It is no longer allowed to create a merge table or remote table or diff --git a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test --- a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test +++ b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test @@ -5,7 +5,7 @@ query T nosort plan copy into cm_tmp from '/file1','/file2' ---- insert( -| table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT NULL UNIQUE ] +| table("sys"."cm_tmp") [ "cm_tmp"."i", "cm_tmp"."%TID%" NOT NULL UNIQUE ] | union ( | | project ( | | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", varchar NULL, varchar "null", varchar "/file1", bigint(18) "-1", bigint(18) "0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), diff --git a/sql/test/merge-partitions/Tests/mergepart31.test b/sql/test/merge-partitions/Tests/mergepart31.test --- a/sql/test/merge-partitions/Tests/mergepart31.test +++ b/sql/test/merge-partitions/Tests/mergepart31.test @@ -383,11 +383,18 @@ project ( query T nosort plan select 1 from splitted where stamp > TIMESTAMP '1999-01-01 00:00:00' and stamp <= TIMESTAMP '2001-01-01 00:00:00' ---- -project ( -| select ( -| | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] -| ) [ (timestamp(7) "1999-01-01 00:00:00.000000") < ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2001-01-01 00:00:00.000000") ] -) [ tinyint(1) "1" as "%5"."%5" ] +union ( +| project ( +| | select ( +| | | table("sys"."first_decade") [ "first_decade"."stamp" UNIQUE as "splitted"."stamp" ] +| | ) [ (timestamp(7) "1999-01-01 00:00:00.000000") < ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2001-01-01 00:00:00.000000") ] +| ) [ tinyint(1) "1" ], +| project ( +| | select ( +| | | table("sys"."fourth_decade") [ "fourth_decade"."stamp" UNIQUE as "splitted"."stamp" ] +| | ) [ (timestamp(7) "1999-01-01 00:00:00.000000") < ("splitted"."stamp" UNIQUE) <= (timestamp(7) "2001-01-01 00:00:00.000000") ] +| ) [ tinyint(1) "1" ] +) [ "%5"."%5" NOT NULL ] query T nosort plan select 1 from splitted where stamp = TIMESTAMP '2010-01-01 00:00:00' diff --git a/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test b/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test --- a/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test +++ b/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test @@ -1,3 +1,15 @@ +# ref: https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/time-date-and-interval-functions + +query I rowsort +select { fn current_date() } > date'2023-01-02' +---- +1 + +query I rowsort +select { fn current_date() } > {d'2023-01-02'} +---- +1 + query I rowsort select length((select { fn current_date() })) > 0 ---- @@ -9,6 +21,22 @@ select length((select { fn curdate() })) 1 query I rowsort +select { fn current_time() } >= time'00:00:00' +---- +1 + +query I rowsort +select { fn CURRENT_TIME() } >= {t'00:00:00'} +---- +1 + +# test CURRENT_TIME( time-precision ) +statement error 42000!syntax error in: "select { fn current_time(6" +select { fn current_time(6) } >= {t'00:00:00.000000001'} +# ---- +# 1 + +query I rowsort select length(cast((select { fn current_time() }) as varchar(100))) > 0 ---- 1 @@ -18,42 +46,148 @@ select length(cast((select { fn curtime( ---- 1 +query I rowsort +select { fn current_timestamp() } > timestamp'2023-01-02 00:00:00' +---- +1 + +query I rowsort +select { fn CURRENT_TIMESTAMP() } > {ts'2023-01-02 00:00:00'} +---- +1 + +# test CURRENT_TIMESTAMP( timestamp-precision ) +statement error 42000!syntax error in: "select { fn current_timestamp(9" +select { fn current_timestamp(9) } >= {ts'2002-01-02 00:00:00.000000001'} +# ---- +# 1 + +query I rowsort +select length(cast((select { fn current_timestamp() }) as varchar(100))) > 0 +---- +1 + query T rowsort -select { fn dayname('2022-11-11') } +select { fn dayname(date'2022-11-11') } ---- Friday query I rowsort -select { fn dayofmonth('2022-11-11') } +select { fn dayofmonth(date'2022-11-11') } ---- 11 query I rowsort -select { fn dayofweek('2022-11-11') } +select { fn dayofweek(date'2022-11-11') } ---- 5 query I rowsort -select { fn dayofyear('2022-01-01') } +select { fn dayofyear(date'2022-01-31') } +---- +31 + +query I rowsort +select { fn extract(day from date'2022-01-02') } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org