Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b50cbbd6
Commit
b50cbbd6
authored
Jun 15, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up memory leakage created by recent changes.
parent
62d45261
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
src/backend/commands/analyze.c
src/backend/commands/analyze.c
+21
-12
No files found.
src/backend/commands/analyze.c
View file @
b50cbbd6
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.3
6 2002/06/13 19:52:02 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.3
7 2002/06/15 22:25:40 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -59,7 +59,7 @@ typedef enum
/*
* We build one of these structs for each attribute (column) that is to be
* analyzed. The struct and subsidiary data are in
TransactionCommandC
ontext,
* analyzed. The struct and subsidiary data are in
anl_c
ontext,
* so they live until the end of the ANALYZE operation.
*/
typedef
struct
...
...
@@ -109,6 +109,8 @@ typedef struct
static
int
elevel
=
-
1
;
static
MemoryContext
anl_context
=
NULL
;
/* context information for compare_scalars() */
static
FmgrInfo
*
datumCmpFn
;
static
SortFunctionKind
datumCmpFnKind
;
...
...
@@ -155,6 +157,13 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
else
elevel
=
DEBUG1
;
/*
* Use the current context for storing analysis info. vacuum.c ensures
* that this context will be cleared when I return, thus releasing the
* memory allocated here.
*/
anl_context
=
CurrentMemoryContext
;
/*
* Check for user-requested abort. Note we want this to be inside a
* transaction, so xact.c doesn't issue useless WARNING.
...
...
@@ -306,14 +315,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
* Compute the statistics. Temporary results during the calculations
* for each column are stored in a child context. The calc routines
* are responsible to make sure that whatever they store into the
* VacAttrStats structure is allocated in
TransactionCommandC
ontext.
* VacAttrStats structure is allocated in
anl_c
ontext.
*/
if
(
numrows
>
0
)
{
MemoryContext
col_context
,
old_context
;
col_context
=
AllocSetContextCreate
(
CurrentMemoryC
ontext
,
col_context
=
AllocSetContextCreate
(
anl_c
ontext
,
"Analyze Column"
,
ALLOCSET_DEFAULT_MINSIZE
,
ALLOCSET_DEFAULT_INITSIZE
,
...
...
@@ -1094,8 +1103,8 @@ compute_minimal_stats(VacAttrStats *stats,
Datum
*
mcv_values
;
float4
*
mcv_freqs
;
/* Must copy the target values into
TransactionCommandC
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
mcv_values
=
(
Datum
*
)
palloc
(
num_mcv
*
sizeof
(
Datum
));
mcv_freqs
=
(
float4
*
)
palloc
(
num_mcv
*
sizeof
(
float4
));
for
(
i
=
0
;
i
<
num_mcv
;
i
++
)
...
...
@@ -1415,8 +1424,8 @@ compute_scalar_stats(VacAttrStats *stats,
Datum
*
mcv_values
;
float4
*
mcv_freqs
;
/* Must copy the target values into
TransactionCommandC
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
mcv_values
=
(
Datum
*
)
palloc
(
num_mcv
*
sizeof
(
Datum
));
mcv_freqs
=
(
float4
*
)
palloc
(
num_mcv
*
sizeof
(
float4
));
for
(
i
=
0
;
i
<
num_mcv
;
i
++
)
...
...
@@ -1501,8 +1510,8 @@ compute_scalar_stats(VacAttrStats *stats,
nvals
=
values_cnt
;
Assert
(
nvals
>=
num_hist
);
/* Must copy the target values into
TransactionCommandC
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
hist_values
=
(
Datum
*
)
palloc
(
num_hist
*
sizeof
(
Datum
));
for
(
i
=
0
;
i
<
num_hist
;
i
++
)
{
...
...
@@ -1530,8 +1539,8 @@ compute_scalar_stats(VacAttrStats *stats,
double
corr_xsum
,
corr_x2sum
;
/* Must copy the target values into
TransactionCommandC
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
corrs
=
(
float4
*
)
palloc
(
sizeof
(
float4
));
MemoryContextSwitchTo
(
old_context
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment