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
1292467d
Commit
1292467d
authored
May 16, 2001
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backpatch getImportedKeys to jdbc1.
parent
aad93fb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
4 deletions
+110
-4
src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
...nterfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
+110
-3
src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
...nterfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
+0
-1
No files found.
src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
View file @
1292467d
...
...
@@ -1048,7 +1048,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
/**
* Can statements remain open across commits? They may, but
* this driver cannot guarentee that. In further reflection.
* we are talking a Statement object
j
ere, so the answer is
* we are talking a Statement object
h
ere, so the answer is
* yes, since the Statement is only a vehicle to ExecSQL()
*
* @return true if they always remain open; false otherwise
...
...
@@ -2183,6 +2183,82 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
);
}
private
Vector
importLoop
(
java
.
sql
.
ResultSet
keyRelation
)
throws
SQLException
{
String
s
,
s2
;
String
origTable
=
null
,
primTable
=
new
String
(
""
),
schema
;
int
i
;
Vector
v
;
s
=
keyRelation
.
getString
(
1
);
s2
=
s
;
System
.
out
.
println
(
s
);
v
=
new
Vector
();
for
(
i
=
0
;;
i
++)
{
s
=
s
.
substring
(
s
.
indexOf
(
"\\000"
)+
4
);
if
(
s
.
compareTo
(
""
)==
0
)
{
System
.
out
.
println
();
break
;
}
s2
=
s
.
substring
(
0
,
s
.
indexOf
(
"\\000"
));
switch
(
i
)
{
case
0
:
origTable
=
s2
;
break
;
case
1
:
primTable
=
s2
;
break
;
case
2
:
schema
=
s2
;
break
;
default
:
v
.
add
(
s2
);
}
}
java
.
sql
.
ResultSet
rstmp
=
connection
.
ExecSQL
(
"select * from "
+
origTable
+
" where 1=0"
);
java
.
sql
.
ResultSetMetaData
origCols
=
rstmp
.
getMetaData
();
String
stmp
;
Vector
tuples
=
new
Vector
();
byte
tuple
[][];
// the foreign keys are only on even positions in the Vector.
for
(
i
=
0
;
i
<
v
.
size
();
i
+=
2
)
{
stmp
=(
String
)
v
.
elementAt
(
i
);
for
(
int
j
=
1
;
j
<=
origCols
.
getColumnCount
();
j
++)
{
if
(
stmp
.
compareTo
(
origCols
.
getColumnName
(
j
))==
0
)
{
tuple
=
new
byte
[
14
][
0
];
for
(
int
k
=
0
;
k
<
14
;
k
++)
tuple
[
k
]=
null
;
//PKTABLE_NAME
tuple
[
2
]=
primTable
.
getBytes
();
//PKTABLE_COLUMN
stmp
=(
String
)
v
.
elementAt
(
i
+
1
);
tuple
[
3
]=
stmp
.
getBytes
();
//FKTABLE_NAME
tuple
[
6
]=
origTable
.
getBytes
();
//FKCOLUMN_NAME
tuple
[
7
]=
origCols
.
getColumnName
(
j
).
getBytes
();
//KEY_SEQ
tuple
[
8
]=
Integer
.
toString
(
j
).
getBytes
();
tuples
.
add
(
tuple
);
System
.
out
.
println
(
origCols
.
getColumnName
(
j
)+
": "
+
j
+
" -> "
+
primTable
+
": "
+
(
String
)
v
.
elementAt
(
i
+
1
));
break
;
}
}
}
return
tuples
;
}
/**
* Get a description of the primary key columns that are
* referenced by a table's foreign key columns (the primary keys
...
...
@@ -2236,8 +2312,39 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public
java
.
sql
.
ResultSet
getImportedKeys
(
String
catalog
,
String
schema
,
String
table
)
throws
SQLException
{
// XXX-Not Implemented
return
null
;
// Added by Ola Sundell <ola@miranda.org>
// FIXME: error checking galore!
java
.
sql
.
ResultSet
rsret
;
Field
f
[]=
new
Field
[
14
];
byte
tuple
[][];
f
[
0
]=
new
Field
(
connection
,
"PKTABLE_CAT"
,
iVarcharOid
,
32
);
f
[
1
]=
new
Field
(
connection
,
"PKTABLE_SCHEM"
,
iVarcharOid
,
32
);
f
[
2
]=
new
Field
(
connection
,
"PKTABLE_NAME"
,
iVarcharOid
,
32
);
f
[
3
]=
new
Field
(
connection
,
"PKCOLUMN_NAME"
,
iVarcharOid
,
32
);
f
[
4
]=
new
Field
(
connection
,
"FKTABLE_CAT"
,
iVarcharOid
,
32
);
f
[
5
]=
new
Field
(
connection
,
"FKTABLE_SCHEM"
,
iVarcharOid
,
32
);
f
[
6
]=
new
Field
(
connection
,
"FKTABLE_NAME"
,
iVarcharOid
,
32
);
f
[
7
]=
new
Field
(
connection
,
"FKCOLUMN_NAME"
,
iVarcharOid
,
32
);
f
[
8
]=
new
Field
(
connection
,
"KEY_SEQ"
,
iInt2Oid
,
2
);
f
[
9
]=
new
Field
(
connection
,
"UPDATE_RULE"
,
iInt2Oid
,
2
);
f
[
10
]=
new
Field
(
connection
,
"DELETE_RULE"
,
iInt2Oid
,
2
);
f
[
11
]=
new
Field
(
connection
,
"FK_NAME"
,
iVarcharOid
,
32
);
f
[
12
]=
new
Field
(
connection
,
"PK_NAME"
,
iVarcharOid
,
32
);
f
[
13
]=
new
Field
(
connection
,
"DEFERRABILITY"
,
iInt2Oid
,
2
);
java
.
sql
.
ResultSet
rs
=
connection
.
ExecSQL
(
"select t.tgargs "
+
"from pg_class as c, pg_trigger as t "
+
"where c.relname like '"
+
table
+
"' and c.relfilenode=t.tgrelid"
);
Vector
tuples
=
new
Vector
();
while
(
rs
.
next
())
{
tuples
.
addAll
(
importLoop
(
rs
));
}
rsret
=
new
ResultSet
(
connection
,
f
,
tuples
,
"OK"
,
1
);
return
rsret
;
}
/**
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
View file @
1292467d
...
...
@@ -2764,4 +2764,3 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
}
}
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