Changeset: 6ba5db4e3053 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6ba5db4e3053
Modified Files:
        sql/backends/monet5/sql_statistics.c
        sql/server/rel_psm.c
Branch: analyze-fix
Log Message:

Make analyze run again and don't use SQL catalog properties on analyze at the 
moment


diffs (110 lines):

diff --git a/sql/backends/monet5/sql_statistics.c 
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -11,41 +11,27 @@ Most optimizers need easy access to key 
 for proper plan generation. Amongst others, this
 information consists of the tuple count, size,
 min- and max-value, and the null-density.
-They are kept around as persistent tables, modeled
-directly as a collection of BATs.
 
 We made need an directly accessible structure to speedup
 analysis by optimizers.
 */
 #include "monetdb_config.h"
 #include "sql_statistics.h"
-#include "sql_execute.h"
 
 str
 sql_analyze(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        mvc *m = NULL;
-       str msg = getSQLContext(cntxt, mb, &m, NULL);
-       sql_trans *tr = m->session->tr;
-       str sch = 0, tbl = 0, col = 0;
+       sql_trans *tr = NULL;
+       str sch = NULL, tbl = NULL, col = NULL, msg = MAL_SUCCEED;
        int argc = pci->argc, sfnd = 0, tfnd = 0, cfnd = 0;
-       sql_schema *sys;
-       sql_table *sysstats;
-       sql_column *statsid;
 
-       if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL)
+       if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
+               return msg;
+       if ((msg = checkSQLContext(cntxt)) != NULL)
                return msg;
 
-       sys = mvc_bind_schema(m, "sys");
-       if (sys == NULL)
-               throw(SQL, "sql.analyze", SQLSTATE(3F000) "Internal error: No 
schema sys");
-       sysstats = mvc_bind_table(m, sys, "statistics");
-       if (sysstats == NULL)
-               throw(SQL, "sql.analyze", SQLSTATE(3F000) "Internal error: No 
table sys.statistics");
-       statsid = mvc_bind_column(m, sysstats, "column_id");
-       if (statsid == NULL)
-               throw(SQL, "sql.analyze", SQLSTATE(3F000) "Internal error: No 
table sys.statistics");
-
+       tr = m->session->tr;
        switch (argc) {
        case 4:
                col = *getArgReference_str(stk, pci, 3);
@@ -142,17 +128,10 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
                                        (void) BATordered_rev(b);
 
                                        /* Check for nils existence */
-                                       if (!c->null) {
-                                               b->tnonil = true;
-                                               b->tnil = false;
-                                       } else {
-                                               (void) BATcount_no_nil(b, NULL);
-                                       }
+                                       (void) BATcount_no_nil(b, NULL);
 
                                        /* Test it column is unique */
-                                       if (is_column_unique(c) && b->tnonil) {
-                                               b->tkey = true;
-                                       } else if ((unq = BATunique(b, NULL)))
+                                       if ((unq = BATunique(b, NULL)))
                                                BBPunfix(unq->batCacheid);
 
                                        /* Guess number of uniques if not 
entirely unique */
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -1411,6 +1411,10 @@ psm_analyze(sql_query *query, dlist *qna
        const char *sname = qname_schema(qname), *tname = 
qname_schema_object(qname);
        list *tl = sa_list(sql->sa), *exps = sa_list(sql->sa), *analyze_calls = 
sa_list(sql->sa);
        sql_subfunc *f = NULL;
+       sql_subtype tpe;
+
+       if (!sql_find_subtype(&tpe, "varchar", 1024, 0))
+               return sql_error(sql, 02, SQLSTATE(HY013) "varchar type 
missing?");
 
        if (sname && tname) {
                sql_table *t = NULL;
@@ -1423,13 +1427,13 @@ psm_analyze(sql_query *query, dlist *qna
        }
        /* call analyze( [schema, [ table ]] ) */
        if (sname) {
-               sql_exp *sname_exp = exp_atom_clob(sql->sa, sname);
+               sql_exp *sname_exp = exp_atom_str(sql->sa, sname, &tpe);
 
                list_append(exps, sname_exp);
                list_append(tl, exp_subtype(sname_exp));
        }
        if (tname) {
-               sql_exp *tname_exp = exp_atom_clob(sql->sa, tname);
+               sql_exp *tname_exp = exp_atom_str(sql->sa, tname, &tpe);
 
                list_append(exps, tname_exp);
                list_append(tl, exp_subtype(tname_exp));
@@ -1453,7 +1457,7 @@ psm_analyze(sql_query *query, dlist *qna
                for(dnode *n = columns->h; n; n = n->next) {
                        const char *cname = n->data.sval;
                        list *nexps = list_dup(exps, NULL);
-                       sql_exp *cname_exp = exp_atom_clob(sql->sa, cname);
+                       sql_exp *cname_exp = exp_atom_str(sql->sa, cname, &tpe);
 
                        list_append(nexps, cname_exp);
                        /* call analyze( opt_minmax, opt_sample_size, sname, 
tname, cname) */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to