Skip to content

Commit 421b2ed

Browse files
committed
improve lookup_type_cache() usage
1 parent c79b3f7 commit 421b2ed

File tree

5 files changed

+10
-38
lines changed

5 files changed

+10
-38
lines changed

range.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,9 @@ BEGIN
11341134
SELECT * INTO schema, relname
11351135
FROM @extschema@.get_plain_schema_and_relname(relation);
11361136

1137-
EXECUTE format('DROP TRIGGER IF EXISTS %s ON %s CASCADE'
1138-
, format('"%s_%s_insert_trigger"', schema, relname)
1139-
, relation::TEXT);
1137+
--EXECUTE format('DROP TRIGGER IF EXISTS %s ON %s CASCADE'
1138+
-- , format('"%s_%s_insert_trigger"', schema, relname)
1139+
-- , relation::TEXT);
11401140
END
11411141
$$ LANGUAGE plpgsql;
11421142

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ load_check_constraints(Oid parent_oid, Snapshot snapshot)
395395
bool byVal = rangerel->by_val;
396396

397397
/* Sort ascending */
398-
tce = lookup_type_cache(prel->atttype, TYPECACHE_CMP_PROC | TYPECACHE_CMP_PROC_FINFO);
398+
tce = lookup_type_cache(prel->atttype, TYPECACHE_CMP_PROC_FINFO);
399399
qsort_type_cmp_func = &tce->cmp_proc_finfo;
400400
globalByVal = byVal;
401401
qsort(ranges, proc, sizeof(RangeEntry), cmp_range_entries);

src/pg_pathman.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,20 +1038,12 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
10381038
strategy;
10391039
TypeCacheEntry *tce;
10401040
FmgrInfo cmp_func;
1041-
Oid cmp_proc_oid;
10421041
const OpExpr *expr = (const OpExpr *) result->orig;
10431042
const PartRelationInfo *prel = context->prel;
10441043

1045-
/* Determine operator type */
1046-
tce = lookup_type_cache(v->vartype,
1047-
TYPECACHE_BTREE_OPFAMILY | TYPECACHE_CMP_PROC | TYPECACHE_CMP_PROC_FINFO);
1048-
1044+
tce = lookup_type_cache(v->vartype, TYPECACHE_BTREE_OPFAMILY);
10491045
strategy = get_op_opfamily_strategy(expr->opno, tce->btree_opf);
1050-
cmp_proc_oid = get_opfamily_proc(tce->btree_opf,
1051-
c->consttype,
1052-
prel->atttype,
1053-
BTORDER_PROC);
1054-
fmgr_info(cmp_proc_oid, &cmp_func);
1046+
fill_type_cmp_fmgr_info(&cmp_func, c->consttype, prel->atttype);
10551047

10561048
switch (prel->parttype)
10571049
{
@@ -1237,23 +1229,16 @@ handle_const(const Const *c, WalkerContext *context)
12371229

12381230
case PT_RANGE:
12391231
{
1240-
Oid cmp_proc_oid;
1241-
FmgrInfo cmp_func;
12421232
TypeCacheEntry *tce;
12431233

1244-
tce = lookup_type_cache(c->consttype, 0);
1245-
cmp_proc_oid = get_opfamily_proc(tce->btree_opf,
1246-
c->consttype,
1247-
c->consttype,
1248-
BTORDER_PROC);
1249-
fmgr_info(cmp_proc_oid, &cmp_func);
1234+
tce = lookup_type_cache(c->consttype, TYPECACHE_CMP_PROC_FINFO);
12501235

12511236
if (!context->ranges)
12521237
refresh_walker_context_ranges(context);
12531238

12541239
select_range_partitions(c->constvalue,
12551240
c->constbyval,
1256-
&cmp_func,
1241+
&tce->cmp_proc_finfo,
12571242
context->ranges,
12581243
context->nranges,
12591244
BTEqualStrategyNumber,

src/pl_funcs.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,18 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
9292
Datum value = PG_GETARG_DATUM(1);
9393
Oid value_type = get_fn_expr_argtype(fcinfo->flinfo, 1);
9494
RangeRelation *rangerel;
95-
TypeCacheEntry *tce;
9695
PartRelationInfo *prel;
97-
Oid cmp_proc_oid;
9896
FmgrInfo cmp_func;
9997
search_rangerel_result search_state;
10098
RangeEntry found_re;
10199

102-
tce = lookup_type_cache(value_type,
103-
TYPECACHE_EQ_OPR | TYPECACHE_LT_OPR | TYPECACHE_GT_OPR |
104-
TYPECACHE_CMP_PROC | TYPECACHE_CMP_PROC_FINFO);
105-
106100
prel = get_pathman_relation_info(relid, NULL);
107101
rangerel = get_pathman_range_relation(relid, NULL);
108102

109103
if (!prel || !rangerel)
110104
PG_RETURN_NULL();
111105

112-
cmp_proc_oid = get_opfamily_proc(tce->btree_opf,
113-
value_type,
114-
prel->atttype,
115-
BTORDER_PROC);
116-
fmgr_info(cmp_proc_oid, &cmp_func);
106+
fill_type_cmp_fmgr_info(&cmp_func, value_type, prel->atttype);
117107

118108
search_state = search_range_partition_eq(value, &cmp_func,
119109
rangerel, &found_re);

src/utils.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,7 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
258258
Oid cmp_proc_oid;
259259
TypeCacheEntry *tce;
260260

261-
tce = lookup_type_cache(type1,
262-
TYPECACHE_BTREE_OPFAMILY |
263-
TYPECACHE_CMP_PROC |
264-
TYPECACHE_CMP_PROC_FINFO);
261+
tce = lookup_type_cache(type1, TYPECACHE_BTREE_OPFAMILY);
265262

266263
cmp_proc_oid = get_opfamily_proc(tce->btree_opf,
267264
type1,

0 commit comments

Comments
 (0)