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
efea5da4
Commit
efea5da4
authored
Nov 03, 2003
by
Dave Cramer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accept url and fk action fix from Kris Jurka
parent
90e53f0c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
11 deletions
+52
-11
src/interfaces/jdbc/org/postgresql/Driver.java.in
src/interfaces/jdbc/org/postgresql/Driver.java.in
+9
-5
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
...c/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
+3
-1
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
...ces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
+4
-3
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
.../jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
+33
-1
src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java
...interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java
+3
-1
No files found.
src/interfaces/jdbc/org/postgresql/Driver.java.in
View file @
efea5da4
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
Copyright
(
c
)
2003
,
PostgreSQL
Global
Development
Group
*
Copyright
(
c
)
2003
,
PostgreSQL
Global
Development
Group
*
*
*
IDENTIFICATION
*
IDENTIFICATION
*
$
Header
:
/
cvsroot
/
pgsql
/
src
/
interfaces
/
jdbc
/
org
/
postgresql
/
Attic
/
Driver
.
java
.
in
,
v
1.3
6
2003
/
09
/
13
04
:
02
:
12
barry
Exp
$
*
$
Header
:
/
cvsroot
/
pgsql
/
src
/
interfaces
/
jdbc
/
org
/
postgresql
/
Attic
/
Driver
.
java
.
in
,
v
1.3
7
2003
/
11
/
03
15
:
22
:
06
davec
Exp
$
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -111,7 +111,7 @@ public class Driver implements java.sql.Driver
...
@@ -111,7 +111,7 @@ public class Driver implements java.sql.Driver
*
*
*
Our
protocol
takes
the
forms
:
*
Our
protocol
takes
the
forms
:
*
<
PRE
>
*
<
PRE
>
*
jdbc
:
org
.
postgresql
://
host
:
port
/
database
?
param1
=
val1
&...
*
jdbc
:
postgresql
://
host
:
port
/
database
?
param1
=
val1
&...
*
</
PRE
>
*
</
PRE
>
*
*
*
@
param
url
the
URL
of
the
database
to
connect
to
*
@
param
url
the
URL
of
the
database
to
connect
to
...
@@ -163,7 +163,7 @@ public class Driver implements java.sql.Driver
...
@@ -163,7 +163,7 @@ public class Driver implements java.sql.Driver
*
Returns
true
if
the
driver
thinks
it
can
open
a
connection
to
the
*
Returns
true
if
the
driver
thinks
it
can
open
a
connection
to
the
*
given
URL
.
Typically
,
drivers
will
return
true
if
they
understand
*
given
URL
.
Typically
,
drivers
will
return
true
if
they
understand
*
the
subprotocol
specified
in
the
URL
and
false
if
they
don
't. Our
*
the
subprotocol
specified
in
the
URL
and
false
if
they
don
't. Our
* protocols start with jdbc:
org.
postgresql:
* protocols start with jdbc:postgresql:
*
*
* @see java.sql.Driver#acceptsURL
* @see java.sql.Driver#acceptsURL
* @param url the URL of the driver
* @param url the URL of the driver
...
@@ -286,7 +286,8 @@ public class Driver implements java.sql.Driver
...
@@ -286,7 +286,8 @@ public class Driver implements java.sql.Driver
//parse the server part of the url
//parse the server part of the url
StringTokenizer st = new StringTokenizer(l_urlServer, ":/", true);
StringTokenizer st = new StringTokenizer(l_urlServer, ":/", true);
for (int count = 0; (st.hasMoreTokens()); count++)
int count;
for (count = 0; (st.hasMoreTokens()); count++)
{
{
String token = st.nextToken();
String token = st.nextToken();
...
@@ -357,6 +358,9 @@ public class Driver implements java.sql.Driver
...
@@ -357,6 +358,9 @@ public class Driver implements java.sql.Driver
}
}
}
}
}
}
if (count <= 1) {
return null;
}
// if we extracted an IPv6 address out earlier put it back
// if we extracted an IPv6 address out earlier put it back
if (ipv6address != null)
if (ipv6address != null)
...
@@ -364,7 +368,7 @@ public class Driver implements java.sql.Driver
...
@@ -364,7 +368,7 @@ public class Driver implements java.sql.Driver
//parse the args part of the url
//parse the args part of the url
StringTokenizer qst = new StringTokenizer(l_urlArgs, "&");
StringTokenizer qst = new StringTokenizer(l_urlArgs, "&");
for (
int
count = 0; (qst.hasMoreTokens()); count++)
for (count = 0; (qst.hasMoreTokens()); count++)
{
{
String token = qst.nextToken();
String token = qst.nextToken();
int l_pos = token.indexOf('
=
');
int l_pos = token.indexOf('
=
');
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
View file @
efea5da4
...
@@ -3114,7 +3114,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
...
@@ -3114,7 +3114,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
if
(
deleteRule
!=
null
)
if
(
deleteRule
!=
null
)
{
{
String
rule
=
updateRule
.
substring
(
8
,
upda
teRule
.
length
()
-
4
);
String
rule
=
deleteRule
.
substring
(
8
,
dele
teRule
.
length
()
-
4
);
int
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeyNoAction
;
int
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeyNoAction
;
if
(
"cascade"
.
equals
(
rule
))
if
(
"cascade"
.
equals
(
rule
))
...
@@ -3123,6 +3123,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
...
@@ -3123,6 +3123,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeySetNull
;
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeySetNull
;
else
if
(
"setdefault"
.
equals
(
rule
))
else
if
(
"setdefault"
.
equals
(
rule
))
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeySetDefault
;
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeySetDefault
;
else
if
(
"restrict"
.
equals
(
rule
))
action
=
java
.
sql
.
DatabaseMetaData
.
importedKeyRestrict
;
tuple
[
10
]
=
Integer
.
toString
(
action
).
getBytes
();
tuple
[
10
]
=
Integer
.
toString
(
action
).
getBytes
();
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
View file @
efea5da4
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
* Copyright (c) 2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.2
2 2003/10/29 02:39:09
davec Exp $
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.2
3 2003/11/03 15:22:07
davec Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -210,8 +210,8 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
...
@@ -210,8 +210,8 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
public
byte
getByte
(
int
columnIndex
)
throws
SQLException
public
byte
getByte
(
int
columnIndex
)
throws
SQLException
{
{
String
s
=
getString
(
columnIndex
);
String
s
=
getString
(
columnIndex
);
if
(
s
!=
null
)
if
(
s
!=
null
)
{
{
try
try
{
{
...
@@ -232,6 +232,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
...
@@ -232,6 +232,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
s
=
s
.
trim
();
s
=
s
.
trim
();
break
;
break
;
}
}
if
(
s
.
length
()
==
0
)
return
0
;
return
Byte
.
parseByte
(
s
);
return
Byte
.
parseByte
(
s
);
}
}
catch
(
NumberFormatException
e
)
catch
(
NumberFormatException
e
)
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
View file @
efea5da4
...
@@ -9,7 +9,7 @@ import java.sql.*;
...
@@ -9,7 +9,7 @@ import java.sql.*;
*
*
* PS: Do you know how difficult it is to type on a train? ;-)
* PS: Do you know how difficult it is to type on a train? ;-)
*
*
* $Id: DatabaseMetaDataTest.java,v 1.1
8 2003/05/29 04:39:48 barry
Exp $
* $Id: DatabaseMetaDataTest.java,v 1.1
9 2003/11/03 15:22:07 davec
Exp $
*/
*/
public
class
DatabaseMetaDataTest
extends
TestCase
public
class
DatabaseMetaDataTest
extends
TestCase
...
@@ -137,6 +137,38 @@ public class DatabaseMetaDataTest extends TestCase
...
@@ -137,6 +137,38 @@ public class DatabaseMetaDataTest extends TestCase
fail
(
ex
.
getMessage
());
fail
(
ex
.
getMessage
());
}
}
}
}
public
void
testForeignKeyActions
()
{
try
{
Connection
conn
=
TestUtil
.
openDB
();
TestUtil
.
createTable
(
conn
,
"pkt"
,
"id int primary key"
);
TestUtil
.
createTable
(
conn
,
"fkt1"
,
"id int references pkt on update restrict on delete cascade"
);
TestUtil
.
createTable
(
conn
,
"fkt2"
,
"id int references pkt on update set null on delete set default"
);
DatabaseMetaData
dbmd
=
conn
.
getMetaData
();
ResultSet
rs
=
dbmd
.
getImportedKeys
(
null
,
""
,
"fkt1"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
getInt
(
"UPDATE_RULE"
)
==
DatabaseMetaData
.
importedKeyRestrict
);
assertTrue
(
rs
.
getInt
(
"DELETE_RULE"
)
==
DatabaseMetaData
.
importedKeyCascade
);
rs
.
close
();
rs
=
dbmd
.
getImportedKeys
(
null
,
""
,
"fkt2"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
getInt
(
"UPDATE_RULE"
)
==
DatabaseMetaData
.
importedKeySetNull
);
assertTrue
(
rs
.
getInt
(
"DELETE_RULE"
)
==
DatabaseMetaData
.
importedKeySetDefault
);
rs
.
close
();
TestUtil
.
dropTable
(
conn
,
"fkt2"
);
TestUtil
.
dropTable
(
conn
,
"fkt1"
);
TestUtil
.
dropTable
(
conn
,
"pkt"
);
}
catch
(
SQLException
ex
)
{
fail
(
ex
.
getMessage
());
}
}
public
void
testForeignKeys
()
public
void
testForeignKeys
()
{
{
try
try
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java
View file @
efea5da4
...
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
...
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import
java.sql.*
;
import
java.sql.*
;
/*
/*
* $Id: DriverTest.java,v 1.
5 2002/08/14 20:35:40 barry
Exp $
* $Id: DriverTest.java,v 1.
6 2003/11/03 15:22:07 davec
Exp $
*
*
* Tests the dynamically created class org.postgresql.Driver
* Tests the dynamically created class org.postgresql.Driver
*
*
...
@@ -37,10 +37,12 @@ public class DriverTest extends TestCase
...
@@ -37,10 +37,12 @@ public class DriverTest extends TestCase
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://localhost:5432/test"
));
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://localhost:5432/test"
));
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://127.0.0.1/anydbname"
));
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://127.0.0.1/anydbname"
));
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://127.0.0.1:5433/hidden"
));
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://127.0.0.1:5433/hidden"
));
assertTrue
(
drv
.
acceptsURL
(
"jdbc:postgresql://[::1]:5740/db"
));
// Badly formatted url's
// Badly formatted url's
assertTrue
(!
drv
.
acceptsURL
(
"jdbc:postgres:test"
));
assertTrue
(!
drv
.
acceptsURL
(
"jdbc:postgres:test"
));
assertTrue
(!
drv
.
acceptsURL
(
"postgresql:test"
));
assertTrue
(!
drv
.
acceptsURL
(
"postgresql:test"
));
assertTrue
(!
drv
.
acceptsURL
(
"db"
));
}
}
catch
(
SQLException
ex
)
catch
(
SQLException
ex
)
...
...
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