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
09634eaf
Commit
09634eaf
authored
Nov 19, 2001
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indent jdbc case labels using pgjindent.
parent
6c8120d6
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
1236 additions
and
1211 deletions
+1236
-1211
src/interfaces/jdbc/example/ImageViewer.java
src/interfaces/jdbc/example/ImageViewer.java
+0
-1
src/interfaces/jdbc/example/Unicode.java
src/interfaces/jdbc/example/Unicode.java
+15
-15
src/interfaces/jdbc/example/basic.java
src/interfaces/jdbc/example/basic.java
+3
-1
src/interfaces/jdbc/example/blobtest.java
src/interfaces/jdbc/example/blobtest.java
+0
-4
src/interfaces/jdbc/example/corba/StockClient.java
src/interfaces/jdbc/example/corba/StockClient.java
+19
-19
src/interfaces/jdbc/example/datestyle.java
src/interfaces/jdbc/example/datestyle.java
+0
-2
src/interfaces/jdbc/example/metadata.java
src/interfaces/jdbc/example/metadata.java
+0
-1
src/interfaces/jdbc/example/psql.java
src/interfaces/jdbc/example/psql.java
+1
-2
src/interfaces/jdbc/example/threadsafe.java
src/interfaces/jdbc/example/threadsafe.java
+0
-2
src/interfaces/jdbc/org/postgresql/Connection.java
src/interfaces/jdbc/org/postgresql/Connection.java
+114
-115
src/interfaces/jdbc/org/postgresql/PG_Stream.java
src/interfaces/jdbc/org/postgresql/PG_Stream.java
+1
-2
src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java
src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java
+1
-19
src/interfaces/jdbc/org/postgresql/Statement.java
src/interfaces/jdbc/org/postgresql/Statement.java
+37
-37
src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
+17
-18
src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
+14
-14
src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
+48
-49
src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
+39
-40
src/interfaces/jdbc/org/postgresql/geometric/PGpath.java
src/interfaces/jdbc/org/postgresql/geometric/PGpath.java
+0
-1
src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
...nterfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
+145
-125
src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
...terfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
+46
-46
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
+70
-67
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java
...terfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java
+65
-65
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
+176
-176
src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
...nterfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
+174
-153
src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
...terfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
+46
-46
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
+99
-87
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java
...terfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java
+65
-65
src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java
+30
-30
src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
...erfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
+7
-7
src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
+1
-0
src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java
src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java
+2
-1
src/tools/pgindent/pgjindent
src/tools/pgindent/pgjindent
+1
-1
No files found.
src/interfaces/jdbc/example/ImageViewer.java
View file @
09634eaf
...
...
@@ -291,7 +291,6 @@ public class ImageViewer implements ItemListener
public
void
run
()
{
// Now the real import stuff
if
(
name
!=
null
&&
dir
!=
null
)
{
...
...
src/interfaces/jdbc/example/Unicode.java
View file @
09634eaf
...
...
@@ -214,21 +214,21 @@ public class Unicode
{
switch
(
mode
)
{
case
CREATE:
log
(
"Exception creating database"
,
sqle
);
break
;
case
INSERT:
log
(
"Exception inserting block "
+
blockNum
,
sqle
);
break
;
case
SELECT:
log
(
"Exception selecting block "
+
blockNum
,
sqle
);
break
;
case
LIKE:
log
(
"Exception doing LIKE on block "
+
blockNum
,
sqle
);
break
;
default
:
log
(
"Exception"
,
sqle
);
break
;
case
CREATE:
log
(
"Exception creating database"
,
sqle
);
break
;
case
INSERT:
log
(
"Exception inserting block "
+
blockNum
,
sqle
);
break
;
case
SELECT:
log
(
"Exception selecting block "
+
blockNum
,
sqle
);
break
;
case
LIKE:
log
(
"Exception doing LIKE on block "
+
blockNum
,
sqle
);
break
;
default
:
log
(
"Exception"
,
sqle
);
break
;
}
}
catch
(
ClassNotFoundException
cnfe
)
...
...
src/interfaces/jdbc/example/basic.java
View file @
09634eaf
...
...
@@ -6,7 +6,7 @@ import java.text.*;
/*
*
* $Id: basic.java,v 1.
9 2001/11/19 22:43:13
momjian Exp $
* $Id: basic.java,v 1.
10 2001/11/19 23:16:44
momjian Exp $
*
* This example tests the basic components of the JDBC driver, and shows
* how even the simplest of queries can be implemented.
...
...
@@ -137,6 +137,7 @@ public class basic
// Now run the query again, showing a more efficient way of getting the
// result if you don't know what column number a value is in
System
.
out
.
println
(
"performing another query"
);
rs
=
st
.
executeQuery
(
"select * from basic where b>1"
);
if
(
rs
!=
null
)
...
...
@@ -163,6 +164,7 @@ public class basic
// Now test maxrows by setting it to 3 rows
st
.
setMaxRows
(
3
);
System
.
out
.
println
(
"performing a query limited to "
+
st
.
getMaxRows
());
rs
=
st
.
executeQuery
(
"select a, b from basic"
);
...
...
src/interfaces/jdbc/example/blobtest.java
View file @
09634eaf
...
...
@@ -61,7 +61,6 @@ public class blobtest
System
.
out
.
println
(
"Now closing the connection"
);
s
.
close
();
db
.
close
();
}
/*
...
...
@@ -171,7 +170,6 @@ public class blobtest
lobj
.
unlink
(
oid
);
}
//=======================================================================
// This tests the Blob interface of the JDBC 2.0 specification
public
void
jdbc2api
(
int
oid
)
throws
SQLException
,
IOException
{
...
...
@@ -218,8 +216,6 @@ public class blobtest
db
.
setAutoCommit
(
false
);
}
//=======================================================================
public
static
void
instructions
()
{
System
.
err
.
println
(
"java example.blobtest jdbc-url user password [debug]"
);
...
...
src/interfaces/jdbc/example/corba/StockClient.java
View file @
09634eaf
...
...
@@ -9,7 +9,7 @@ import org.omg.CosNaming.*;
*
* It has no GUI, just a text frontend to keep it simple.
*
* $Id: StockClient.java,v 1.
3 2001/11/19 22:43:13
momjian Exp $
* $Id: StockClient.java,v 1.
4 2001/11/19 23:16:45
momjian Exp $
*/
public
class
StockClient
{
...
...
@@ -116,29 +116,29 @@ public class StockClient
int
i
=
getMenu
(
"Main"
,
5
);
switch
(
i
)
{
case
0
:
run
=
false
;
break
;
case
0
:
run
=
false
;
break
;
case
1
:
displayItem
();
break
;
case
1
:
displayItem
();
break
;
case
2
:
bookOut
();
break
;
case
2
:
bookOut
();
break
;
case
3
:
bookIn
();
break
;
case
3
:
bookIn
();
break
;
case
4
:
order
(
0
);
break
;
case
4
:
order
(
0
);
break
;
case
5
:
displayAll
();
break
;
case
5
:
displayAll
();
break
;
}
}
}
...
...
src/interfaces/jdbc/example/datestyle.java
View file @
09634eaf
...
...
@@ -9,7 +9,6 @@ import java.text.*;
*
* To use this example, you need a database to be in existence. This example
* will create a table called datestyle.
*
*/
public
class
datestyle
...
...
@@ -105,7 +104,6 @@ public class datestyle
ps
.
setDate
(
1
,
standard
);
ps
.
executeUpdate
();
ps
.
close
();
}
/*
...
...
src/interfaces/jdbc/example/metadata.java
View file @
09634eaf
...
...
@@ -218,7 +218,6 @@ public class metadata
{
if
(
line
.
startsWith
(
"\\d"
))
{
if
(
line
.
startsWith
(
"\\d "
))
{
// Display details about a table
...
...
src/interfaces/jdbc/example/psql.java
View file @
09634eaf
...
...
@@ -50,7 +50,7 @@ public class psql
// Now the main loop.
int
tt
=
0
,
lineno
=
1
;
while
(
tt
!=
StreamTokenizer
.
TT_EOF
&&
!
done
)
{
// done added by CWJ to permit \q command
{
System
.
out
.
print
(
"["
+
lineno
+
"] "
);
System
.
out
.
flush
();
...
...
@@ -72,7 +72,6 @@ public class psql
System
.
out
.
println
(
"Now closing the connection"
);
st
.
close
();
db
.
close
();
}
/*
...
...
src/interfaces/jdbc/example/threadsafe.java
View file @
09634eaf
...
...
@@ -53,7 +53,6 @@ public class threadsafe
System
.
out
.
println
(
"Now closing the connection"
);
st
.
close
();
db
.
close
();
}
/*
...
...
@@ -108,7 +107,6 @@ public class threadsafe
System
.
out
.
println
(
"Waiting for threads to run"
);
while
(
thread1
.
isAlive
()
||
thread2
.
isAlive
()
||
thread3
.
isAlive
())
thread0
.
yield
();
}
finally
{
...
...
src/interfaces/jdbc/org/postgresql/Connection.java
View file @
09634eaf
...
...
@@ -11,7 +11,7 @@ import org.postgresql.util.*;
import
org.postgresql.core.*
;
/*
* $Id: Connection.java,v 1.3
6 2001/11/19 22:33:37
momjian Exp $
* $Id: Connection.java,v 1.3
7 2001/11/19 23:16:45
momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
...
...
@@ -115,7 +115,7 @@ public abstract class Connection
this_url
=
url
;
PG_DATABASE
=
database
;
PG_USER
=
info
.
getProperty
(
"user"
);
PG_PASSWORD
=
info
.
getProperty
(
"password"
,
""
);
PG_PASSWORD
=
info
.
getProperty
(
"password"
,
""
);
PG_PORT
=
port
;
PG_HOST
=
host
;
PG_STATUS
=
CONNECTION_BAD
;
...
...
@@ -168,88 +168,88 @@ public abstract class Connection
int
beresp
=
pg_stream
.
ReceiveChar
();
switch
(
beresp
)
{
case
'E'
:
// An error occured, so pass the error message to the
// user.
//
// The most common one to be thrown here is:
// "User authentication failed"
//
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
encoding
));
case
'R'
:
// Get the type of request
areq
=
pg_stream
.
ReceiveIntegerR
(
4
);
// Get the crypt password salt if there is one
if
(
areq
==
AUTH_REQ_CRYPT
)
{
byte
[]
rst
=
new
byte
[
2
];
rst
[
0
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
1
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
salt
=
new
String
(
rst
,
0
,
2
);
DriverManager
.
println
(
"Crypt salt="
+
salt
);
}
// Or get the md5 password salt if there is one
if
(
areq
==
AUTH_REQ_MD5
)
{
byte
[]
rst
=
new
byte
[
4
];
rst
[
0
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
1
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
2
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
3
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
salt
=
new
String
(
rst
,
0
,
4
);
DriverManager
.
println
(
"MD5 salt="
+
salt
);
}
// now send the auth packet
switch
(
areq
)
{
case
AUTH_REQ_OK:
break
;
case
AUTH_REQ_KRB4:
DriverManager
.
println
(
"postgresql: KRB4"
);
throw
new
PSQLException
(
"postgresql.con.kerb4"
);
case
AUTH_REQ_KRB5:
DriverManager
.
println
(
"postgresql: KRB5"
);
throw
new
PSQLException
(
"postgresql.con.kerb5"
);
case
AUTH_REQ_PASSWORD:
DriverManager
.
println
(
"postgresql: PASSWORD"
);
pg_stream
.
SendInteger
(
5
+
PG_PASSWORD
.
length
(),
4
);
pg_stream
.
Send
(
PG_PASSWORD
.
getBytes
());
pg_stream
.
SendInteger
(
0
,
1
);
pg_stream
.
flush
();
break
;
case
AUTH_REQ_CRYPT:
DriverManager
.
println
(
"postgresql: CRYPT"
);
String
crypted
=
UnixCrypt
.
crypt
(
salt
,
PG_PASSWORD
);
pg_stream
.
SendInteger
(
5
+
crypted
.
length
(),
4
);
pg_stream
.
Send
(
crypted
.
getBytes
());
pg_stream
.
SendInteger
(
0
,
1
);
pg_stream
.
flush
();
break
;
case
AUTH_REQ_MD5:
DriverManager
.
println
(
"postgresql: MD5"
);
byte
[]
digest
=
MD5Digest
.
encode
(
PG_USER
,
PG_PASSWORD
,
salt
);
pg_stream
.
SendInteger
(
5
+
digest
.
length
,
4
);
pg_stream
.
Send
(
digest
);
pg_stream
.
SendInteger
(
0
,
1
);
pg_stream
.
flush
();
case
'E'
:
// An error occured, so pass the error message to the
// user.
//
// The most common one to be thrown here is:
// "User authentication failed"
//
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
encoding
));
case
'R'
:
// Get the type of request
areq
=
pg_stream
.
ReceiveIntegerR
(
4
);
// Get the crypt password salt if there is one
if
(
areq
==
AUTH_REQ_CRYPT
)
{
byte
[]
rst
=
new
byte
[
2
];
rst
[
0
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
1
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
salt
=
new
String
(
rst
,
0
,
2
);
DriverManager
.
println
(
"Crypt salt="
+
salt
);
}
// Or get the md5 password salt if there is one
if
(
areq
==
AUTH_REQ_MD5
)
{
byte
[]
rst
=
new
byte
[
4
];
rst
[
0
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
1
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
2
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
3
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
salt
=
new
String
(
rst
,
0
,
4
);
DriverManager
.
println
(
"MD5 salt="
+
salt
);
}
// now send the auth packet
switch
(
areq
)
{
case
AUTH_REQ_OK:
break
;
case
AUTH_REQ_KRB4:
DriverManager
.
println
(
"postgresql: KRB4"
);
throw
new
PSQLException
(
"postgresql.con.kerb4"
);
case
AUTH_REQ_KRB5:
DriverManager
.
println
(
"postgresql: KRB5"
);
throw
new
PSQLException
(
"postgresql.con.kerb5"
);
case
AUTH_REQ_PASSWORD:
DriverManager
.
println
(
"postgresql: PASSWORD"
);
pg_stream
.
SendInteger
(
5
+
PG_PASSWORD
.
length
(),
4
);
pg_stream
.
Send
(
PG_PASSWORD
.
getBytes
());
pg_stream
.
SendInteger
(
0
,
1
);
pg_stream
.
flush
();
break
;
case
AUTH_REQ_CRYPT:
DriverManager
.
println
(
"postgresql: CRYPT"
);
String
crypted
=
UnixCrypt
.
crypt
(
salt
,
PG_PASSWORD
);
pg_stream
.
SendInteger
(
5
+
crypted
.
length
(),
4
);
pg_stream
.
Send
(
crypted
.
getBytes
());
pg_stream
.
SendInteger
(
0
,
1
);
pg_stream
.
flush
();
break
;
case
AUTH_REQ_MD5:
DriverManager
.
println
(
"postgresql: MD5"
);
byte
[]
digest
=
MD5Digest
.
encode
(
PG_USER
,
PG_PASSWORD
,
salt
);
pg_stream
.
SendInteger
(
5
+
digest
.
length
,
4
);
pg_stream
.
Send
(
digest
);
pg_stream
.
SendInteger
(
0
,
1
);
pg_stream
.
flush
();
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.auth"
,
new
Integer
(
areq
));
}
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.auth"
,
new
Integer
(
areq
));
}
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.authfail"
);
throw
new
PSQLException
(
"postgresql.con.authfail"
);
}
}
while
(
areq
!=
AUTH_REQ_OK
);
...
...
@@ -265,28 +265,28 @@ public abstract class Connection
int
beresp
=
pg_stream
.
ReceiveChar
();
switch
(
beresp
)
{
case
'K'
:
pid
=
pg_stream
.
ReceiveInteger
(
4
);
ckey
=
pg_stream
.
ReceiveInteger
(
4
);
break
;
case
'E'
:
case
'N'
:
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
encoding
));
default
:
throw
new
PSQLException
(
"postgresql.con.setup"
);
case
'K'
:
pid
=
pg_stream
.
ReceiveInteger
(
4
);
ckey
=
pg_stream
.
ReceiveInteger
(
4
);
break
;
case
'E'
:
case
'N'
:
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
encoding
));
default
:
throw
new
PSQLException
(
"postgresql.con.setup"
);
}
// Expect ReadyForQuery packet
beresp
=
pg_stream
.
ReceiveChar
();
switch
(
beresp
)
{
case
'Z'
:
break
;
case
'E'
:
case
'N'
:
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
encoding
));
default
:
throw
new
PSQLException
(
"postgresql.con.setup"
);
case
'Z'
:
break
;
case
'E'
:
case
'N'
:
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
encoding
));
default
:
throw
new
PSQLException
(
"postgresql.con.setup"
);
}
firstWarning
=
null
;
...
...
@@ -958,15 +958,15 @@ public abstract class Connection
isolationLevelSQL
=
"SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL "
;
switch
(
isolationLevel
)
{
case
java
.
sql
.
Connection
.
TRANSACTION_READ_COMMITTED
:
isolationLevelSQL
+=
"READ COMMITTED"
;
break
;
case
java
.
sql
.
Connection
.
TRANSACTION_SERIALIZABLE
:
isolationLevelSQL
+=
"SERIALIZABLE"
;
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.isolevel"
,
new
Integer
(
isolationLevel
));
case
java
.
sql
.
Connection
.
TRANSACTION_READ_COMMITTED
:
isolationLevelSQL
+=
"READ COMMITTED"
;
break
;
case
java
.
sql
.
Connection
.
TRANSACTION_SERIALIZABLE
:
isolationLevelSQL
+=
"SERIALIZABLE"
;
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.isolevel"
,
new
Integer
(
isolationLevel
));
}
}
ExecSQL
(
isolationLevelSQL
);
...
...
@@ -993,16 +993,16 @@ public abstract class Connection
switch
(
isolationLevel
)
{
case
java
.
sql
.
Connection
.
TRANSACTION_READ_COMMITTED
:
sb
.
append
(
" READ COMMITTED"
);
break
;
case
java
.
sql
.
Connection
.
TRANSACTION_READ_COMMITTED
:
sb
.
append
(
" READ COMMITTED"
);
break
;
case
java
.
sql
.
Connection
.
TRANSACTION_SERIALIZABLE
:
sb
.
append
(
" SERIALIZABLE"
);
break
;
case
java
.
sql
.
Connection
.
TRANSACTION_SERIALIZABLE
:
sb
.
append
(
" SERIALIZABLE"
);
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.isolevel"
,
new
Integer
(
isolationLevel
));
default
:
throw
new
PSQLException
(
"postgresql.con.isolevel"
,
new
Integer
(
isolationLevel
));
}
return
sb
.
toString
();
}
...
...
@@ -1166,6 +1166,5 @@ public abstract class Connection
}
return
pgType
;
}
}
src/interfaces/jdbc/org/postgresql/PG_Stream.java
View file @
09634eaf
...
...
@@ -10,7 +10,7 @@ import org.postgresql.core.*;
import
org.postgresql.util.*
;
/*
* $Id: PG_Stream.java,v 1.1
5 2001/11/19 22:33:37
momjian Exp $
* $Id: PG_Stream.java,v 1.1
6 2001/11/19 23:16:45
momjian Exp $
*
* This class is used by Connection & PGlobj for communicating with the
* backend.
...
...
@@ -371,5 +371,4 @@ public class PG_Stream
pg_input
.
close
();
connection
.
close
();
}
}
src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java
View file @
09634eaf
...
...
@@ -40,7 +40,7 @@
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: PostgresqlDataSource.java,v 1.
4 2001/11/19 22:33:37
momjian Exp $
* $Id: PostgresqlDataSource.java,v 1.
5 2001/11/19 23:16:45
momjian Exp $
*/
...
...
@@ -133,38 +133,32 @@ public class PostgresqlDataSource
*/
private
int
_loginTimeout
;
/*
* Holds the user's account name.
*/
private
String
_user
;
/*
* Holds the database password.
*/
private
String
_password
;
/*
* Holds the name of the particular database on the server.
*/
private
String
_databaseName
;
/*
* Description of this datasource.
*/
private
String
_description
=
"PostgreSQL DataSource"
;
/*
* Holds the database server name. If null, this is
* assumed to be the localhost.
*/
private
String
_serverName
;
/*
* Holds the port number where a server is listening.
* The default value will open a connection with an
...
...
@@ -172,7 +166,6 @@ public class PostgresqlDataSource
*/
private
int
_portNumber
=
DEFAULT_PORT
;
/*
* The default port number. Since we open the connection
* without specifying the port if it's the default one,
...
...
@@ -180,7 +173,6 @@ public class PostgresqlDataSource
*/
private
static
final
int
DEFAULT_PORT
=
0
;
/*
* Holds the log writer to which all messages should be
* printed. The default writer is obtained from the driver
...
...
@@ -189,7 +181,6 @@ public class PostgresqlDataSource
*/
private
transient
PrintWriter
_logWriter
;
/*
* Each datasource maintains it's own driver, in case of
* driver-specific setup (e.g. pools, log writer).
...
...
@@ -197,9 +188,6 @@ public class PostgresqlDataSource
// FIXME
// private transient postgresql.Driver _driver;
private
transient
org
.
postgresql
.
Driver
_driver
;
//---------
public
PostgresqlDataSource
()
{
...
...
@@ -233,12 +221,10 @@ public class PostgresqlDataSource
// FIXME
// _driver = new postgresql.Driver();
_driver
=
new
org
.
postgresql
.
Driver
();
//-----------
//FIXME
// _driver.setLogWriter( _logWriter );
// Method seems to be unavailable. Just commented it out.
//----------
}
catch
(
SQLException
except
)
{
...
...
@@ -282,7 +268,6 @@ public class PostgresqlDataSource
// if ( ! ( conn instanceof postgresql.jdbc2.Connection ) ) {
if
(
!
(
conn
instanceof
org
.
postgresql
.
jdbc2
.
Connection
)
)
{
//--------
if
(
_logWriter
!=
null
)
_logWriter
.
println
(
"DataSource: JDBC 1 connections not supported"
);
throw
new
PSQLException
(
"postgresql.ds.onlyjdbc2"
);
...
...
@@ -317,7 +302,6 @@ public class PostgresqlDataSource
// FIXME
// _driver.setLogWriter( writer );
// Method seems to be unavailable. Commented it out.
//----------
_logWriter
=
writer
;
}
}
...
...
@@ -617,7 +601,5 @@ public class PostgresqlDataSource
else
return
null
;
}
}
src/interfaces/jdbc/org/postgresql/Statement.java
View file @
09634eaf
...
...
@@ -269,50 +269,50 @@ public abstract class Statement
char
c
=
sql
.
charAt
(
i
);
switch
(
state
)
{
case
IN_SQLCODE:
if
(
c
==
'\''
)
// start of a string?
state
=
IN_STRING
;
else
if
(
c
==
'{'
)
// start of an escape code?
if
(
i
+
1
<
len
)
{
char
next
=
sql
.
charAt
(
i
+
1
);
if
(
next
==
'd'
)
{
state
=
ESC_TIMEDATE
;
i
++;
break
;
}
else
if
(
next
==
't'
)
case
IN_SQLCODE:
if
(
c
==
'\''
)
// start of a string?
state
=
IN_STRING
;
else
if
(
c
==
'{'
)
// start of an escape code?
if
(
i
+
1
<
len
)
{
state
=
ESC_TIMEDATE
;
i
+=
(
i
+
2
<
len
&&
sql
.
charAt
(
i
+
2
)
==
's'
)
?
2
:
1
;
break
;
char
next
=
sql
.
charAt
(
i
+
1
);
if
(
next
==
'd'
)
{
state
=
ESC_TIMEDATE
;
i
++;
break
;
}
else
if
(
next
==
't'
)
{
state
=
ESC_TIMEDATE
;
i
+=
(
i
+
2
<
len
&&
sql
.
charAt
(
i
+
2
)
==
's'
)
?
2
:
1
;
break
;
}
}
}
newsql
.
append
(
c
);
break
;
case
IN_STRING:
if
(
c
==
'\''
)
// end of string?
state
=
IN_SQLCODE
;
else
if
(
c
==
'\\'
)
// a backslash?
state
=
BACKSLASH
;
newsql
.
append
(
c
);
break
;
newsql
.
append
(
c
);
break
;
case
IN_STRING:
if
(
c
==
'\''
)
// end of string?
state
=
IN_SQLCODE
;
else
if
(
c
==
'\\'
)
// a backslash?
state
=
BACKSLASH
;
case
BACKSLASH:
state
=
IN_STRING
;
newsql
.
append
(
c
);
break
;
newsql
.
append
(
c
);
break
;
case
BACKSLASH:
state
=
IN_STRING
;
case
ESC_TIMEDATE:
if
(
c
==
'}'
)
state
=
IN_SQLCODE
;
// end of escape code.
else
newsql
.
append
(
c
);
break
;
break
;
case
ESC_TIMEDATE:
if
(
c
==
'}'
)
state
=
IN_SQLCODE
;
// end of escape code.
else
newsql
.
append
(
c
);
break
;
}
// end switch
}
...
...
src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
View file @
09634eaf
...
...
@@ -6,7 +6,6 @@ package org.postgresql.core;
*/
public
class
BytePoolDim1
{
/*
* The maximum size of the array we manage.
*/
...
...
@@ -47,26 +46,26 @@ public class BytePoolDim1
// for now until the bug can be removed
return
new
byte
[
size
];
/*
// Don't pool if >maxsize
if (size > maxsize){
return new byte[size];
}
// Don't pool if >maxsize
if (size > maxsize){
return new byte[size];
}
ObjectPool not_usel = notusemap[size];
ObjectPool in_usel = inusemap[size];
byte b[] = null;
ObjectPool not_usel = notusemap[size];
ObjectPool in_usel = inusemap[size];
byte b[] = null;
// Fetch from the unused pool if available otherwise allocate a new
// now array
if (!not_usel.isEmpty()) {
Object o = not_usel.remove();
b = (byte[]) o;
} else
b = new byte[size];
in_usel.add(b);
// Fetch from the unused pool if available otherwise allocate a new
// now array
if (!not_usel.isEmpty()) {
Object o = not_usel.remove();
b = (byte[]) o;
} else
b = new byte[size];
in_usel.add(b);
return b;
*/
return b;
*/
}
/*
...
...
src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
View file @
09634eaf
...
...
@@ -20,22 +20,22 @@ public class BytePoolDim2
// For now until the bug can be removed
return
new
byte
[
size
][
0
];
/*
if (size > maxsize){
return new byte[size][0];
}
ObjectPool not_usel = notusemap[size];
ObjectPool in_usel = inusemap[size];
if (size > maxsize){
return new byte[size][0];
}
ObjectPool not_usel = notusemap[size];
ObjectPool in_usel = inusemap[size];
byte b[][] = null;
byte b[][] = null;
if (!not_usel.isEmpty()) {
Object o = not_usel.remove();
b = (byte[][]) o;
} else
b = new byte[size][0];
in_usel.add(b);
return b;
*/
if (!not_usel.isEmpty()) {
Object o = not_usel.remove();
b = (byte[][]) o;
} else
b = new byte[size][0];
in_usel.add(b);
return b;
*/
}
public
void
release
(
byte
[][]
b
)
...
...
src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
View file @
09634eaf
...
...
@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
* <p>The lifetime of a QueryExecutor object is from sending the query
* until the response has been received from the backend.
*
* $Id: QueryExecutor.java,v 1.
4 2001/11/19 22:33:37
momjian Exp $
* $Id: QueryExecutor.java,v 1.
5 2001/11/19 23:16:45
momjian Exp $
*/
public
class
QueryExecutor
...
...
@@ -69,53 +69,53 @@ public class QueryExecutor
switch
(
c
)
{
case
'A'
:
// Asynchronous Notify
int
pid
=
pg_stream
.
ReceiveInteger
(
4
);
String
msg
=
pg_stream
.
ReceiveString
(
connection
.
getEncoding
());
break
;
case
'B'
:
// Binary Data Transfer
receiveTuple
(
true
);
break
;
case
'C'
:
// Command Status
receiveCommandStatus
();
if
(
fields
!=
null
)
hfr
=
true
;
else
{
sendQuery
(
" "
);
fqp
++;
}
break
;
case
'D'
:
// Text Data Transfer
receiveTuple
(
false
);
break
;
case
'E'
:
// Error Message
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
connection
.
getEncoding
()));
case
'I'
:
// Empty Query
int
t
=
pg_stream
.
ReceiveChar
();
if
(
t
!=
0
)
throw
new
PSQLException
(
"postgresql.con.garbled"
);
if
(
fqp
>
0
)
fqp
--;
if
(
fqp
==
0
)
hfr
=
true
;
break
;
case
'N'
:
// Error Notification
connection
.
addWarning
(
pg_stream
.
ReceiveString
(
connection
.
getEncoding
()));
break
;
case
'P'
:
// Portal Name
String
pname
=
pg_stream
.
ReceiveString
(
connection
.
getEncoding
());
break
;
case
'T'
:
// MetaData Field Description
receiveFields
();
break
;
case
'Z'
:
// backend ready for query, ignore for now :-)
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.type"
,
new
Character
((
char
)
c
));
case
'A'
:
// Asynchronous Notify
int
pid
=
pg_stream
.
ReceiveInteger
(
4
);
String
msg
=
pg_stream
.
ReceiveString
(
connection
.
getEncoding
());
break
;
case
'B'
:
// Binary Data Transfer
receiveTuple
(
true
);
break
;
case
'C'
:
// Command Status
receiveCommandStatus
();
if
(
fields
!=
null
)
hfr
=
true
;
else
{
sendQuery
(
" "
);
fqp
++;
}
break
;
case
'D'
:
// Text Data Transfer
receiveTuple
(
false
);
break
;
case
'E'
:
// Error Message
throw
new
SQLException
(
pg_stream
.
ReceiveString
(
connection
.
getEncoding
()));
case
'I'
:
// Empty Query
int
t
=
pg_stream
.
ReceiveChar
();
if
(
t
!=
0
)
throw
new
PSQLException
(
"postgresql.con.garbled"
);
if
(
fqp
>
0
)
fqp
--;
if
(
fqp
==
0
)
hfr
=
true
;
break
;
case
'N'
:
// Error Notification
connection
.
addWarning
(
pg_stream
.
ReceiveString
(
connection
.
getEncoding
()));
break
;
case
'P'
:
// Portal Name
String
pname
=
pg_stream
.
ReceiveString
(
connection
.
getEncoding
());
break
;
case
'T'
:
// MetaData Field Description
receiveFields
();
break
;
case
'Z'
:
// backend ready for query, ignore for now :-)
break
;
default
:
throw
new
PSQLException
(
"postgresql.con.type"
,
new
Character
((
char
)
c
));
}
}
return
connection
.
getResultSet
(
connection
,
statement
,
fields
,
tuples
,
status
,
update_count
,
insert_oid
,
binaryCursor
);
...
...
@@ -162,7 +162,6 @@ public class QueryExecutor
*/
private
void
receiveCommandStatus
()
throws
SQLException
{
status
=
pg_stream
.
ReceiveString
(
connection
.
getEncoding
());
try
...
...
src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
View file @
09634eaf
...
...
@@ -61,7 +61,6 @@ public class Fastpath
// added Oct 7 1998 to give us thread safety
synchronized
(
stream
)
{
// send the function call
try
{
...
...
@@ -105,52 +104,52 @@ public class Fastpath
//DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
switch
(
in
)
{
case
'V'
:
break
;
case
'V'
:
break
;
//------------------------------
// Function returned properly
//
case
'G'
:
int
sz
=
stream
.
ReceiveIntegerR
(
4
);
//DriverManager.println("G: size="+sz); //debug
//------------------------------
// Function returned properly
//
case
'G'
:
int
sz
=
stream
.
ReceiveIntegerR
(
4
);
//DriverManager.println("G: size="+sz); //debug
// Return an Integer if
if
(
resulttype
)
result
=
new
Integer
(
stream
.
ReceiveIntegerR
(
sz
));
else
{
byte
buf
[]
=
new
byte
[
sz
];
stream
.
Receive
(
buf
,
0
,
sz
);
result
=
buf
;
}
break
;
// Return an Integer if
if
(
resulttype
)
result
=
new
Integer
(
stream
.
ReceiveIntegerR
(
sz
));
else
{
byte
buf
[]
=
new
byte
[
sz
];
stream
.
Receive
(
buf
,
0
,
sz
);
result
=
buf
;
}
break
;
//------------------------------
// Error message returned
case
'E'
:
throw
new
PSQLException
(
"postgresql.fp.error"
,
stream
.
ReceiveString
(
conn
.
getEncoding
()));
//------------------------------
// Error message returned
case
'E'
:
throw
new
PSQLException
(
"postgresql.fp.error"
,
stream
.
ReceiveString
(
conn
.
getEncoding
()));
//------------------------------
// Notice from backend
case
'N'
:
conn
.
addWarning
(
stream
.
ReceiveString
(
conn
.
getEncoding
()));
break
;
//------------------------------
// Notice from backend
case
'N'
:
conn
.
addWarning
(
stream
.
ReceiveString
(
conn
.
getEncoding
()));
break
;
//------------------------------
// End of results
//
// Here we simply return res, which would contain the result
// processed earlier. If no result, this already contains null
case
'0'
:
//DriverManager.println("returning "+result);
return
result
;
//------------------------------
// End of results
//
// Here we simply return res, which would contain the result
// processed earlier. If no result, this already contains null
case
'0'
:
//DriverManager.println("returning "+result);
return
result
;
case
'Z'
:
break
;
case
'Z'
:
break
;
default
:
throw
new
PSQLException
(
"postgresql.fp.protocol"
,
new
Character
((
char
)
in
));
default
:
throw
new
PSQLException
(
"postgresql.fp.protocol"
,
new
Character
((
char
)
in
));
}
}
}
...
...
src/interfaces/jdbc/org/postgresql/geometric/PGpath.java
View file @
09634eaf
...
...
@@ -148,5 +148,4 @@ public class PGpath extends PGobject implements Serializable, Cloneable
{
open
=
true
;
}
}
src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
View file @
09634eaf
This diff is collapsed.
Click to expand it.
src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
View file @
09634eaf
...
...
@@ -617,53 +617,53 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
}
switch
(
targetSqlType
)
{
case
Types
.
TINYINT
:
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
BIGINT
:
case
Types
.
REAL
:
case
Types
.
FLOAT
:
case
Types
.
DOUBLE
:
case
Types
.
DECIMAL
:
case
Types
.
NUMERIC
:
if
(
x
instanceof
Boolean
)
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"1"
:
"0"
);
else
set
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
case
Types
.
LONGVARCHAR
:
setString
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
DATE
:
setDate
(
parameterIndex
,
(
java
.
sql
.
Date
)
x
);
break
;
case
Types
.
TIME
:
setTime
(
parameterIndex
,
(
Time
)
x
);
break
;
case
Types
.
TIMESTAMP
:
setTimestamp
(
parameterIndex
,
(
Timestamp
)
x
);
break
;
case
Types
.
BIT
:
if
(
x
instanceof
Boolean
)
{
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"TRUE"
:
"FALSE"
);
}
else
{
case
Types
.
TINYINT
:
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
BIGINT
:
case
Types
.
REAL
:
case
Types
.
FLOAT
:
case
Types
.
DOUBLE
:
case
Types
.
DECIMAL
:
case
Types
.
NUMERIC
:
if
(
x
instanceof
Boolean
)
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"1"
:
"0"
);
else
set
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
case
Types
.
LONGVARCHAR
:
setString
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
DATE
:
setDate
(
parameterIndex
,
(
java
.
sql
.
Date
)
x
);
break
;
case
Types
.
TIME
:
setTime
(
parameterIndex
,
(
Time
)
x
);
break
;
case
Types
.
TIMESTAMP
:
setTimestamp
(
parameterIndex
,
(
Timestamp
)
x
);
break
;
case
Types
.
BIT
:
if
(
x
instanceof
Boolean
)
{
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"TRUE"
:
"FALSE"
);
}
else
{
throw
new
PSQLException
(
"postgresql.prep.type"
);
}
break
;
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
setObject
(
parameterIndex
,
x
);
break
;
case
Types
.
OTHER
:
setString
(
parameterIndex
,
((
PGobject
)
x
).
getValue
());
break
;
default
:
throw
new
PSQLException
(
"postgresql.prep.type"
);
}
break
;
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
setObject
(
parameterIndex
,
x
);
break
;
case
Types
.
OTHER
:
setString
(
parameterIndex
,
((
PGobject
)
x
).
getValue
());
break
;
default
:
throw
new
PSQLException
(
"postgresql.prep.type"
);
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
View file @
09634eaf
...
...
@@ -394,40 +394,40 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
wasNullFlag
=
(
this_row
[
columnIndex
-
1
]
==
null
);
if
(!
wasNullFlag
)
{
if
(
binaryCursor
)
{
//If the data is already binary then just return it
return
this_row
[
columnIndex
-
1
];
}
else
if
(
connection
.
haveMinimumCompatibleVersion
(
"7.2"
))
{
//Version 7.2 supports the bytea datatype for byte arrays
if
(
fields
[
columnIndex
-
1
].
getPGType
().
equals
(
"bytea"
))
if
(
binaryCursor
)
{
return
PGbytea
.
toBytes
(
getString
(
columnIndex
));
//If the data is already binary then just return it
return
this_row
[
columnIndex
-
1
];
}
else
{
return
this_row
[
columnIndex
-
1
];
}
}
else
{
//Version 7.1 and earlier supports LargeObjects for byte arrays
// Handle OID's as BLOBS
if
(
fields
[
columnIndex
-
1
].
getOID
()
==
26
)
else
if
(
connection
.
haveMinimumCompatibleVersion
(
"7.2"
))
{
LargeObjectManager
lom
=
connection
.
getLargeObjectAPI
();
LargeObject
lob
=
lom
.
open
(
getInt
(
columnIndex
));
byte
buf
[]
=
lob
.
read
(
lob
.
size
());
lob
.
close
();
return
buf
;
//Version 7.2 supports the bytea datatype for byte arrays
if
(
fields
[
columnIndex
-
1
].
getPGType
().
equals
(
"bytea"
))
{
return
PGbytea
.
toBytes
(
getString
(
columnIndex
));
}
else
{
return
this_row
[
columnIndex
-
1
];
}
}
else
{
return
this_row
[
columnIndex
-
1
];
//Version 7.1 and earlier supports LargeObjects for byte arrays
// Handle OID's as BLOBS
if
(
fields
[
columnIndex
-
1
].
getOID
()
==
26
)
{
LargeObjectManager
lom
=
connection
.
getLargeObjectAPI
();
LargeObject
lob
=
lom
.
open
(
getInt
(
columnIndex
));
byte
buf
[]
=
lob
.
read
(
lob
.
size
());
lob
.
close
();
return
buf
;
}
else
{
return
this_row
[
columnIndex
-
1
];
}
}
}
}
return
null
;
}
...
...
@@ -447,10 +447,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
return
null
;
// length == 10: SQL Date
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
try
{
return
java
.
sql
.
Date
.
valueOf
((
s
.
length
()
==
10
)
?
s
:
s
.
substring
(
0
,
10
));
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.baddate"
,
s
);
try
{
return
java
.
sql
.
Date
.
valueOf
((
s
.
length
()
==
10
)
?
s
:
s
.
substring
(
0
,
10
));
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.baddate"
,
s
);
}
}
...
...
@@ -926,43 +929,43 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
switch
(
field
.
getSQLType
())
{
case
Types
.
BIT
:
return
new
Boolean
(
getBoolean
(
columnIndex
));
case
Types
.
SMALLINT
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
INTEGER
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
BIGINT
:
return
new
Long
(
getLong
(
columnIndex
));
case
Types
.
NUMERIC
:
return
getBigDecimal
(
columnIndex
,
((
field
.
getMod
()
-
4
)
&
0xffff
));
case
Types
.
REAL
:
return
new
Float
(
getFloat
(
columnIndex
));
case
Types
.
DOUBLE
:
return
new
Double
(
getDouble
(
columnIndex
));
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
return
getString
(
columnIndex
);
case
Types
.
DATE
:
return
getDate
(
columnIndex
);
case
Types
.
TIME
:
return
getTime
(
columnIndex
);
case
Types
.
TIMESTAMP
:
return
getTimestamp
(
columnIndex
);
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
return
getBytes
(
columnIndex
);
default
:
String
type
=
field
.
getPGType
();
// if the backend doesn't know the type then coerce to String
if
(
type
.
equals
(
"unknown"
))
{
case
Types
.
BIT
:
return
new
Boolean
(
getBoolean
(
columnIndex
));
case
Types
.
SMALLINT
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
INTEGER
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
BIGINT
:
return
new
Long
(
getLong
(
columnIndex
));
case
Types
.
NUMERIC
:
return
getBigDecimal
(
columnIndex
,
((
field
.
getMod
()
-
4
)
&
0xffff
));
case
Types
.
REAL
:
return
new
Float
(
getFloat
(
columnIndex
));
case
Types
.
DOUBLE
:
return
new
Double
(
getDouble
(
columnIndex
));
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
return
getString
(
columnIndex
);
}
else
{
return
connection
.
getObject
(
field
.
getPGType
(),
getString
(
columnIndex
));
}
case
Types
.
DATE
:
return
getDate
(
columnIndex
);
case
Types
.
TIME
:
return
getTime
(
columnIndex
);
case
Types
.
TIMESTAMP
:
return
getTimestamp
(
columnIndex
);
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
return
getBytes
(
columnIndex
);
default
:
String
type
=
field
.
getPGType
();
// if the backend doesn't know the type then coerce to String
if
(
type
.
equals
(
"unknown"
))
{
return
getString
(
columnIndex
);
}
else
{
return
connection
.
getObject
(
field
.
getPGType
(),
getString
(
columnIndex
));
}
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java
View file @
09634eaf
...
...
@@ -78,17 +78,17 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
default
:
return
true
;
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
default
:
return
true
;
}
}
...
...
@@ -112,10 +112,10 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
// for further expansion.
switch
(
sql_type
)
{
case
Types
.
OTHER
:
return
true
;
default
:
return
true
;
case
Types
.
OTHER
:
return
true
;
default
:
return
true
;
}
}
...
...
@@ -167,18 +167,18 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
return
true
;
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
// I don't know about these?
default
:
return
false
;
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
return
true
;
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
// I don't know about these?
default
:
return
false
;
}
}
...
...
@@ -294,26 +294,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
return
5
;
case
Types
.
INTEGER
:
return
10
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
((
0xFFFF0000
)&
f
.
getMod
())
>>
16
;
else
case
Types
.
SMALLINT
:
return
5
;
case
Types
.
INTEGER
:
return
10
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
((
0xFFFF0000
)&
f
.
getMod
())
>>
16
;
else
return
0
;
default
:
return
0
;
default
:
return
0
;
}
}
...
...
@@ -331,26 +331,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
return
0
;
case
Types
.
INTEGER
:
return
0
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
(((
0x0000FFFF
)&
f
.
getMod
())
-
4
);
else
case
Types
.
SMALLINT
:
return
0
;
case
Types
.
INTEGER
:
return
0
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
(((
0x0000FFFF
)&
f
.
getMod
())
-
4
);
else
return
0
;
default
:
return
0
;
default
:
return
0
;
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
View file @
09634eaf
This diff is collapsed.
Click to expand it.
src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
View file @
09634eaf
This diff is collapsed.
Click to expand it.
src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
View file @
09634eaf
...
...
@@ -652,53 +652,53 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
}
switch
(
targetSqlType
)
{
case
Types
.
TINYINT
:
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
BIGINT
:
case
Types
.
REAL
:
case
Types
.
FLOAT
:
case
Types
.
DOUBLE
:
case
Types
.
DECIMAL
:
case
Types
.
NUMERIC
:
if
(
x
instanceof
Boolean
)
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"1"
:
"0"
);
else
set
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
case
Types
.
LONGVARCHAR
:
setString
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
DATE
:
setDate
(
parameterIndex
,
(
java
.
sql
.
Date
)
x
);
break
;
case
Types
.
TIME
:
setTime
(
parameterIndex
,
(
Time
)
x
);
break
;
case
Types
.
TIMESTAMP
:
setTimestamp
(
parameterIndex
,
(
Timestamp
)
x
);
break
;
case
Types
.
BIT
:
if
(
x
instanceof
Boolean
)
{
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"TRUE"
:
"FALSE"
);
}
else
{
case
Types
.
TINYINT
:
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
BIGINT
:
case
Types
.
REAL
:
case
Types
.
FLOAT
:
case
Types
.
DOUBLE
:
case
Types
.
DECIMAL
:
case
Types
.
NUMERIC
:
if
(
x
instanceof
Boolean
)
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"1"
:
"0"
);
else
set
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
case
Types
.
LONGVARCHAR
:
setString
(
parameterIndex
,
x
.
toString
());
break
;
case
Types
.
DATE
:
setDate
(
parameterIndex
,
(
java
.
sql
.
Date
)
x
);
break
;
case
Types
.
TIME
:
setTime
(
parameterIndex
,
(
Time
)
x
);
break
;
case
Types
.
TIMESTAMP
:
setTimestamp
(
parameterIndex
,
(
Timestamp
)
x
);
break
;
case
Types
.
BIT
:
if
(
x
instanceof
Boolean
)
{
set
(
parameterIndex
,
((
Boolean
)
x
).
booleanValue
()
?
"TRUE"
:
"FALSE"
);
}
else
{
throw
new
PSQLException
(
"postgresql.prep.type"
);
}
break
;
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
setObject
(
parameterIndex
,
x
);
break
;
case
Types
.
OTHER
:
setString
(
parameterIndex
,
((
PGobject
)
x
).
getValue
());
break
;
default
:
throw
new
PSQLException
(
"postgresql.prep.type"
);
}
break
;
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
setObject
(
parameterIndex
,
x
);
break
;
case
Types
.
OTHER
:
setString
(
parameterIndex
,
((
PGobject
)
x
).
getValue
());
break
;
default
:
throw
new
PSQLException
(
"postgresql.prep.type"
);
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
View file @
09634eaf
...
...
@@ -321,40 +321,40 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
wasNullFlag
=
(
this_row
[
columnIndex
-
1
]
==
null
);
if
(!
wasNullFlag
)
{
if
(
binaryCursor
)
{
//If the data is already binary then just return it
return
this_row
[
columnIndex
-
1
];
}
else
if
(
connection
.
haveMinimumCompatibleVersion
(
"7.2"
))
{
//Version 7.2 supports the bytea datatype for byte arrays
if
(
fields
[
columnIndex
-
1
].
getPGType
().
equals
(
"bytea"
))
if
(
binaryCursor
)
{
return
PGbytea
.
toBytes
(
getString
(
columnIndex
));
//If the data is already binary then just return it
return
this_row
[
columnIndex
-
1
];
}
else
else
if
(
connection
.
haveMinimumCompatibleVersion
(
"7.2"
))
{
return
this_row
[
columnIndex
-
1
];
}
}
else
{
//Version 7.1 and earlier supports LargeObjects for byte arrays
// Handle OID's as BLOBS
if
(
fields
[
columnIndex
-
1
].
getOID
()
==
26
)
{
LargeObjectManager
lom
=
connection
.
getLargeObjectAPI
();
LargeObject
lob
=
lom
.
open
(
getInt
(
columnIndex
));
byte
buf
[]
=
lob
.
read
(
lob
.
size
());
lob
.
close
();
return
buf
;
//Version 7.2 supports the bytea datatype for byte arrays
if
(
fields
[
columnIndex
-
1
].
getPGType
().
equals
(
"bytea"
))
{
return
PGbytea
.
toBytes
(
getString
(
columnIndex
));
}
else
{
return
this_row
[
columnIndex
-
1
];
}
}
else
{
return
this_row
[
columnIndex
-
1
];
//Version 7.1 and earlier supports LargeObjects for byte arrays
// Handle OID's as BLOBS
if
(
fields
[
columnIndex
-
1
].
getOID
()
==
26
)
{
LargeObjectManager
lom
=
connection
.
getLargeObjectAPI
();
LargeObject
lob
=
lom
.
open
(
getInt
(
columnIndex
));
byte
buf
[]
=
lob
.
read
(
lob
.
size
());
lob
.
close
();
return
buf
;
}
else
{
return
this_row
[
columnIndex
-
1
];
}
}
}
}
return
null
;
}
...
...
@@ -742,44 +742,44 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
switch
(
field
.
getSQLType
())
{
case
Types
.
BIT
:
return
new
Boolean
(
getBoolean
(
columnIndex
));
case
Types
.
SMALLINT
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
INTEGER
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
BIGINT
:
return
new
Long
(
getLong
(
columnIndex
));
case
Types
.
NUMERIC
:
return
getBigDecimal
(
columnIndex
,
(
field
.
getMod
()
==
-
1
)
?
-
1
:
((
field
.
getMod
()
-
4
)
&
0xffff
));
case
Types
.
REAL
:
return
new
Float
(
getFloat
(
columnIndex
));
case
Types
.
DOUBLE
:
return
new
Double
(
getDouble
(
columnIndex
));
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
return
getString
(
columnIndex
);
case
Types
.
DATE
:
return
getDate
(
columnIndex
);
case
Types
.
TIME
:
return
getTime
(
columnIndex
);
case
Types
.
TIMESTAMP
:
return
getTimestamp
(
columnIndex
);
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
return
getBytes
(
columnIndex
);
default
:
String
type
=
field
.
getPGType
();
// if the backend doesn't know the type then coerce to String
if
(
type
.
equals
(
"unknown"
))
{
case
Types
.
BIT
:
return
new
Boolean
(
getBoolean
(
columnIndex
));
case
Types
.
SMALLINT
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
INTEGER
:
return
new
Integer
(
getInt
(
columnIndex
));
case
Types
.
BIGINT
:
return
new
Long
(
getLong
(
columnIndex
));
case
Types
.
NUMERIC
:
return
getBigDecimal
(
columnIndex
,
(
field
.
getMod
()
==
-
1
)
?
-
1
:
((
field
.
getMod
()
-
4
)
&
0xffff
));
case
Types
.
REAL
:
return
new
Float
(
getFloat
(
columnIndex
));
case
Types
.
DOUBLE
:
return
new
Double
(
getDouble
(
columnIndex
));
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
return
getString
(
columnIndex
);
}
else
{
return
connection
.
getObject
(
field
.
getPGType
(),
getString
(
columnIndex
));
}
case
Types
.
DATE
:
return
getDate
(
columnIndex
);
case
Types
.
TIME
:
return
getTime
(
columnIndex
);
case
Types
.
TIMESTAMP
:
return
getTimestamp
(
columnIndex
);
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
return
getBytes
(
columnIndex
);
default
:
String
type
=
field
.
getPGType
();
// if the backend doesn't know the type then coerce to String
if
(
type
.
equals
(
"unknown"
))
{
return
getString
(
columnIndex
);
}
else
{
return
connection
.
getObject
(
field
.
getPGType
(),
getString
(
columnIndex
));
}
}
}
...
...
@@ -1082,7 +1082,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
if
(
current_row
<
0
||
current_row
>=
rows_size
)
return
0
;
return
current_row
+
1
;
}
...
...
@@ -1565,10 +1565,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
return
null
;
// length == 10: SQL Date
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
try
{
return
java
.
sql
.
Date
.
valueOf
((
s
.
length
()
==
10
)
?
s
:
s
.
substring
(
0
,
10
));
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.baddate"
,
s
);
try
{
return
java
.
sql
.
Date
.
valueOf
((
s
.
length
()
==
10
)
?
s
:
s
.
substring
(
0
,
10
));
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.baddate"
,
s
);
}
}
...
...
@@ -1578,10 +1581,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
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
));
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.badtime"
,
s
);
try
{
return
java
.
sql
.
Time
.
valueOf
((
s
.
length
()
==
8
)
?
s
:
s
.
substring
(
11
,
19
));
}
catch
(
NumberFormatException
e
)
{
throw
new
PSQLException
(
"postgresql.res.badtime"
,
s
);
}
}
...
...
@@ -1628,7 +1634,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
char
sub
=
resultSet
.
sbuf
.
charAt
(
resultSet
.
sbuf
.
length
()
-
3
);
if
(
sub
==
'+'
||
sub
==
'-'
)
{
//we have found timezone info of format +/-HH
//we have found timezone info of format +/-HH
resultSet
.
sbuf
.
setLength
(
resultSet
.
sbuf
.
length
()
-
3
);
if
(
subsecond
)
...
...
@@ -1639,22 +1645,28 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
{
resultSet
.
sbuf
.
append
(
"GMT"
).
append
(
s
.
substring
(
s
.
length
()
-
3
)).
append
(
":00"
);
}
}
else
if
(
sub
==
':'
)
{
//we may have found timezone info of format +/-HH:MM, or there is no
//timezone info at all and this is the : preceding the seconds
char
sub2
=
resultSet
.
sbuf
.
charAt
(
resultSet
.
sbuf
.
length
()-
5
);
if
(
sub2
==
'+'
||
sub2
==
'-'
)
}
else
if
(
sub
==
':'
)
{
//we may have found timezone info of format +/-HH:MM, or there is no
//timezone info at all and this is the : preceding the seconds
char
sub2
=
resultSet
.
sbuf
.
charAt
(
resultSet
.
sbuf
.
length
()
-
5
);
if
(
sub2
==
'+'
||
sub2
==
'-'
)
{
//we have found timezone info of format +/-HH:MM
resultSet
.
sbuf
.
setLength
(
resultSet
.
sbuf
.
length
()-
5
);
if
(
subsecond
)
//we have found timezone info of format +/-HH:MM
resultSet
.
sbuf
.
setLength
(
resultSet
.
sbuf
.
length
()
-
5
);
if
(
subsecond
)
{
resultSet
.
sbuf
.
append
(
'0'
).
append
(
"GMT"
).
append
(
s
.
substring
(
s
.
length
()-
5
));
}
else
{
resultSet
.
sbuf
.
append
(
"GMT"
).
append
(
s
.
substring
(
s
.
length
()-
5
));
resultSet
.
sbuf
.
append
(
'0'
).
append
(
"GMT"
).
append
(
s
.
substring
(
s
.
length
()
-
5
));
}
}
else
if
(
subsecond
)
{
resultSet
.
sbuf
.
append
(
'0'
);
else
{
resultSet
.
sbuf
.
append
(
"GMT"
).
append
(
s
.
substring
(
s
.
length
()
-
5
));
}
}
else
if
(
subsecond
)
{
resultSet
.
sbuf
.
append
(
'0'
);
}
}
else
if
(
subsecond
)
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java
View file @
09634eaf
...
...
@@ -73,17 +73,17 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
default
:
return
true
;
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
default
:
return
true
;
}
}
...
...
@@ -107,10 +107,10 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
// for further expansion.
switch
(
sql_type
)
{
case
Types
.
OTHER
:
return
true
;
default
:
return
true
;
case
Types
.
OTHER
:
return
true
;
default
:
return
true
;
}
}
...
...
@@ -162,18 +162,18 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
return
true
;
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
// I don't know about these?
default
:
return
false
;
case
Types
.
SMALLINT
:
case
Types
.
INTEGER
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
return
true
;
case
Types
.
DATE
:
case
Types
.
TIME
:
case
Types
.
TIMESTAMP
:
return
false
;
// I don't know about these?
default
:
return
false
;
}
}
...
...
@@ -289,26 +289,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
return
5
;
case
Types
.
INTEGER
:
return
10
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
((
0xFFFF0000
)&
f
.
getMod
())
>>
16
;
else
case
Types
.
SMALLINT
:
return
5
;
case
Types
.
INTEGER
:
return
10
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
((
0xFFFF0000
)&
f
.
getMod
())
>>
16
;
else
return
0
;
default
:
return
0
;
default
:
return
0
;
}
}
...
...
@@ -326,26 +326,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
switch
(
sql_type
)
{
case
Types
.
SMALLINT
:
return
0
;
case
Types
.
INTEGER
:
return
0
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
(((
0x0000FFFF
)&
f
.
getMod
())
-
4
);
else
case
Types
.
SMALLINT
:
return
0
;
case
Types
.
INTEGER
:
return
0
;
case
Types
.
REAL
:
return
8
;
case
Types
.
FLOAT
:
return
16
;
case
Types
.
DOUBLE
:
return
16
;
case
Types
.
VARCHAR
:
return
0
;
case
Types
.
NUMERIC
:
Field
f
=
getField
(
column
);
if
(
f
!=
null
)
return
(((
0x0000FFFF
)&
f
.
getMod
())
-
4
);
else
return
0
;
default
:
return
0
;
default
:
return
0
;
}
}
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java
View file @
09634eaf
...
...
@@ -8,7 +8,7 @@ import java.sql.*;
import
org.postgresql.largeobject.*
;
/*
* $Id: BlobTest.java,v 1.
4 2001/11/19 22:33:39
momjian Exp $
* $Id: BlobTest.java,v 1.
5 2001/11/19 23:16:46
momjian Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
...
...
@@ -108,36 +108,36 @@ public class BlobTest extends TestCase
switch
(
method
)
{
case
LOOP:
buf
=
new
byte
[
2048
];
t
=
0
;
while
((
s
=
fis
.
read
(
buf
,
0
,
buf
.
length
))
>
0
)
{
t
+=
s
;
blob
.
write
(
buf
,
0
,
s
);
}
break
;
case
NATIVE_STREAM:
os
=
blob
.
getOutputStream
();
s
=
fis
.
read
();
while
(
s
>
-
1
)
{
os
.
write
(
s
);
case
LOOP:
buf
=
new
byte
[
2048
];
t
=
0
;
while
((
s
=
fis
.
read
(
buf
,
0
,
buf
.
length
))
>
0
)
{
t
+=
s
;
blob
.
write
(
buf
,
0
,
s
);
}
break
;
case
NATIVE_STREAM:
os
=
blob
.
getOutputStream
();
s
=
fis
.
read
();
}
os
.
close
();
break
;
case
JDBC_STREAM:
File
f
=
new
File
(
file
);
PreparedStatement
ps
=
con
.
prepareStatement
(
JDBC2Tests
.
insertSQL
(
"testblob"
,
"?"
));
ps
.
setBinaryStream
(
1
,
fis
,
(
int
)
f
.
length
());
ps
.
execute
();
break
;
default
:
assertTrue
(
"Unknown method in uploadFile"
,
false
);
while
(
s
>
-
1
)
{
os
.
write
(
s
);
s
=
fis
.
read
();
}
os
.
close
();
break
;
case
JDBC_STREAM:
File
f
=
new
File
(
file
);
PreparedStatement
ps
=
con
.
prepareStatement
(
JDBC2Tests
.
insertSQL
(
"testblob"
,
"?"
));
ps
.
setBinaryStream
(
1
,
fis
,
(
int
)
f
.
length
());
ps
.
execute
();
break
;
default
:
assertTrue
(
"Unknown method in uploadFile"
,
false
);
}
blob
.
close
();
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
View file @
09634eaf
...
...
@@ -21,7 +21,7 @@ public class ResultSetTest extends TestCase
{
con
=
JDBC2Tests
.
openDB
();
Statement
stmt
=
con
.
createStatement
();
JDBC2Tests
.
createTable
(
con
,
"testrs"
,
"id integer"
);
stmt
.
executeUpdate
(
"INSERT INTO testrs VALUES (1)"
);
...
...
@@ -44,23 +44,23 @@ public class ResultSetTest extends TestCase
{
Statement
stmt
=
con
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"SELECT * FROM testrs"
);
assertTrue
(
rs
.
absolute
(-
1
));
assertTrue
(
rs
.
absolute
(
-
1
));
assertEquals
(
6
,
rs
.
getRow
());
assertTrue
(
rs
.
absolute
(
1
));
assertEquals
(
1
,
rs
.
getRow
());
assertTrue
(!
rs
.
absolute
(-
10
));
assertTrue
(!
rs
.
absolute
(
-
10
));
assertEquals
(
0
,
rs
.
getRow
());
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getRow
());
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getRow
());
assertTrue
(!
rs
.
absolute
(
10
));
assertEquals
(
0
,
rs
.
getRow
());
assertTrue
(
rs
.
previous
());
assertEquals
(
6
,
rs
.
getRow
());
stmt
.
close
();
}
}
src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
View file @
09634eaf
...
...
@@ -77,6 +77,7 @@ public class PGtokenizer
// Don't forget the last token ;-)
if
(
s
<
string
.
length
())
tokens
.
addElement
(
string
.
substring
(
s
));
...
...
src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java
View file @
09634eaf
...
...
@@ -40,7 +40,7 @@
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: XADataSourceImpl.java,v 1.
3 2001/11/19 22:33:39
momjian Exp $
* $Id: XADataSourceImpl.java,v 1.
4 2001/11/19 23:16:46
momjian Exp $
*/
...
...
@@ -379,6 +379,7 @@ public abstract class XADataSourceImpl
// Look for all connections inside a transaction that
// should have timed out by now.
timeout
=
System
.
currentTimeMillis
();
enum
=
_txConnections
.
elements
();
while
(
enum
.
hasMoreElements
()
)
...
...
src/tools/pgindent/pgjindent
View file @
09634eaf
...
...
@@ -16,7 +16,7 @@ fi
for
FILE
do
astyle
--style
=
java
-b
-p
-j
<
"
$FILE
"
>
/tmp/
$$
2>/tmp/
$$
a
astyle
--style
=
java
-b
-p
-j
-S
<
"
$FILE
"
>
/tmp/
$$
2>/tmp/
$$
a
if
[
"
$?
"
-ne
0
-o
-s
/tmp/
$$
a
]
then
echo
"
$FILE
"
cat
/tmp/
$$
a
...
...
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