Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc86c76

Browse files
committed
call fill_type_cmp_fmgr_info() in handle_binary_opexpr() only for RANGE part. cases, improve fill_type_cmp_fmgr_info()
1 parent010bf7e commitdc86c76

File tree

4 files changed

+58
-14
lines changed

4 files changed

+58
-14
lines changed

‎expected/pathman_basic.out

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,30 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.sql_inline_func(1);
11141114
DROP FUNCTION test.sql_inline_func(int);
11151115
DROP TABLE test.sql_inline CASCADE;
11161116
NOTICE: drop cascades to 3 other objects
1117+
/*
1118+
* Test by @baiyinqiqi (issue #60)
1119+
*/
1120+
CREATE TABLE test.hash_varchar(val VARCHAR(40) NOT NULL);
1121+
INSERT INTO test.hash_varchar SELECT generate_series(1, 20);
1122+
SELECT pathman.create_hash_partitions('test.hash_varchar', 'val', 4);
1123+
create_hash_partitions
1124+
------------------------
1125+
4
1126+
(1 row)
1127+
1128+
SELECT * FROM test.hash_varchar WHERE val = 'a';
1129+
val
1130+
-----
1131+
(0 rows)
1132+
1133+
SELECT * FROM test.hash_varchar WHERE val = '12'::TEXT;
1134+
val
1135+
-----
1136+
12
1137+
(1 row)
1138+
1139+
DROP TABLE test.hash_varchar CASCADE;
1140+
NOTICE: drop cascades to 4 other objects
11171141
/*
11181142
* Test CTE query
11191143
*/

‎sql/pathman_basic.sql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.sql_inline_func(1);
280280
DROPFUNCTIONtest.sql_inline_func(int);
281281
DROPTABLEtest.sql_inline CASCADE;
282282

283+
/*
284+
* Test by @baiyinqiqi (issue #60)
285+
*/
286+
CREATETABLEtest.hash_varchar(valVARCHAR(40)NOT NULL);
287+
INSERT INTOtest.hash_varcharSELECT generate_series(1,20);
288+
289+
SELECTpathman.create_hash_partitions('test.hash_varchar','val',4);
290+
SELECT*FROMtest.hash_varcharWHERE val='a';
291+
SELECT*FROMtest.hash_varcharWHERE val='12'::TEXT;
292+
293+
DROPTABLEtest.hash_varchar CASCADE;
294+
283295
/*
284296
* Test CTE query
285297
*/
@@ -291,7 +303,6 @@ EXPLAIN (COSTS OFF)
291303
WITH tttAS (SELECT*FROMtest.hash_relWHERE value=2)
292304
SELECT*FROM ttt;
293305

294-
295306
/*
296307
* Test CTE query - by @parihaaraka (add varno to WalkerContext)
297308
*/

‎src/pg_pathman.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
704704
{
705705
intstrategy;
706706
TypeCacheEntry*tce;
707-
FmgrInfocmp_func;
708707
Oidvartype;
709708
constOpExpr*expr= (constOpExpr*)result->orig;
710709
constPartRelationInfo*prel=context->prel;
@@ -730,10 +729,6 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
730729
if (strategy==0)
731730
gotobinary_opexpr_return;
732731

733-
fill_type_cmp_fmgr_info(&cmp_func,
734-
getBaseType(c->consttype),
735-
getBaseType(prel->atttype));
736-
737732
switch (prel->parttype)
738733
{
739734
casePT_HASH:
@@ -754,6 +749,12 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
754749

755750
casePT_RANGE:
756751
{
752+
FmgrInfocmp_func;
753+
754+
fill_type_cmp_fmgr_info(&cmp_func,
755+
getBaseType(c->consttype),
756+
getBaseType(prel->atttype));
757+
757758
select_range_partitions(c->constvalue,
758759
&cmp_func,
759760
PrelGetRangesArray(context->prel),

‎src/utils.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,36 @@ void
6464
fill_type_cmp_fmgr_info(FmgrInfo*finfo,Oidtype1,Oidtype2)
6565
{
6666
Oidcmp_proc_oid;
67-
TypeCacheEntry*tce;
67+
TypeCacheEntry*tce_1,
68+
*tce_2;
6869

6970
if (IsBinaryCoercible(type1,type2))
7071
type1=type2;
7172

7273
elseif (IsBinaryCoercible(type2,type1))
7374
type2=type1;
7475

75-
tce=lookup_type_cache(type1,TYPECACHE_BTREE_OPFAMILY);
76+
tce_1=lookup_type_cache(type1,TYPECACHE_BTREE_OPFAMILY);
77+
tce_2=lookup_type_cache(type2,TYPECACHE_BTREE_OPFAMILY);
7678

77-
cmp_proc_oid=get_opfamily_proc(tce->btree_opf,
78-
type1,
79-
type2,
79+
if (tce_1->btree_opf!=tce_2->btree_opf)
80+
gotofill_type_cmp_fmgr_info_error;
81+
82+
cmp_proc_oid=get_opfamily_proc(tce_1->btree_opf,
83+
tce_1->btree_opintype,
84+
tce_2->btree_opintype,
8085
BTORDER_PROC);
8186

8287
if (cmp_proc_oid==InvalidOid)
83-
elog(ERROR,"missing comparison function for types %s & %s",
84-
format_type_be(type1),format_type_be(type2));
88+
gotofill_type_cmp_fmgr_info_error;
8589

8690
fmgr_info(cmp_proc_oid,finfo);
8791

88-
return;
92+
return;/* exit safely */
93+
94+
fill_type_cmp_fmgr_info_error:
95+
elog(ERROR,"missing comparison function for types %s & %s",
96+
format_type_be(type1),format_type_be(type2));
8997
}
9098

9199
List*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp