Changeset: 7b36483311ee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7b36483311ee
Modified Files:
sql/server/sql_atom.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: Nov2019
Log Message:
The negation of a NULL atom is NULL
diffs (156 lines):
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -611,7 +611,7 @@ atom_num_digits( atom *a )
#endif
unsigned int inlen = 1;
- switch(a->tpe.type->localtype) {
+ switch (a->tpe.type->localtype) {
case TYPE_bte:
v = a->data.val.btval;
break;
@@ -659,7 +659,7 @@ atom_cast(sql_allocator *sa, atom *a, sq
if (at->type->eclass == EC_NUM && tp->type->eclass == EC_NUM &&
at->type->localtype <= tp->type->localtype) {
/* cast numerics */
- switch( tp->type->localtype) {
+ switch ( tp->type->localtype) {
case TYPE_bte:
if (at->type->localtype != TYPE_bte)
return 0;
@@ -725,7 +725,7 @@ atom_cast(sql_allocator *sa, atom *a, sq
lng mul = 1, div = 0, rnd = 0;
#endif
/* cast numerics */
- switch( tp->type->localtype) {
+ switch (tp->type->localtype) {
case TYPE_bte:
if (at->type->localtype != TYPE_bte)
return 0;
@@ -983,7 +983,7 @@ atom_cast(sql_allocator *sa, atom *a, sq
lng mul = 1;
#endif
/* cast numerics */
- switch( tp->type->localtype) {
+ switch (tp->type->localtype) {
case TYPE_bte:
if (at->type->localtype != TYPE_bte)
return 0;
@@ -1099,7 +1099,7 @@ atom_cast(sql_allocator *sa, atom *a, sq
size_t len = 0;
ssize_t res = 0;
/* cast decimals to doubles */
- switch( at->type->localtype) {
+ switch (at->type->localtype) {
case TYPE_bte:
dec = a->data.val.btval;
break;
@@ -1168,9 +1168,11 @@ atom_cast(sql_allocator *sa, atom *a, sq
}
int
-atom_neg( atom *a )
+atom_neg(atom *a)
{
ValRecord dst;
+ if (a->isnull)
+ return 0;
dst.vtype = a->data.vtype;
if (VARcalcnegate(&dst, &a->data) != GDK_SUCCEED)
return -1;
@@ -1200,9 +1202,8 @@ atom_add(atom *a1, atom *a2)
{
ValRecord dst;
- if ((!EC_COMPUTE(a1->tpe.type->eclass) && (a1->tpe.type->eclass !=
EC_DEC || a1->tpe.digits != a2->tpe.digits || a1->tpe.scale != a2->tpe.scale))
|| a1->tpe.digits < a2->tpe.digits || a1->tpe.type->localtype !=
a2->tpe.type->localtype) {
+ if ((!EC_COMPUTE(a1->tpe.type->eclass) && (a1->tpe.type->eclass !=
EC_DEC || a1->tpe.digits != a2->tpe.digits || a1->tpe.scale != a2->tpe.scale))
|| a1->tpe.digits < a2->tpe.digits || a1->tpe.type->localtype !=
a2->tpe.type->localtype)
return NULL;
- }
if (a1->tpe.type->localtype < a2->tpe.type->localtype ||
(a1->tpe.type->localtype == a2->tpe.type->localtype &&
a1->tpe.digits < a2->tpe.digits)) {
@@ -1227,9 +1228,8 @@ atom_sub(atom *a1, atom *a2)
{
ValRecord dst;
- if ((!EC_COMPUTE(a1->tpe.type->eclass) && (a1->tpe.type->eclass !=
EC_DEC || a1->tpe.digits != a2->tpe.digits || a1->tpe.scale != a2->tpe.scale))
|| a1->tpe.digits < a2->tpe.digits || a1->tpe.type->localtype !=
a2->tpe.type->localtype) {
+ if ((!EC_COMPUTE(a1->tpe.type->eclass) && (a1->tpe.type->eclass !=
EC_DEC || a1->tpe.digits != a2->tpe.digits || a1->tpe.scale != a2->tpe.scale))
|| a1->tpe.digits < a2->tpe.digits || a1->tpe.type->localtype !=
a2->tpe.type->localtype)
return NULL;
- }
if (a1->tpe.type->localtype < a2->tpe.type->localtype ||
(a1->tpe.type->localtype == a2->tpe.type->localtype &&
a1->tpe.digits < a2->tpe.digits))
@@ -1297,7 +1297,7 @@ atom_mul(atom *a1, atom *a2)
}
int
-atom_inc( atom *a )
+atom_inc(atom *a)
{
ValRecord dst;
@@ -1314,11 +1314,11 @@ atom_inc( atom *a )
}
int
-atom_is_zero( atom *a )
+atom_is_zero(atom *a)
{
if (a->isnull)
return 0;
- switch(a->tpe.type->localtype) {
+ switch (a->tpe.type->localtype) {
case TYPE_bte:
return a->data.val.btval == 0;
case TYPE_sht:
@@ -1342,11 +1342,11 @@ atom_is_zero( atom *a )
}
int
-atom_is_true( atom *a )
+atom_is_true(atom *a)
{
if (a->isnull)
return 0;
- switch(a->tpe.type->localtype) {
+ switch (a->tpe.type->localtype) {
case TYPE_bit:
return a->data.val.btval != 0;
case TYPE_bte:
@@ -1451,7 +1451,7 @@ atom_zero_value(sql_allocator *sa, sql_s
break;
} //no support for strings and blobs zero value
- if(ret != NULL) {
+ if (ret != NULL) {
res = atom_create(sa);
res->tpe = *tpe;
res->isnull = 0;
diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -14,6 +14,7 @@ select cast(sum(42) as bigint) having 42
select 1 having false;
select 1 having true;
+select -NULL;
create table x (x interval second, y interval month);
insert into x values (1, 1);
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.out
b/sql/test/miscellaneous/Tests/simple_selects.stable.out
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.out
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.out
@@ -143,6 +143,12 @@ stdout of test 'simple_selects` in direc
% tinyint # type
% 1 # length
[ 1 ]
+#select -NULL;
+% .L2 # table_name
+% L2 # name
+% char # type
+% 0 # length
+[ NULL ]
#create table x (x interval second, y interval month);
#insert into x values (1, 1);
[ 1 ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list