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

Commit473af39

Browse files
Add missing optimizer hooks for function cost and number of rows.
Closely follow design of other optimizer hooks: if hook existsretrieve value from plugin; if still not set then get from cache.
1 parent491d1ea commit473af39

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

‎src/backend/utils/cache/lsyscache.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.168 2010/02/26 02:01:11 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.169 2010/04/23 22:23:39 sriggs Exp $
1111
*
1212
* NOTES
1313
* Eventually, the index information should go through here, too.
@@ -38,6 +38,9 @@
3838
/* Hook for plugins to get control in get_attavgwidth() */
3939
get_attavgwidth_hook_typeget_attavgwidth_hook=NULL;
4040

41+
/* Hook for plugins to get control in get_func_cost and get_func_rows */
42+
get_func_cost_hook_typeget_func_cost_hook=NULL;
43+
get_func_rows_hook_typeget_func_rows_hook=NULL;
4144

4245
/*---------- AMOP CACHES ---------- */
4346

@@ -1409,6 +1412,12 @@ get_func_cost(Oid funcid)
14091412
HeapTupletp;
14101413
float4result;
14111414

1415+
if (get_func_cost_hook)
1416+
{
1417+
result= (*get_func_cost_hook) (funcid);
1418+
if (result> (float4)0)
1419+
returnresult;
1420+
}
14121421
tp=SearchSysCache1(PROCOID,ObjectIdGetDatum(funcid));
14131422
if (!HeapTupleIsValid(tp))
14141423
elog(ERROR,"cache lookup failed for function %u",funcid);
@@ -1428,6 +1437,12 @@ get_func_rows(Oid funcid)
14281437
HeapTupletp;
14291438
float4result;
14301439

1440+
if (get_func_rows_hook)
1441+
{
1442+
result= (*get_func_rows_hook) (funcid);
1443+
if (result> (float4)0)
1444+
returnresult;
1445+
}
14311446
tp=SearchSysCache1(PROCOID,ObjectIdGetDatum(funcid));
14321447
if (!HeapTupleIsValid(tp))
14331448
elog(ERROR,"cache lookup failed for function %u",funcid);

‎src/include/utils/lsyscache.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.131 2010/01/04 02:44:40 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.132 2010/04/23 22:23:39 sriggs Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -30,6 +30,12 @@ typedef enum IOFuncSelector
3030
typedefint32 (*get_attavgwidth_hook_type) (Oidrelid,AttrNumberattnum);
3131
externPGDLLIMPORTget_attavgwidth_hook_typeget_attavgwidth_hook;
3232

33+
/* Hook for plugins to get control in get_func_cost and get_func_rows */
34+
typedeffloat4 (*get_func_cost_hook_type) (Oidfuncid);
35+
externPGDLLIMPORTget_func_cost_hook_typeget_func_cost_hook;
36+
typedeffloat4 (*get_func_rows_hook_type) (Oidfuncid);
37+
externPGDLLIMPORTget_func_rows_hook_typeget_func_rows_hook;
38+
3339
externboolop_in_opfamily(Oidopno,Oidopfamily);
3440
externintget_op_opfamily_strategy(Oidopno,Oidopfamily);
3541
externvoidget_op_opfamily_properties(Oidopno,Oidopfamily,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp