mirror of https://github.com/citusdata/citus.git
Fix treating same numeric value differently in citus_stat_tenants bug
parent
a5f4fece13
commit
927843be7d
|
@ -29,6 +29,7 @@
|
|||
#include "utils/builtins.h"
|
||||
#include "utils/datetime.h"
|
||||
#include "utils/json.h"
|
||||
#include "utils/numeric.h"
|
||||
|
||||
|
||||
#include <time.h>
|
||||
|
@ -245,8 +246,22 @@ AnnotateQuery(char *queryString, Const *partitionKeyValue, int colocationId)
|
|||
return queryString;
|
||||
}
|
||||
|
||||
char *partitionKeyValueString = DatumToString(partitionKeyValue->constvalue,
|
||||
partitionKeyValue->consttype);
|
||||
char *partitionKeyValueString = NULL;
|
||||
|
||||
/*
|
||||
* We need to normalize the numeric values to avoid the difference between
|
||||
* different number of trailing zeros.
|
||||
*/
|
||||
if (partitionKeyValue->consttype == NUMERICOID)
|
||||
{
|
||||
Numeric num = DatumGetNumeric(partitionKeyValue->constvalue);
|
||||
partitionKeyValueString = numeric_normalize(num);
|
||||
}
|
||||
else
|
||||
{
|
||||
partitionKeyValueString = DatumToString(partitionKeyValue->constvalue,
|
||||
partitionKeyValue->consttype);
|
||||
}
|
||||
|
||||
char *commentCharsEscaped = EscapeCommentChars(partitionKeyValueString);
|
||||
StringInfo escapedSourceName = makeStringInfo();
|
||||
|
|
|
@ -871,5 +871,30 @@ SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
|||
äbc | 11
|
||||
(2 rows)
|
||||
|
||||
-- test numeric values with different numbers of trailing zeros
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
CREATE TABLE dist_tbl_numeric(a numeric);
|
||||
SELECT create_distributed_table('dist_tbl_numeric', 'a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO dist_tbl_numeric VALUES (1);
|
||||
INSERT INTO dist_tbl_numeric VALUES (1.0);
|
||||
INSERT INTO dist_tbl_numeric VALUES (1.00);
|
||||
INSERT INTO dist_tbl_numeric VALUES (1.000);
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
tenant_attribute | query_count_in_this_period
|
||||
---------------------------------------------------------------------
|
||||
1 | 4
|
||||
(1 row)
|
||||
|
||||
SET client_min_messages TO ERROR;
|
||||
DROP SCHEMA citus_stat_tenants CASCADE;
|
||||
|
|
|
@ -311,5 +311,19 @@ SELECT count(*)>=0 FROM select_from_dist_tbl_text_view WHERE a = U&'\0061\0308bc
|
|||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
|
||||
-- test numeric values with different numbers of trailing zeros
|
||||
SELECT citus_stat_tenants_reset();
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
|
||||
CREATE TABLE dist_tbl_numeric(a numeric);
|
||||
SELECT create_distributed_table('dist_tbl_numeric', 'a');
|
||||
|
||||
INSERT INTO dist_tbl_numeric VALUES (1);
|
||||
INSERT INTO dist_tbl_numeric VALUES (1.0);
|
||||
INSERT INTO dist_tbl_numeric VALUES (1.00);
|
||||
INSERT INTO dist_tbl_numeric VALUES (1.000);
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
|
||||
SET client_min_messages TO ERROR;
|
||||
DROP SCHEMA citus_stat_tenants CASCADE;
|
||||
|
|
Loading…
Reference in New Issue