Changeset: 6e36c6b55af6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6e36c6b55af6
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/common/sql_types.c
sql/include/sql_catalog.h
sql/server/rel_optimizer.c
sql/storage/sql_storage.h
sql/storage/store.c
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: unlock
Log Message:
merged
diffs (truncated from 128069 to 300 lines):
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1360,7 +1360,10 @@ GDKusec(void)
return (lng) (f.QuadPart / 10);
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
- clock_gettime(CLOCK_REALTIME, &ts);
+#ifdef CLOCK_REALTIME_COARSE
+ if (clock_gettime(CLOCK_REALTIME_COARSE, &ts) < 0)
+#endif
+ (void) clock_gettime(CLOCK_REALTIME, &ts);
return (lng) (ts.tv_sec * LL_CONSTANT(1000000) + ts.tv_nsec / 1000);
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tv;
diff --git a/sql/backends/monet5/sql_upgrades.c
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1946,7 +1946,7 @@ sql_update_default_lidar(Client c)
}
static str
-sql_update_default(Client c, mvc *sql, const char *prev_schema)
+sql_update_default(Client c, mvc *sql, const char *prev_schema, bool
*systabfixed)
{
size_t bufsize = 8192, pos = 0;
char *err = NULL, *buf = GDKmalloc(bufsize);
@@ -1969,6 +1969,11 @@ sql_update_default(Client c, mvc *sql, c
if (b) {
BATiter bi = bat_iterator(b);
if (BATcount(b) > 0 && strcmp(BUNtail(bi, 0), "progress") == 0)
{
+ if (!*systabfixed &&
+ (err = sql_fix_system_tables(c, sql,
prev_schema)) != NULL)
+ return err;
+ *systabfixed = true;
+
pos = 0;
pos += snprintf(buf + pos, bufsize - pos,
"set schema \"sys\";\n");
@@ -2087,20 +2092,6 @@ sql_update_default(Client c, mvc *sql, c
pos += snprintf(buf + pos, bufsize - pos,
"delete from args where id in (select
args.id from args left join functions on args.func_id = functions.id where
functions.id is null);\n");
- list *functions = sa_list(sql->sa);
- /* Adding fixed versions of degrees and radians
functions */
- sql_subtype *flt_types[2] = {sql_bind_localtype("flt"),
sql_bind_localtype("dbl")};
- for (int i = 0; i < 2; i++) {
- sql_subtype *next = flt_types[i];
- /* TODO: This is BAD: its redundantly is
trying to add duplicate function definitions to the global funcs list instead
of updating the functions table.
- * But it just ends up corrupting the
global funcs list because it is using the wrong sql allocator.
- */
- list_append(functions, sql_create_func(sql->sa,
"degrees", "mmath", "degrees", FALSE, FALSE, SCALE_FIX, 0, next->type, 1,
next->type));
- list_append(functions, sql_create_func(sql->sa,
"radians", "mmath", "radians", FALSE, FALSE, SCALE_FIX, 0, next->type, 1,
next->type));
- }
-
- insert_functions(sql->session->tr, mvc_bind_table(sql,
sys, "functions"), functions, mvc_bind_table(sql, sys, "args"));
-
pos += snprintf(buf + pos, bufsize - pos,
"UPDATE sys.functions set semantics = false
WHERE (name, func) IN (VALUES \n"
"('length', 'nitems'),\n"
@@ -2426,7 +2417,7 @@ SQLupgrades(Client c, mvc *m)
return -1;
}
- if ((err = sql_update_default(c, m, prev_schema)) != NULL) {
+ if ((err = sql_update_default(c, m, prev_schema, &systabfixed)) !=
NULL) {
TRC_CRITICAL(SQL_PARSER, "%s\n", err);
freeException(err);
GDKfree(prev_schema);
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1055,7 +1055,7 @@ sql_create_procedure(sql_allocator *sa,
return res;
}
-sql_func *
+static sql_func *
sql_create_func(sql_allocator *sa, const char *name, const char *mod, const
char *imp, bit semantics, bit side_effect, int fix_scale,
unsigned int res_scale, sql_type *fres, int
nargs, ...)
{
diff --git a/sql/common/sql_types.h b/sql/common/sql_types.h
--- a/sql/common/sql_types.h
+++ b/sql/common/sql_types.h
@@ -68,8 +68,4 @@ extern int is_sqlfunc(sql_func *f);
extern void types_init(sql_allocator *sa);
-/* This function should be used in exceptional cases such as dealing with
tricky upgrades! */
-extern sql_func *sql_create_func(sql_allocator *sa, const char *name, const
char *mod, const char *imp, bit semantics, bit side_effect, int fix_scale,
- unsigned int
res_scale, sql_type *fres, int nargs, ...);
-
#endif /* SQL_TYPES_H */
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -311,6 +311,7 @@ typedef enum sql_class {
#define EC_TEMP_TZ(e) (e==EC_TIME_TZ||e==EC_TIMESTAMP_TZ)
#define EC_TEMP(e)
(e==EC_TIME||e==EC_DATE||e==EC_TIMESTAMP||EC_TEMP_TZ(e))
#define EC_TEMP_FRAC(e)
(e==EC_TIME||e==EC_TIMESTAMP||EC_TEMP_TZ(e))
+#define EC_TEMP_NOFRAC(e) (e==EC_TIME||e==EC_TIMESTAMP)
#define EC_BACKEND_FIXED(e) (EC_NUMBER(e)||e==EC_BIT||EC_TEMP(e))
typedef struct sql_type {
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -18,8 +18,6 @@
#ifdef HAVE_HGE
#include "mal.h" /* for have_hge */
#endif
-#include "gdk_time.h"
-#include "blob.h"
comp_type
compare_str2type(const char *compare_op)
@@ -2648,97 +2646,6 @@ exp_sum_scales(sql_subfunc *f, sql_exp *
}
}
-sql_exp *
-create_table_part_atom_exp(mvc *sql, sql_subtype tpe, ptr value)
-{
- str buf = NULL;
- size_t len = 0;
- sql_exp *res = NULL;
-
- switch (tpe.type->eclass) {
- case EC_BIT: {
- bit bval = *((bit*) value);
- return exp_atom_bool(sql->sa, bval ? 1 : 0);
- }
- case EC_POS:
- case EC_NUM:
- case EC_DEC:
- case EC_SEC:
- case EC_MONTH:
- switch (tpe.type->localtype) {
-#ifdef HAVE_HGE
- case TYPE_hge: {
- hge hval = *((hge*) value);
- return exp_atom_hge(sql->sa, hval);
- }
-#endif
- case TYPE_lng: {
- lng lval = *((lng*) value);
- return exp_atom_lng(sql->sa, lval);
- }
- case TYPE_int: {
- int ival = *((int*) value);
- return exp_atom_int(sql->sa, ival);
- }
- case TYPE_sht: {
- sht sval = *((sht*) value);
- return exp_atom_sht(sql->sa, sval);
- }
- case TYPE_bte: {
- bte bbval = *((bte *) value);
- return exp_atom_bte(sql->sa, bbval);
- }
- default:
- return NULL;
- }
- case EC_FLT:
- switch (tpe.type->localtype) {
- case TYPE_flt: {
- flt fval = *((flt*) value);
- return exp_atom_flt(sql->sa, fval);
- }
- case TYPE_dbl: {
- dbl dval = *((dbl*) value);
- return exp_atom_dbl(sql->sa, dval);
- }
- default:
- return NULL;
- }
- case EC_DATE: {
- if(date_tostr(&buf, &len, (const date *)value, false) <
0)
- return NULL;
- res = exp_atom(sql->sa, atom_general(sql->sa, &tpe,
buf));
- break;
- }
- case EC_TIME: {
- if(daytime_tostr(&buf, &len, (const daytime *)value,
false) < 0)
- return NULL;
- res = exp_atom(sql->sa, atom_general(sql->sa, &tpe,
buf));
- break;
- }
- case EC_TIMESTAMP: {
- if(timestamp_tostr(&buf, &len, (const timestamp
*)value, false) < 0)
- return NULL;
- res = exp_atom(sql->sa, atom_general(sql->sa, &tpe,
buf));
- break;
- }
- case EC_BLOB: {
- if(BLOBtostr(&buf, &len, (const blob *)value, false) <
0)
- return NULL;
- res = exp_atom(sql->sa, atom_general(sql->sa, &tpe,
buf));
- break;
- }
- case EC_CHAR:
- case EC_STRING:
- return exp_atom_clob(sql->sa, sa_strdup(sql->sa,
value));
- default:
- assert(0);
- }
- if(buf)
- GDKfree(buf);
- return res;
-}
-
int
exp_aggr_is_count(sql_exp *e)
{
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -186,8 +186,6 @@ extern atom *exp_flatten(mvc *sql, sql_e
extern void exp_sum_scales(sql_subfunc *f, sql_exp *l, sql_exp *r);
-extern sql_exp *create_table_part_atom_exp(mvc *sql, sql_subtype tpe, ptr
value);
-
extern int exp_aggr_is_count(sql_exp *e);
extern void exps_reset_freevar(list *exps);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -8790,52 +8790,15 @@ rel_add_dicts(visitor *v, sql_rel *rel)
}
static int
-find_col_exp( list *exps, sql_exp *e)
-{
- node *n;
- int nr = 0;
-
- for (n=exps->h; n; n=n->next, nr++){
- if (n->data == e)
- return nr;
- }
- return -1;
-}
-
-static int
-exp_range_overlap(mvc *sql, sql_exp *e, char *min, char *max, atom *emin, atom
*emax)
-{
- sql_subtype *t = exp_subtype(e);
- int localtype = t->type->localtype;
-
- if (!min || !max || !emin || !emax || strNil(min) || strNil(max) ||
emin->isnull || emax->isnull || !ATOMlinear(localtype))
+exp_range_overlap(atom *min, atom *max, atom *emin, atom *emax, bool
min_exclusive, bool max_exclusive)
+{
+ if (!min || !max || !emin || !emax || min->isnull || max->isnull ||
emin->isnull || emax->isnull)
return 0;
- switch (ATOMstorage(localtype)) {
- case TYPE_bte:
- case TYPE_sht:
- case TYPE_int:
- case TYPE_lng:
-#ifdef HAVE_HGE
- case TYPE_hge:
-#endif
- case TYPE_flt:
- case TYPE_dbl:
- case TYPE_str: {
- atom *cmin, *cmax;
-
-#ifdef HAVE_HGE
- if (localtype == TYPE_hge && !have_hge)
- return 0;
-#endif
- cmin = atom_general(sql->sa, t, min);
- cmax = atom_general(sql->sa, t, max);
- if (VALcmp(&(emax->data), &(cmin->data)) < 0 ||
VALcmp(&(emin->data), &(cmax->data)) > 0)
- return 0;
- } break;
- default:
+ if ((!min_exclusive && VALcmp(&(emax->data), &(min->data)) < 0) ||
(min_exclusive && VALcmp(&(emax->data), &(min->data)) <= 0))
return 0;
- }
+ if ((!max_exclusive && VALcmp(&(emin->data), &(max->data)) > 0) ||
(max_exclusive && VALcmp(&(emin->data), &(max->data)) >= 0))
+ return 0;
return 1;
}
@@ -8871,13 +8834,22 @@ rel_rename_part(mvc *sql, sql_rel *p, ch
return p;
}
+typedef struct {
+ atom *lval;
+ atom *hval;
+ bte anti:1,
+ semantics:1;
+ int flag;
+ list *values;
+} range_limit;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list