Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed serious bug in handling NUMERIC values (proper copy of the data).

  • Loading branch information...
commit a57b428a7093b89db0d320bb052c28815d5e9caa 1 parent b80540b
@tvondra authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/quantile.c
View
6 src/quantile.c
@@ -12,6 +12,7 @@
#include <limits.h>
#include "postgres.h"
+#include "utils/datum.h"
#include "utils/array.h"
#include "utils/lsyscache.h"
#include "utils/numeric.h"
@@ -413,7 +414,8 @@ quantile_append_numeric(PG_FUNCTION_ARGS)
data->nelements = data->nelements + SLICE_SIZE;
}
- data->elements[data->next++] = element;
+ /* the value has to be copied (it's reused) */
+ data->elements[data->next++] = DatumGetNumeric(datumCopy(NumericGetDatum(element), false, -1));
}
@@ -459,7 +461,7 @@ quantile_append_numeric_array(PG_FUNCTION_ARGS)
data->nelements = data->nelements + SLICE_SIZE;
}
- data->elements[data->next++] = element;
+ data->elements[data->next++] = DatumGetNumeric(datumCopy(NumericGetDatum(element), false, -1));
}
Please sign in to comment.
Something went wrong with that request. Please try again.