Permalink
Browse files

Extension of the previous commit - proper passing of 64-bit values fr…

…om the SRF.
  • Loading branch information...
1 parent 36fa551 commit 862f989e798cb0732c6ad3e0000e641970d85510 @tvondra committed Nov 3, 2011
Showing with 6 additions and 6 deletions.
  1. +2 −2 query_histogram--1.0.sql
  2. +2 −2 query_histogram.c
  3. +2 −2 queryhist.h
View
4 query_histogram--1.0.sql
@@ -1,5 +1,5 @@
-CREATE OR REPLACE FUNCTION query_histogram( IN scale BOOLEAN DEFAULT TRUE, OUT bin_from INT, OUT bin_to INT, OUT bin_count INT, OUT bin_count_pct REAL,
- OUT bin_time REAL, OUT bin_time_pct REAL)
+CREATE OR REPLACE FUNCTION query_histogram( IN scale BOOLEAN DEFAULT TRUE, OUT bin_from INT, OUT bin_to INT, OUT bin_count BIGINT, OUT bin_count_pct REAL,
+ OUT bin_time DOUBLE PRECISION, OUT bin_time_pct REAL)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'query_histogram'
LANGUAGE C IMMUTABLE;
View
4 query_histogram.c
@@ -115,15 +115,15 @@ query_histogram(PG_FUNCTION_ARGS)
}
- values[2] = UInt32GetDatum(data->count_data[binIdx]);
+ values[2] = Int64GetDatum(data->count_data[binIdx]);
if (data->total_count > 0) {
values[3] = Float4GetDatum(100.0*data->count_data[binIdx] / data->total_count);
} else {
values[3] = Float4GetDatum(0);
}
- values[4] = Float4GetDatum(data->time_data[binIdx]);
+ values[4] = Float8GetDatum(data->time_data[binIdx]);
if (data->total_time > 0) {
values[5] = Float4GetDatum(100*data->time_data[binIdx] / data->total_time);
View
4 queryhist.h
@@ -16,8 +16,8 @@ typedef enum {
} histogram_type_t;
/* data types used to store queries */
-typedef unsigned long long count_bin_t;
-typedef float8 time_bin_t;
+typedef long long count_bin_t;
+typedef float8 time_bin_t;
/* used to transfer the data to the SRF */
typedef struct histogram_data {

0 comments on commit 862f989

Please sign in to comment.