Changeset: 099339430751 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/099339430751
Branch: nested
Log Message:
merge upstream
diffs (truncated from 543 to 300 lines):
diff --git a/clients/Tests/MAL-signatures-hge.test
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -46542,7 +46542,12 @@ json
read_json
pattern json.read_json(X_0:str):bat[:json]
JSONread_json
-Reads json file into a table
+Reads json file
+json
+read_nd_json
+pattern json.read_nd_json(X_0:str):bat[:json]
+JSONread_nd_json
+Reads new line delimited json objects
json
renderarray
pattern json.renderarray(X_0:any...):json
@@ -49177,12 +49182,12 @@ sql
from_json
pattern sql.from_json(X_0:bat?[:json], X_1:ptr):bat[:any]...
SQLfrom_json
-Reads json string into table of nested/multiset structures
+Converts json string into table of nested/multiset structures
sql
from_varchar
pattern sql.from_varchar(X_0:bat?[:str], X_1:ptr):bat[:any]...
SQLfrom_varchar
-Reads string into table of nested/multiset structures
+Converts string into table of nested/multiset structures
sql
getVariable
pattern sql.getVariable(X_0:int, X_1:str, X_2:str):any_1
@@ -49299,6 +49304,11 @@ pattern sql.next_value_ms(X_0:any_1, X_1
mvc_next_value
return the next value of the sequence
sql
+normalize_monetdb_url
+pattern sql.normalize_monetdb_url(X_0:str):str
+SQLnormalize_monetdb_url
+Normalize mapi:monetdb://, monetdb:// or monetdbs:// URL
+sql
nth_value
pattern sql.nth_value(X_0:any_1, X_1:lng, X_2:bit, X_3:bit, X_4:int, X_5:oid,
X_6:oid):any_1
SQLnth_value
@@ -49789,6 +49799,11 @@ pattern sql.tid(X_0:int, X_1:str, X_2:st
SQLtid
Return the tables tid column.
sql
+to_json
+pattern sql.to_json(X_0:ptr, X_1:bat[:any]...):json
+SQLto_json
+Convert complex type into json
+sql
transaction_begin
unsafe pattern sql.transaction_begin(X_0:int, X_1:str):void
SQLtransaction_begin
diff --git a/clients/Tests/MAL-signatures.test
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -34909,6 +34909,11 @@ pattern json.dump(X_0:json):bat[:str]
JSONdump
(empty)
json
+epilogue
+command json.epilogue():void
+JSONepilogue
+(empty)
+json
filter
command json.filter(X_0:json, X_1:str):json
JSONfilter
@@ -35014,6 +35019,21 @@ command json.number(X_0:json):dbl
JSONjson2number
Convert simple JSON values to a double, return nil upon error.
json
+prelude
+pattern json.prelude():void
+JSONprelude
+(empty)
+json
+read_json
+pattern json.read_json(X_0:str):bat[:json]
+JSONread_json
+Reads json file
+json
+read_nd_json
+pattern json.read_nd_json(X_0:str):bat[:json]
+JSONread_nd_json
+Reads new line delimited json objects
+json
renderarray
pattern json.renderarray(X_0:any...):json
JSONrenderarray
@@ -37615,14 +37635,14 @@ SQLfirst_value
return the first value of groups
sql
from_json
-pattern sql.from_json(X_0:json, X_1:ptr):bat[:any]...
+pattern sql.from_json(X_0:bat?[:json], X_1:ptr):bat[:any]...
SQLfrom_json
-Reads json string into table of nested/multiset structures
+Converts json string into table of nested/multiset structures
sql
from_varchar
pattern sql.from_varchar(X_0:bat?[:str], X_1:ptr):bat[:any]...
SQLfrom_varchar
-Reads string into table of nested/multiset structures
+Converts string into table of nested/multiset structures
sql
getVariable
pattern sql.getVariable(X_0:int, X_1:str, X_2:str):any_1
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
@@ -1651,14 +1651,15 @@ void qc_delete(qc *cache, cq *q);
cq *qc_find(qc *cache, int id);
cq *qc_insert(qc *cache, allocator *sa, sql_rel *r, symbol *s, list *params,
mapi_query_t type, char *codedstr, int no_mitosis);
void rel_base_use_all(mvc *sql, sql_rel *rel);
-sql_rel *rel_basetable(mvc *sql, sql_table *t, const char *tname);
+sql_rel *rel_basetable(mvc *sql, sql_table *t, sql_alias *tname);
sql_rel *rel_project(allocator *sa, sql_rel *l, list *e);
-list *rel_projections(mvc *sql, sql_rel *rel, const char *tname, int settname,
int intern);
+list *rel_projections(mvc *sql, sql_rel *rel, sql_alias *tname, int settname,
int intern);
void res_tables_destroy(res_table *results);
list *sa_list(allocator *sa);
char *sa_message(allocator *sa, _In_z_ _Printf_format_string_ const char
*format, ...) __attribute__((__format__(__printf__, 2, 3)));
msettings *sa_msettings_create(allocator *sa);
char *sa_msettings_to_string(const msettings *mp, allocator *sa, size_t
size_hint);
+sql_type *schema_bind_type(mvc *sql, sql_schema *s, const char *name);
str sht_dec2_bte(bte *res, const int *s1, const sht *v);
str sht_dec2_dbl(dbl *res, const int *s1, const sht *v);
str sht_dec2_flt(flt *res, const int *s1, const sht *v);
@@ -1684,7 +1685,9 @@ void sql_init_subtype(sql_subtype *res,
void sql_register(const char *name, const unsigned char *code);
int sql_trans_add_dependency_change(sql_trans *tr, sqlid id,
sql_dependency_change_type tp);
int sql_trans_create_table(sql_table **tres, sql_trans *tr, sql_schema *s,
const char *name, const char *sql, int tt, bit system, int persistence, int
commit_action, int sz, bte properties);
+stmt *stmt_alias(backend *be, stmt *op1, int label, sql_alias *tname, const
char *name);
stmt *stmt_func(backend *be, stmt *ops, const char *name, sql_rel *imp, int
f_union);
+stmt *stmt_none(backend *be);
# stream
stream *block_stream(stream *s);
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2641,6 +2641,10 @@ rel2bin_subtable(backend *be, sql_table
if (s && s->type == st_list &&
c->type.multiset) { /* keep rowid at the end */
stmt *ns = stmt_col(be, c, dels,
dels->partition);
list_append(s->op4.lval, ns);
+ s->nr = ns->nr;
+ s->multiset = c->type.multiset;
+ } else if (s && s->type == st_list &&
c->type.type->composite) {
+ s->subtype = *exp_subtype(exp);
}
} else {
s = stmt_col(be, c, dels, dels->partition);
@@ -2728,11 +2732,7 @@ rel2bin_basetable(backend *be, sql_rel *
s->nr = ns->nr;
s->multiset = c->type.multiset;
} else if (s && s->type == st_list &&
c->type.type->composite) {
- stmt *ns = stmt_none(be);
- ns->type = st_alias;
- ns->subtype = *exp_subtype(exp);
- ns->virt = true;
- list_append(s->op4.lval, ns);
+ s->subtype = *exp_subtype(exp);
}
} else {
s = (c == fcol) ? col : stmt_col(be, c,
complex?dels:NULL, dels->partition);
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -1878,7 +1878,10 @@ mvc_export_head(backend *b, stream *s, i
int mtype = c->type.type->localtype;
sql_class eclass = c->type.type->eclass;
- if ((res = export_length(s, mtype, eclass,
c->type.digits, c->type.scale, type_has_tz(&c->type), c->b, c->p)) < 0)
+ if (c->type.multiset || c->type.type->composite) {
+ if (mvc_send_lng(s, 16) != 1)
+ return -4;
+ } else if ((res = export_length(s, mtype, eclass,
c->type.digits, c->type.scale, type_has_tz(&c->type), c->b, c->p)) < 0)
return res;
i += c->nrfields;
if (i < t->nr_cols && mnstr_write(s, ",\t", 2, 1) != 1)
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -2638,6 +2638,7 @@ stmt_project(backend *be, stmt *op1, stm
if (s == NULL)
return NULL;
s->nested = true;
+ s->subtype = op2->subtype;
return s;
}
InstrPtr q = stmt_project_join(be, op1, op2, false);
diff --git a/sql/server/rel_basetable.c b/sql/server/rel_basetable.c
--- a/sql/server/rel_basetable.c
+++ b/sql/server/rel_basetable.c
@@ -157,6 +157,62 @@ rel_base_use_all( mvc *sql, sql_rel *rel
}
}
+static rel_base_t* rel_nested_basetable_add_cols(mvc *sql, rel_base_t *pba,
char *colname, sql_table *t, list *exps);
+
+static node *
+rel_nested_basetable_add_ccols(mvc *sql, rel_base_t *ba, sql_column *c, node
*cn, list *exps)
+{
+ sql_alias *atname = a_create(sql->sa, c->base.name);
+ atname->parent = ba->name;
+ int i = sql->nid;
+ prop *p = NULL;
+ sql_exp *e = NULL;
+
+ sql->nid += list_length(c->type.type->d.fields);
+ for (node *n = c->type.type->d.fields->h; n && cn; n = n->next, i++) {
+ sql_column *c = cn->data;
+ if (!column_privs(sql, c, PRIV_SELECT))
+ continue;
+ if (c->type.multiset) {
+ e = exp_alias(sql, atname, c->base.name, atname,
c->base.name, &c->type, CARD_MULTI, c->null, is_column_unique(c), 1);
+ if (e)
+ e->f = sa_list(sql->sa);
+ if (!e || !e->f)
+ return NULL;
+ sql_table *t = mvc_bind_table(sql, c->t->s,
c->storage_type);
+ if (rel_nested_basetable_add_cols(sql, ba,
c->base.name, t, e->f) == NULL)
+ e = NULL;
+ cn = cn->next;
+ } else if (c->type.type->composite) {
+ e = exp_alias(sql, atname, c->base.name, atname,
c->base.name, &c->type, CARD_MULTI, c->null, is_column_unique(c), 0);
+ if (e)
+ e->f = sa_list(sql->sa);
+ if (!e || !e->f)
+ return NULL;
+ cn = rel_nested_basetable_add_ccols(sql, ba, c,
cn->next, e->f);
+ } else {
+ e = exp_alias(sql, atname, c->base.name, atname,
c->base.name, &c->type, CARD_MULTI, c->null, is_column_unique(c), 1);
+ cn = cn->next;
+ }
+ if (e == NULL)
+ return NULL;
+ e->nid = -(i);
+ e->alias.label = e->nid;
+ if (c->t->pkey && ((sql_kc*)c->t->pkey->k.columns->h->data)->c
== c) {
+ p = e->p = prop_create(sql->sa, PROP_HASHCOL, e->p);
+ p->value.pval = c->t->pkey;
+ } else if (c->unique == 2) {
+ p = e->p = prop_create(sql->sa, PROP_HASHCOL, e->p);
+ p->value.pval = NULL;
+ }
+ set_intern(e);
+ set_basecol(e);
+ sql_column_get_statistics(sql, c, e);
+ append(exps, e);
+ }
+ return cn;
+}
+
static rel_base_t*
rel_nested_basetable_add_cols(mvc *sql, rel_base_t *pba, char *colname,
sql_table *t, list *exps)
{
@@ -176,30 +232,30 @@ rel_nested_basetable_add_cols(mvc *sql,
int i = 0;
prop *p = NULL;
sql_exp *e = NULL;
- for (node *cn = ol_first_node(t->columns); cn; cn = cn->next, i++) {
+ for (node *cn = ol_first_node(t->columns); cn; i++) {
sql_column *c = cn->data;
if (!column_privs(sql, c, PRIV_SELECT))
continue;
if (c->type.multiset) {
e = exp_alias(sql, atname, c->base.name, atname,
c->base.name, &c->type, CARD_MULTI, c->null, is_column_unique(c), 1);
- if (e) {
- e->nid = -(ba->basenr + i);
- e->alias.label = e->nid;
- set_intern(e);
- set_basecol(e);
- append(exps, e);
+ if (e)
e->f = sa_list(sql->sa);
- }
-
if (!e || !e->f)
return NULL;
sql_table *t = mvc_bind_table(sql, c->t->s,
c->storage_type);
if (rel_nested_basetable_add_cols(sql, pba,
c->base.name, t, e->f) == NULL)
e = NULL;
- else
- continue;
+ cn = cn->next;
+ } else if (c->type.type->composite) {
+ e = exp_alias(sql, atname, c->base.name, atname,
c->base.name, &c->type, CARD_MULTI, c->null, is_column_unique(c), 0);
+ if (e)
+ e->f = sa_list(sql->sa);
+ if (!e || !e->f)
+ return NULL;
+ cn = rel_nested_basetable_add_ccols(sql, ba, c,
cn->next, e->f);
} else {
e = exp_alias(sql, atname, c->base.name, atname,
c->base.name, &c->type, CARD_MULTI, c->null, is_column_unique(c), 1);
+ cn = cn->next;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]