Skip to content

Commit

Permalink
fix from/to condition to return NULL
Browse files Browse the repository at this point in the history
So far it was (from > to), but (from >= to) seems more appropriate.
  • Loading branch information
tvondra committed Aug 12, 2016
1 parent 84ceada commit 2c54dde
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/trimmed.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ trimmed_avg_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1049,7 +1049,7 @@ trimmed_double_array(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1100,7 +1100,7 @@ trimmed_avg_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -1133,7 +1133,7 @@ trimmed_int32_array(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -1184,7 +1184,7 @@ trimmed_avg_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -1217,7 +1217,7 @@ trimmed_int64_array(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -1267,7 +1267,7 @@ trimmed_avg_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

/* create numeric values */
Expand Down Expand Up @@ -1304,7 +1304,7 @@ trimmed_numeric_array(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

/* create numeric values */
Expand Down Expand Up @@ -1384,7 +1384,7 @@ trimmed_var_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1418,7 +1418,7 @@ trimmed_var_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -1451,7 +1451,7 @@ trimmed_var_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -1483,7 +1483,7 @@ trimmed_var_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

cnt = create_numeric(to - from);
Expand Down Expand Up @@ -1524,7 +1524,7 @@ trimmed_var_pop_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1557,7 +1557,7 @@ trimmed_var_pop_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -1590,7 +1590,7 @@ trimmed_var_pop_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -1622,7 +1622,7 @@ trimmed_var_pop_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

cnt = create_numeric(to - from);
Expand Down Expand Up @@ -1665,7 +1665,7 @@ trimmed_var_samp_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1698,7 +1698,7 @@ trimmed_var_samp_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -1731,7 +1731,7 @@ trimmed_var_samp_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -1763,7 +1763,7 @@ trimmed_var_samp_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

cnt = create_numeric(to - from);
Expand Down Expand Up @@ -1809,7 +1809,7 @@ trimmed_stddev_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1842,7 +1842,7 @@ trimmed_stddev_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -1875,7 +1875,7 @@ trimmed_stddev_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -1907,7 +1907,7 @@ trimmed_stddev_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

cnt = create_numeric(to - from);
Expand Down Expand Up @@ -1948,7 +1948,7 @@ trimmed_stddev_pop_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -1981,7 +1981,7 @@ trimmed_stddev_pop_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -2014,7 +2014,7 @@ trimmed_stddev_pop_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -2046,7 +2046,7 @@ trimmed_stddev_pop_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

cnt = create_numeric(to - from);
Expand Down Expand Up @@ -2090,7 +2090,7 @@ trimmed_stddev_samp_double(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(double), &double_comparator);
Expand Down Expand Up @@ -2123,7 +2123,7 @@ trimmed_stddev_samp_int32(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int32), &int32_comparator);
Expand Down Expand Up @@ -2156,7 +2156,7 @@ trimmed_stddev_samp_int64(PG_FUNCTION_ARGS)
to = data->nelements - floor(data->nelements * data->cut_upper);
cnt = (to - from);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

qsort(data->elements, data->nelements, sizeof(int64), &int64_comparator);
Expand Down Expand Up @@ -2188,7 +2188,7 @@ trimmed_stddev_samp_numeric(PG_FUNCTION_ARGS)
from = floor(data->nelements * data->cut_lower);
to = data->nelements - floor(data->nelements * data->cut_upper);

if (from > to)
if (from >= to)
PG_RETURN_NULL();

cnt = create_numeric(to - from);
Expand Down

0 comments on commit 2c54dde

Please sign in to comment.