mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
Fix problems with partitioning logic for padded fields
Padded fields such as character(20) did not work correctly before because of differences between type output and coercion/casting.
This commit is contained in:
parent
10f486fa5a
commit
f2b42ebe0e
@ -4,6 +4,7 @@
|
||||
#include <catalog/namespace.h>
|
||||
#include <catalog/pg_type.h>
|
||||
#include <access/hash.h>
|
||||
#include <parser/parse_coerce.h>
|
||||
|
||||
#include "partitioning.h"
|
||||
#include "metadata_queries.h"
|
||||
@ -32,10 +33,20 @@ partitioning_info_set_textfunc_fmgr(PartitioningInfo *pi, Oid relid)
|
||||
Oid type_id,
|
||||
func_id;
|
||||
bool isVarlena;
|
||||
CoercionPathType cpt;
|
||||
|
||||
pi->column_attnum = get_attnum(relid, pi->column);
|
||||
type_id = get_atttype(relid, pi->column_attnum);
|
||||
getTypeOutputInfo(type_id, &func_id, &isVarlena);
|
||||
|
||||
/*
|
||||
* First look for an explicit cast type. Needed since the output of for
|
||||
* example character(20) not the same as character(20)::text
|
||||
*/
|
||||
cpt = find_coercion_pathway(TEXTOID, type_id, COERCION_EXPLICIT, &func_id);
|
||||
if (cpt != COERCION_PATH_FUNC)
|
||||
{
|
||||
getTypeOutputInfo(type_id, &func_id, &isVarlena);
|
||||
}
|
||||
fmgr_info_cxt(func_id, &pi->partfunc.textfunc_fmgr, CurrentMemoryContext);
|
||||
}
|
||||
|
||||
|
@ -459,3 +459,21 @@ SELECT * FROM error_test;
|
||||
Mon Mar 20 09:18:25.7 2017 | 22.4 | dev2
|
||||
(2 rows)
|
||||
|
||||
--test character(9) partition keys since there were issues with padding causing partitioning errors
|
||||
CREATE TABLE tick_character (
|
||||
symbol character(9) NOT NULL, mid REAL NOT NULL, spread REAL NOT NULL,
|
||||
time TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
SELECT create_hypertable ('tick_character', 'time', 'symbol', 2);
|
||||
create_hypertable
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO tick_character ( symbol, mid, spread, time ) VALUES ( 'GBPJPY', 142.639000, 5.80, 'Mon Mar 20 09:18:22.3 2017');
|
||||
SELECT * FROM tick_character;
|
||||
symbol | mid | spread | time
|
||||
-----------+---------+--------+--------------------------------
|
||||
GBPJPY | 142.639 | 5.8 | Mon Mar 20 09:18:22.3 2017 PDT
|
||||
(1 row)
|
||||
|
||||
|
@ -20,3 +20,14 @@ INSERT INTO error_test VALUES ('Mon Mar 20 09:18:22.3 2017', 21.1, NULL);
|
||||
\set ON_ERROR_STOP 1
|
||||
INSERT INTO error_test VALUES ('Mon Mar 20 09:18:25.7 2017', 22.4, 'dev2');
|
||||
SELECT * FROM error_test;
|
||||
|
||||
--test character(9) partition keys since there were issues with padding causing partitioning errors
|
||||
CREATE TABLE tick_character (
|
||||
symbol character(9) NOT NULL, mid REAL NOT NULL, spread REAL NOT NULL,
|
||||
time TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
|
||||
SELECT create_hypertable ('tick_character', 'time', 'symbol', 2);
|
||||
INSERT INTO tick_character ( symbol, mid, spread, time ) VALUES ( 'GBPJPY', 142.639000, 5.80, 'Mon Mar 20 09:18:22.3 2017');
|
||||
SELECT * FROM tick_character;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user