Skip to content

Commit cd7206b

Browse files
committed
Enable to set _cpu_page_wight_ & _cpu_index_page_wight_ via
SET cost_heap(cost_index) TO ...
1 parent 0a08f2b commit cd7206b

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

src/backend/tcop/variable.c

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Routines for handling of 'SET var TO', 'SHOW var' and 'RESET var'
33
* statements.
44
*
5-
* $Id: variable.c,v 1.5 1997/04/23 06:09:36 vadim Exp $
5+
* $Id: variable.c,v 1.6 1997/04/24 15:41:37 vadim Exp $
66
*
77
*/
88

@@ -11,6 +11,11 @@
1111
#include "postgres.h"
1212
#include "miscadmin.h"
1313
#include "tcop/variable.h"
14+
#include "utils/builtins.h"
15+
#include "optimizer/internal.h"
16+
17+
extern Cost _cpu_page_wight_;
18+
extern Cost _cpu_index_page_wight_;
1419

1520
/*-----------------------------------------------------------------------*/
1621
#if USE_EURODATES
@@ -64,6 +69,50 @@ static bool reset_null(const char *value)
6469
return TRUE;
6570
}
6671

72+
static bool parse_cost_heap (const char *value)
73+
{
74+
float32 res = float4in ((char*)value);
75+
76+
_cpu_page_wight_ = *res;
77+
78+
return TRUE;
79+
}
80+
81+
static bool show_cost_heap ()
82+
{
83+
84+
elog (NOTICE, "COST_HEAP is %f", _cpu_page_wight_);
85+
return TRUE;
86+
}
87+
88+
static bool reset_cost_heap ()
89+
{
90+
_cpu_page_wight_ = _CPU_PAGE_WEIGHT_;
91+
return TRUE;
92+
}
93+
94+
static bool parse_cost_index (const char *value)
95+
{
96+
float32 res = float4in ((char*)value);
97+
98+
_cpu_index_page_wight_ = *res;
99+
100+
return TRUE;
101+
}
102+
103+
static bool show_cost_index ()
104+
{
105+
106+
elog (NOTICE, "COST_INDEX is %f", _cpu_index_page_wight_);
107+
return TRUE;
108+
}
109+
110+
static bool reset_cost_index ()
111+
{
112+
_cpu_index_page_wight_ = _CPU_INDEX_PAGE_WEIGHT_;
113+
return TRUE;
114+
}
115+
67116
static bool parse_date(const char *value)
68117
{
69118
char tok[32];
@@ -149,6 +198,10 @@ struct VariableParsers
149198
{
150199
{ "datestyle", parse_date, show_date, reset_date },
151200
{ "timezone", parse_null, show_null, reset_null },
201+
{ "cost_heap", parse_cost_heap,
202+
show_cost_heap, reset_cost_heap },
203+
{ "cost_index", parse_cost_index,
204+
show_cost_index, reset_cost_index },
152205
{ NULL, NULL, NULL }
153206
};
154207

0 commit comments

Comments
 (0)