Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit a57b428a7093b89db0d320bb052c28815d5e9caa 1 parent b80540b
Tomas Vondra authored

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. +4 2 src/quantile.c
6 src/quantile.c
@@ -12,6 +12,7 @@
12 12 #include <limits.h>
13 13
14 14 #include "postgres.h"
  15 +#include "utils/datum.h"
15 16 #include "utils/array.h"
16 17 #include "utils/lsyscache.h"
17 18 #include "utils/numeric.h"
@@ -413,7 +414,8 @@ quantile_append_numeric(PG_FUNCTION_ARGS)
413 414 data->nelements = data->nelements + SLICE_SIZE;
414 415 }
415 416
416   - data->elements[data->next++] = element;
  417 + /* the value has to be copied (it's reused) */
  418 + data->elements[data->next++] = DatumGetNumeric(datumCopy(NumericGetDatum(element), false, -1));
417 419
418 420 }
419 421
@@ -459,7 +461,7 @@ quantile_append_numeric_array(PG_FUNCTION_ARGS)
459 461 data->nelements = data->nelements + SLICE_SIZE;
460 462 }
461 463
462   - data->elements[data->next++] = element;
  464 + data->elements[data->next++] = DatumGetNumeric(datumCopy(NumericGetDatum(element), false, -1));
463 465
464 466 }
465 467

0 comments on commit a57b428

Please sign in to comment.
Something went wrong with that request. Please try again.