Changeset: 5b8a05d35077 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5b8a05d35077
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_project.c
        monetdb5/modules/atoms/batxml.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/kernel/batcolor.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/manifold.c
        sql/backends/monet5/sql_rank.c
        sql/test/BugTracker-2016/Tests/storagemodel.stable.out
Branch: candidate-type
Log Message:

Empty bats have tkey property.


diffs (290 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -87,10 +87,10 @@ BATcreatedesc(oid hseq, int tt, int heap
        bn->hseqbase = hseq;
 
        bn->ttype = tt;
-       bn->tkey = FALSE;
-       bn->tunique = FALSE;
-       bn->tnonil = TRUE;
-       bn->tnil = FALSE;
+       bn->tkey = true;
+       bn->tunique = false;
+       bn->tnonil = true;
+       bn->tnil = false;
        bn->tsorted = bn->trevsorted = ATOMlinear(tt) != 0;
        bn->tident = BATstring_t;
        bn->tseqbase = oid_nil;
@@ -821,8 +821,7 @@ COLcopy(BAT *b, int tt, int writable, in
                BUN h = BUNlast(b);
                bn->tsorted = b->tsorted;
                bn->trevsorted = b->trevsorted;
-               if (b->tkey)
-                       BATkey(bn, true);
+               BATkey(bn, b->tkey);
                bn->tnonil = b->tnonil;
                bn->tnil = b->tnil;
                if (b->tnosorted > 0 && b->tnosorted < h)
diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -756,7 +756,7 @@ BATprojectchain(BAT **bats)
                bn->twidth = b->twidth;
                bn->tshift = b->tshift;
        }
-       bn->tsorted = bn->trevsorted = cnt <= 1;
+       bn->tsorted = bn->trevsorted = bn->tkey = cnt <= 1;
        bn->tseqbase = oid_nil;
        GDKfree(ba);
        if (iscand)
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
@@ -67,6 +67,7 @@ mal_export str AGGRsubxml(bat *retval, c
                (X)->tsorted =  0;                                              
                                        \
                (X)->trevsorted =  0;                                           
                                \
                (X)->tnonil = 1;                                                
                                        \
+               (X)->tkey = 0;                                                  
                                        \
        } while (0)
 
 #define finalizeResult(X,Y,Z)                                  \
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -1708,6 +1708,7 @@ MTIMEtimestamp_create_from_date_bulk(bat
        BATsetcount(bn, BATcount(b));
        bn->tsorted = b->tsorted || BATcount(bn) <= 1;
        bn->trevsorted = b->trevsorted || BATcount(bn) <= 1;
+       bn->tkey = BATcount(bn) <= 1;
        bn->tnonil = !bn->tnil;
        BBPunfix(b->batCacheid);
        *ret = bn->batCacheid;
@@ -1952,6 +1953,7 @@ MTIMEtimestamp_extract_daytime_default_b
        BATsetcount(bn, BATcount(b));
        bn->tsorted = b->tsorted || BATcount(bn) <= 1;
        bn->trevsorted = b->trevsorted || BATcount(bn) <= 1;
+       bn->tkey = BATcount(bn) <= 1;
        bn->tnonil = !bn->tnil;
        BBPunfix(b->batCacheid);
        *ret = bn->batCacheid;
@@ -2027,6 +2029,7 @@ MTIMEtimestamp_extract_date_default_bulk
        BATsetcount(bn, BATcount(b));
        bn->tsorted = b->tsorted || BATcount(bn) <= 1;
        bn->trevsorted = b->trevsorted || BATcount(bn) <= 1;
+       bn->tkey = BATcount(bn) <= 1;
        bn->tnonil = !bn->tnil;
        BBPunfix(b->batCacheid);
        *ret = bn->batCacheid;
@@ -2184,6 +2187,7 @@ MTIMEdate_diff_bulk(bat *ret, const bat 
        BATsetcount(bn, (BUN) (tn - (int *) Tloc(bn, 0)));
        bn->tsorted = BATcount(bn) <= 1;
        bn->trevsorted = BATcount(bn) <= 1;
+       bn->tkey = BATcount(bn) <= 1;
        BBPunfix(b1->batCacheid);
        BBPkeepref(bn->batCacheid);
        *ret = bn->batCacheid;
@@ -2263,6 +2267,7 @@ MTIMEtimestamp_diff_bulk(bat *ret, const
        BATsetcount(bn, (BUN) (tn - (lng *) Tloc(bn, 0)));
        bn->tsorted = BATcount(bn) <= 1;
        bn->trevsorted = BATcount(bn) <= 1;
+       bn->tkey = BATcount(bn) <= 1;
        BBPunfix(b1->batCacheid);
        BBPkeepref(bn->batCacheid);
        *ret = bn->batCacheid;
@@ -2667,6 +2672,7 @@ MTIMEsecs2daytime_bulk(bat *ret, bat *bi
        bn->tsorted = b->tsorted || BATcount(bn) <= 1;
        bn->trevsorted = b->trevsorted || BATcount(bn) <= 1;
        bn->tnonil = !bn->tnil;
+       bn->tkey = BATcount(bn) <= 1;
        BBPunfix(b->batCacheid);
        *ret = bn->batCacheid;
        BBPkeepref(*ret);
@@ -2783,6 +2789,7 @@ MTIMEepoch_bulk(bat *ret, bat *bid)
        BATsetcount(bn, (BUN) (tn - (lng *) Tloc(bn, 0)));
        bn->tsorted = BATcount(bn) <= 1;
        bn->trevsorted = BATcount(bn) <= 1;
+       bn->tkey = BATcount(bn) <= 1;
        BBPkeepref(bn->batCacheid);
        *ret = bn->batCacheid;
        return msg;
@@ -2863,6 +2870,7 @@ MTIMEtimestamp_bulk(bat *ret, bat *bid)
        bn->tsorted = b->tsorted || BATcount(bn) <= 1;
        bn->trevsorted = b->trevsorted || BATcount(bn) <= 1;
        bn->tnonil = !bn->tnil;
+       bn->tkey = BATcount(bn) <= 1;
        BBPunfix(b->batCacheid);
        *ret = bn->batCacheid;
        BBPkeepref(*ret);
@@ -2920,6 +2928,7 @@ MTIMEtimestamp_lng_bulk(bat *ret, bat *b
        bn->tsorted = b->tsorted || BATcount(bn) <= 1;
        bn->trevsorted = b->trevsorted || BATcount(bn) <= 1;
        bn->tnonil = !bn->tnil;
+       bn->tkey = BATcount(bn) <= 1;
        BBPunfix(b->batCacheid);
        *ret = bn->batCacheid;
        BBPkeepref(*ret);
@@ -3220,6 +3229,7 @@ MTIMEdate_extract_year_bulk(bat *ret, co
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3266,6 +3276,7 @@ MTIMEdate_extract_quarter_bulk(bat *ret,
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3312,6 +3323,7 @@ MTIMEdate_extract_month_bulk(bat *ret, c
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3359,6 +3371,7 @@ MTIMEdate_extract_day_bulk(bat *ret, con
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3405,6 +3418,7 @@ MTIMEdaytime_extract_hours_bulk(bat *ret
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3451,6 +3465,7 @@ MTIMEdaytime_extract_minutes_bulk(bat *r
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3497,6 +3512,7 @@ MTIMEdaytime_extract_seconds_bulk(bat *r
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3544,6 +3560,7 @@ MTIMEdaytime_extract_sql_seconds_bulk(ba
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
@@ -3590,6 +3607,7 @@ MTIMEdaytime_extract_milliseconds_bulk(b
        bn->tnonil = !bn->tnil;
        bn->tsorted = BATcount(bn) < 2;
        bn->trevsorted = BATcount(bn) < 2;
+       bn->tkey = BATcount(bn) <= 1;
 
        BBPkeepref(*ret = bn->batCacheid);
        BBPunfix(b->batCacheid);
diff --git a/monetdb5/modules/kernel/batcolor.c 
b/monetdb5/modules/kernel/batcolor.c
--- a/monetdb5/modules/kernel/batcolor.c
+++ b/monetdb5/modules/kernel/batcolor.c
@@ -41,6 +41,7 @@ str CLRbat##NAME(bat *ret, const bat *l)
        bn->trevsorted=0;                                                       
                                                \
        bn->tnil = 0;                                                           
                                                \
        bn->tnonil = 1;                                                         
                                                \
+       bn->tkey = 0;                                                           
                                                \
                                                                                
                                                                \
        bi = bat_iterator(b);                                                   
                                        \
                                                                                
                                                                \
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -98,7 +98,8 @@ mal_export str STRbatsubstring(bat *ret,
                throw(MAL, Z, SQLSTATE(HY001) MAL_MALLOC_FAIL); \
        }                                                                       
                                \
        X->tsorted=0;                                                           
                \
-       X->trevsorted=0;
+       X->trevsorted=0;                                                        
                \
+       X->tkey=0;
 #define prepareResult2(X,Y,A,T,Z)                                              
\
        X= COLnew((Y)->hseqbase,T,BATcount(Y), TRANSIENT);      \
        if( X == NULL){                                                         
                \
@@ -107,7 +108,8 @@ mal_export str STRbatsubstring(bat *ret,
                throw(MAL, Z, SQLSTATE(HY001) MAL_MALLOC_FAIL); \
        }                                                                       
                                \
        X->tsorted=0;                                                           
                \
-       X->trevsorted=0;
+       X->trevsorted=0;                                                        
                \
+       X->tkey=0;
 #define finalizeResult(X,Y,Z)                                                  
        \
        *X = (Y)->batCacheid;                                                   
                \
        BBPkeepref(*(X));                                                       
                        \
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -333,6 +333,7 @@ MANIFOLDevaluate(Client cntxt, MalBlkPtr
                goto wrapup;
        }
        mat[0].b->tnonil=0;
+       mat[0].b->tkey=0;
        mat[0].b->tsorted=0;
        mat[0].b->trevsorted=0;
        mat[0].bi = bat_iterator(mat[0].b);
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -19,6 +19,7 @@
                r->tsorted = 0;                                 \
                r->trevsorted = 0;                              \
                r->tnonil = 1;                                  \
+               r->tkey = 0;                                    \
        } while (0)
 
 str 
diff --git a/sql/test/BugTracker-2016/Tests/storagemodel.stable.out 
b/sql/test/BugTracker-2016/Tests/storagemodel.stable.out
--- a/sql/test/BugTracker-2016/Tests/storagemodel.stable.out
+++ b/sql/test/BugTracker-2016/Tests/storagemodel.stable.out
@@ -67,7 +67,7 @@ Ready.
 
 #create table bug3923(i integer);
 #select "schema", "table", "column", "type", "mode", case when typewidth < 14 
then typewidth else 99 end as typewidth, hashes, phash, imprints from 
storage('sys','_tables');
-% .L3, .L3,    .L3,    .L3,    .L3,    .L3,    .L3,    .L3,    .L3 # table_name
+% .L3, .L3,    .L3,    .L3,    .L3,    .L12,   .L3,    .L3,    .L3 # table_name
 % schema,      table,  column, type,   mode,   typewidth,      hashes, phash,  
imprints # name
 % clob,        clob,   clob,   clob,   clob,   int,    bigint, boolean,        
bigint # type
 % 3,   7,      13,     8,      8,      2,      1,      5,      1 # length
@@ -88,11 +88,11 @@ Ready.
 % schema,      table,  column, type,   count,  columnsize,     heapsize,       
hashes, imprints,       sorted, revsorted,      unique, orderidx # name
 % clob,        clob,   clob,   clob,   bigint, bigint, bigint, bigint, bigint, 
boolean,        boolean,        boolean,        bigint # type
 % 3,   7,      1,      3,      5,      5,      1,      1,      4,      5,      
5,      5,      1 # length
-[ "sys",       "bug3923",      "i",    "int",  10000,  40000,  0,      0,      
1200,   true,   true,   NULL,   0       ]
+[ "sys",       "bug3923",      "i",    "int",  10000,  40000,  0,      0,      
1200,   true,   true,   true,   0       ]
 #drop table bug3923;
 #create table bug3923(i integer);
-#select "schema", "table", "column", "type", "mode", case when typewidth < 14 
then typewidth else 99 end as typewidth, hashes, phash, imprints from 
storage('sys','_tables');
-% .L3, .L3,    .L3,    .L3,    .L3,    .L3,    .L3,    .L3,    .L3 # table_name
+#select "schema", "table", "column", "type", "mode", case when typewidth < 14 
then typewidth else 99 end as typewidth, hashes, phash, imprints from 
sys.storage('sys','_tables');
+% .L3, .L3,    .L3,    .L3,    .L3,    .L12,   .L3,    .L3,    .L3 # table_name
 % schema,      table,  column, type,   mode,   typewidth,      hashes, phash,  
imprints # name
 % clob,        clob,   clob,   clob,   clob,   int,    bigint, boolean,        
bigint # type
 % 3,   7,      13,     8,      8,      2,      1,      5,      1 # length
@@ -113,7 +113,7 @@ Ready.
 % schema,      table,  column, type,   count,  columnsize,     heapsize,       
hashes, imprints,       sorted, revsorted,      unique, orderidx # name
 % clob,        clob,   clob,   clob,   bigint, bigint, bigint, bigint, bigint, 
boolean,        boolean,        boolean,        bigint # type
 % 13,  7,      1,      3,      5,      5,      1,      1,      4,      5,      
5,      5,      1 # length
-[ "bug3923schema",     "bug3923",      "i",    "int",  10000,  40000,  0,      
0,      1200,   true,   true,   NULL,   0       ]
+[ "bug3923schema",     "bug3923",      "i",    "int",  10000,  40000,  0,      
0,      1200,   true,   true,   true,   0       ]
 #drop table bug3923;
 
 # 23:38:44 >  
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to