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
54361b42
Commit
54361b42
authored
23 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
High memory usage
Here is a patch which inspired by Michael Stephens that should work Dave Cramer
parent
06f6404c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
+14
-12
14 additions, 12 deletions
...terfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
with
14 additions
and
12 deletions
src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
+
14
−
12
View file @
54361b42
...
@@ -41,8 +41,8 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
...
@@ -41,8 +41,8 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
// We use ThreadLocal for SimpleDateFormat's because they are not that
// We use ThreadLocal for SimpleDateFormat's because they are not that
// thread safe, so each calling thread has its own object.
// thread safe, so each calling thread has its own object.
private
ThreadLocal
tl_df
=
new
ThreadLocal
();
// setDate() SimpleDateFormat
private
static
ThreadLocal
tl_df
=
new
ThreadLocal
();
// setDate() SimpleDateFormat
private
ThreadLocal
tl_tsdf
=
new
ThreadLocal
();
// setTimestamp() SimpleDateFormat
private
static
ThreadLocal
tl_tsdf
=
new
ThreadLocal
();
// setTimestamp() SimpleDateFormat
/**
/**
* Constructor for the PreparedStatement class.
* Constructor for the PreparedStatement class.
...
@@ -64,6 +64,15 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
...
@@ -64,6 +64,15 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
this
.
sql
=
sql
;
this
.
sql
=
sql
;
this
.
connection
=
connection
;
this
.
connection
=
connection
;
// might just as well create it here, so we don't take the hit later
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"''yyyy-MM-dd''"
);
tl_df
.
set
(
df
);
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
tl_tsdf
.
set
(
df
);
for
(
i
=
0
;
i
<
sql
.
length
();
++
i
)
for
(
i
=
0
;
i
<
sql
.
length
();
++
i
)
{
{
int
c
=
sql
.
charAt
(
i
);
int
c
=
sql
.
charAt
(
i
);
...
@@ -89,10 +98,11 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
...
@@ -89,10 +98,11 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
/**
/**
* New in 7.1 - overides Statement.close() to dispose of a few local objects
* New in 7.1 - overides Statement.close() to dispose of a few local objects
*/
*/
public
void
close
()
throws
SQLException
{
public
void
close
()
throws
SQLException
{
// free the ThreadLocal caches
// free the ThreadLocal caches
tl_df
.
set
(
null
);
tl_df
.
set
(
null
);
tl_tsdf
.
set
(
null
);
super
.
close
();
super
.
close
();
}
}
...
@@ -333,10 +343,6 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
...
@@ -333,10 +343,6 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
public
void
setDate
(
int
parameterIndex
,
java
.
sql
.
Date
x
)
throws
SQLException
public
void
setDate
(
int
parameterIndex
,
java
.
sql
.
Date
x
)
throws
SQLException
{
{
SimpleDateFormat
df
=
(
SimpleDateFormat
)
tl_df
.
get
();
SimpleDateFormat
df
=
(
SimpleDateFormat
)
tl_df
.
get
();
if
(
df
==
null
)
{
df
=
new
SimpleDateFormat
(
"''yyyy-MM-dd''"
);
tl_df
.
set
(
df
);
}
set
(
parameterIndex
,
df
.
format
(
x
));
set
(
parameterIndex
,
df
.
format
(
x
));
...
@@ -376,10 +382,6 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
...
@@ -376,10 +382,6 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
)
throws
SQLException
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
)
throws
SQLException
{
{
SimpleDateFormat
df
=
(
SimpleDateFormat
)
tl_tsdf
.
get
();
SimpleDateFormat
df
=
(
SimpleDateFormat
)
tl_tsdf
.
get
();
if
(
df
==
null
)
{
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
tl_tsdf
.
set
(
df
);
}
df
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
));
df
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
));
// Use the shared StringBuffer
// Use the shared StringBuffer
...
...
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