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
d676e29d
Commit
d676e29d
authored
Jul 10, 2002
by
Barry Lind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug in getTime() with fractional seconds reported by Laurette Cisneros (laurette@nextbus.com)
parent
92a77cb8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
27 deletions
+56
-27
src/interfaces/jdbc/org/postgresql/Driver.java.in
src/interfaces/jdbc/org/postgresql/Driver.java.in
+1
-1
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
+30
-18
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
+3
-3
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
+22
-5
No files found.
src/interfaces/jdbc/org/postgresql/Driver.java.in
View file @
d676e29d
...
...
@@ -442,6 +442,6 @@ public class Driver implements java.sql.Driver
}
//
The
build
number
should
be
incremented
for
every
new
build
private
static
int
m_buildNumber
=
10
0
;
private
static
int
m_buildNumber
=
10
1
;
}
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
View file @
d676e29d
...
...
@@ -108,7 +108,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
{
if
(
rows
==
null
)
throw
new
PSQLException
(
"postgresql.con.closed"
);
if
(++
current_row
>=
rows
.
size
())
return
false
;
this_row
=
(
byte
[][])
rows
.
elementAt
(
current_row
);
...
...
@@ -468,30 +468,42 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
{
String
s
=
getString
(
columnIndex
);
if
(
s
!=
null
)
if
(
s
==
null
)
return
null
;
// SQL NULL
try
{
try
{
if
(
s
.
length
()
!=
5
&&
s
.
length
()
!=
8
)
throw
new
NumberFormatException
(
"Wrong Length!"
);
int
hr
=
Integer
.
parseInt
(
s
.
substring
(
0
,
2
));
int
min
=
Integer
.
parseInt
(
s
.
substring
(
3
,
5
));
int
sec
=
(
s
.
length
()
==
5
)
?
0
:
Integer
.
parseInt
(
s
.
substring
(
6
));
return
new
Time
(
hr
,
min
,
sec
);
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.badtime"
,
s
);
}
if
(
s
.
length
()
==
8
)
{
//value is a time value
return
java
.
sql
.
Time
.
valueOf
(
s
);
}
else
if
(
s
.
indexOf
(
"."
)
==
8
)
{
//value is a time value with fractional seconds
java
.
sql
.
Time
l_time
=
java
.
sql
.
Time
.
valueOf
(
s
.
substring
(
0
,
8
));
String
l_strMillis
=
s
.
substring
(
9
);
if
(
l_strMillis
.
length
()
>
3
)
l_strMillis
=
l_strMillis
.
substring
(
0
,
3
);
int
l_millis
=
Integer
.
parseInt
(
l_strMillis
);
if
(
l_millis
<
10
)
{
l_millis
=
l_millis
*
100
;
}
else
if
(
l_millis
<
100
)
{
l_millis
=
l_millis
*
10
;
}
return
new
java
.
sql
.
Time
(
l_time
.
getTime
()
+
l_millis
);
}
else
{
//value is a timestamp
return
new
java
.
sql
.
Time
(
getTimestamp
(
columnIndex
).
getTime
());
}
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.badtime"
,
s
);
}
return
null
;
// SQL NULL
}
/*
* Get the value of a column in the current row as a
* java.sql.Timestamp object
*
* The driver is set to return ISO date formated strings. We modify this
* The driver is set to return ISO date formated strings. We modify this
* string from the ISO format to a format that Java can understand. Java
* expects timezone info as 'GMT+09:00' where as ISO gives '+09'.
* Java also expects fractional seconds to 3 places where postgres
...
...
@@ -577,7 +589,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
}
else
if
(
slen
==
19
)
{
// No tz or fractional second info.
// No tz or fractional second info.
// if type is timestamptz then data is in GMT, else it is in local timezone
if
(
fields
[
columnIndex
-
1
].
getPGType
().
equals
(
"timestamptz"
))
{
sbuf
.
append
(
" GMT"
);
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
View file @
d676e29d
...
...
@@ -74,12 +74,12 @@ public class Array implements java.sql.Array
Object
retVal
=
null
;
ArrayList
array
=
new
ArrayList
();
/* Check if the String is also not an empty array
* otherwise there will be an exception thrown below
* in the ResultSet.toX with an empty string.
* -- Doug Fields <dfields-pg-jdbc@pexicom.com> Feb 20, 2002 */
if
(
rawString
!=
null
&&
!
rawString
.
equals
(
"{}"
)
)
{
char
[]
chars
=
rawString
.
toCharArray
();
...
...
@@ -166,7 +166,7 @@ public class Array implements java.sql.Array
case
Types
.
TIME
:
retVal
=
new
java
.
sql
.
Time
[
count
];
for
(
;
count
>
0
;
count
--
)
((
java
.
sql
.
Time
[])
retVal
)[
i
++]
=
ResultSet
.
toTime
(
arrayContents
[(
int
)
index
++]
);
((
java
.
sql
.
Time
[])
retVal
)[
i
++]
=
ResultSet
.
toTime
(
arrayContents
[(
int
)
index
++]
,
rs
,
getBaseTypeName
()
);
break
;
case
Types
.
TIMESTAMP
:
retVal
=
new
Timestamp
[
count
];
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
View file @
d676e29d
...
...
@@ -388,7 +388,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public
Time
getTime
(
int
columnIndex
)
throws
SQLException
{
return
toTime
(
getString
(
columnIndex
)
);
return
toTime
(
getString
(
columnIndex
)
,
this
,
fields
[
columnIndex
-
1
].
getPGType
()
);
}
/*
...
...
@@ -1626,15 +1626,32 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
}
}
public
static
Time
toTime
(
String
s
)
throws
SQLException
public
static
Time
toTime
(
String
s
,
ResultSet
resultSet
,
String
pgDataType
)
throws
SQLException
{
if
(
s
==
null
)
return
null
;
// SQL NULL
// length == 8: SQL Time
// length > 8: SQL Timestamp
try
{
return
java
.
sql
.
Time
.
valueOf
((
s
.
length
()
==
8
)
?
s
:
s
.
substring
(
11
,
19
));
if
(
s
.
length
()
==
8
)
{
//value is a time value
return
java
.
sql
.
Time
.
valueOf
(
s
);
}
else
if
(
s
.
indexOf
(
"."
)
==
8
)
{
//value is a time value with fractional seconds
java
.
sql
.
Time
l_time
=
java
.
sql
.
Time
.
valueOf
(
s
.
substring
(
0
,
8
));
String
l_strMillis
=
s
.
substring
(
9
);
if
(
l_strMillis
.
length
()
>
3
)
l_strMillis
=
l_strMillis
.
substring
(
0
,
3
);
int
l_millis
=
Integer
.
parseInt
(
l_strMillis
);
if
(
l_millis
<
10
)
{
l_millis
=
l_millis
*
100
;
}
else
if
(
l_millis
<
100
)
{
l_millis
=
l_millis
*
10
;
}
return
new
java
.
sql
.
Time
(
l_time
.
getTime
()
+
l_millis
);
}
else
{
//value is a timestamp
return
new
java
.
sql
.
Time
(
toTimestamp
(
s
,
resultSet
,
pgDataType
).
getTime
());
}
}
catch
(
NumberFormatException
e
)
{
...
...
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