Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
b50cbbd6
Commit
b50cbbd6
authored
23 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Fix up memory leakage created by recent changes.
parent
62d45261
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/commands/analyze.c
+21
-12
21 additions, 12 deletions
src/backend/commands/analyze.c
with
21 additions
and
12 deletions
src/backend/commands/analyze.c
+
21
−
12
View file @
b50cbbd6
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.3
6
2002/06/1
3 19:52:02 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.3
7
2002/06/1
5 22:25:40 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -59,7 +59,7 @@ typedef enum
...
@@ -59,7 +59,7 @@ typedef enum
/*
/*
* We build one of these structs for each attribute (column) that is to be
* 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.
* so they live until the end of the ANALYZE operation.
*/
*/
typedef
struct
typedef
struct
...
@@ -109,6 +109,8 @@ typedef struct
...
@@ -109,6 +109,8 @@ typedef struct
static
int
elevel
=
-
1
;
static
int
elevel
=
-
1
;
static
MemoryContext
anl_context
=
NULL
;
/* context information for compare_scalars() */
/* context information for compare_scalars() */
static
FmgrInfo
*
datumCmpFn
;
static
FmgrInfo
*
datumCmpFn
;
static
SortFunctionKind
datumCmpFnKind
;
static
SortFunctionKind
datumCmpFnKind
;
...
@@ -155,6 +157,13 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
...
@@ -155,6 +157,13 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
else
else
elevel
=
DEBUG1
;
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
* Check for user-requested abort. Note we want this to be inside a
* transaction, so xact.c doesn't issue useless WARNING.
* transaction, so xact.c doesn't issue useless WARNING.
...
@@ -306,14 +315,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
...
@@ -306,14 +315,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
* Compute the statistics. Temporary results during the calculations
* Compute the statistics. Temporary results during the calculations
* for each column are stored in a child context. The calc routines
* for each column are stored in a child context. The calc routines
* are responsible to make sure that whatever they store into the
* 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
)
if
(
numrows
>
0
)
{
{
MemoryContext
col_context
,
MemoryContext
col_context
,
old_context
;
old_context
;
col_context
=
AllocSetContextCreate
(
CurrentMemoryC
ontext
,
col_context
=
AllocSetContextCreate
(
anl_c
ontext
,
"Analyze Column"
,
"Analyze Column"
,
ALLOCSET_DEFAULT_MINSIZE
,
ALLOCSET_DEFAULT_MINSIZE
,
ALLOCSET_DEFAULT_INITSIZE
,
ALLOCSET_DEFAULT_INITSIZE
,
...
@@ -1094,8 +1103,8 @@ compute_minimal_stats(VacAttrStats *stats,
...
@@ -1094,8 +1103,8 @@ compute_minimal_stats(VacAttrStats *stats,
Datum
*
mcv_values
;
Datum
*
mcv_values
;
float4
*
mcv_freqs
;
float4
*
mcv_freqs
;
/* Must copy the target values into
TransactionCommandC
ontext */
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
mcv_values
=
(
Datum
*
)
palloc
(
num_mcv
*
sizeof
(
Datum
));
mcv_values
=
(
Datum
*
)
palloc
(
num_mcv
*
sizeof
(
Datum
));
mcv_freqs
=
(
float4
*
)
palloc
(
num_mcv
*
sizeof
(
float4
));
mcv_freqs
=
(
float4
*
)
palloc
(
num_mcv
*
sizeof
(
float4
));
for
(
i
=
0
;
i
<
num_mcv
;
i
++
)
for
(
i
=
0
;
i
<
num_mcv
;
i
++
)
...
@@ -1415,8 +1424,8 @@ compute_scalar_stats(VacAttrStats *stats,
...
@@ -1415,8 +1424,8 @@ compute_scalar_stats(VacAttrStats *stats,
Datum
*
mcv_values
;
Datum
*
mcv_values
;
float4
*
mcv_freqs
;
float4
*
mcv_freqs
;
/* Must copy the target values into
TransactionCommandC
ontext */
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
mcv_values
=
(
Datum
*
)
palloc
(
num_mcv
*
sizeof
(
Datum
));
mcv_values
=
(
Datum
*
)
palloc
(
num_mcv
*
sizeof
(
Datum
));
mcv_freqs
=
(
float4
*
)
palloc
(
num_mcv
*
sizeof
(
float4
));
mcv_freqs
=
(
float4
*
)
palloc
(
num_mcv
*
sizeof
(
float4
));
for
(
i
=
0
;
i
<
num_mcv
;
i
++
)
for
(
i
=
0
;
i
<
num_mcv
;
i
++
)
...
@@ -1501,8 +1510,8 @@ compute_scalar_stats(VacAttrStats *stats,
...
@@ -1501,8 +1510,8 @@ compute_scalar_stats(VacAttrStats *stats,
nvals
=
values_cnt
;
nvals
=
values_cnt
;
Assert
(
nvals
>=
num_hist
);
Assert
(
nvals
>=
num_hist
);
/* Must copy the target values into
TransactionCommandC
ontext */
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
hist_values
=
(
Datum
*
)
palloc
(
num_hist
*
sizeof
(
Datum
));
hist_values
=
(
Datum
*
)
palloc
(
num_hist
*
sizeof
(
Datum
));
for
(
i
=
0
;
i
<
num_hist
;
i
++
)
for
(
i
=
0
;
i
<
num_hist
;
i
++
)
{
{
...
@@ -1530,8 +1539,8 @@ compute_scalar_stats(VacAttrStats *stats,
...
@@ -1530,8 +1539,8 @@ compute_scalar_stats(VacAttrStats *stats,
double
corr_xsum
,
double
corr_xsum
,
corr_x2sum
;
corr_x2sum
;
/* Must copy the target values into
TransactionCommandC
ontext */
/* Must copy the target values into
anl_c
ontext */
old_context
=
MemoryContextSwitchTo
(
TransactionCommandC
ontext
);
old_context
=
MemoryContextSwitchTo
(
anl_c
ontext
);
corrs
=
(
float4
*
)
palloc
(
sizeof
(
float4
));
corrs
=
(
float4
*
)
palloc
(
sizeof
(
float4
));
MemoryContextSwitchTo
(
old_context
);
MemoryContextSwitchTo
(
old_context
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment