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
605c1e6d
Commit
605c1e6d
authored
Dec 12, 2003
by
Dave Cramer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cancel row updates sets values to null by Kris Jurka
parent
06ec9044
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
17 deletions
+74
-17
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
...ces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+10
-5
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
.../jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
+64
-12
No files found.
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
View file @
605c1e6d
...
...
@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.2
7 2003/11/29 19:52:10 pgsql
Exp $
* $PostgreSQL: pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.2
8 2003/12/12 18:34:14 davec
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -519,7 +519,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
{
doingUpdates
=
false
;
clearRowBuffer
();
clearRowBuffer
(
true
);
}
}
...
...
@@ -662,7 +662,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
this_row
=
rowBuffer
;
// need to clear this in case of another insert
clearRowBuffer
();
clearRowBuffer
(
false
);
}
...
...
@@ -707,7 +707,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
// make sure the underlying data is null
clearRowBuffer
();
clearRowBuffer
(
false
);
onInsertRow
=
true
;
doingUpdates
=
false
;
...
...
@@ -715,12 +715,17 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
private
synchronized
void
clearRowBuffer
()
private
synchronized
void
clearRowBuffer
(
boolean
copyCurrentRow
)
throws
SQLException
{
// rowBuffer is the temporary storage for the row
rowBuffer
=
new
byte
[
fields
.
length
][];
// inserts want an empty array while updates want a copy of the current row
if
(
copyCurrentRow
)
{
System
.
arraycopy
(
this_row
,
0
,
rowBuffer
,
0
,
this_row
.
length
);
}
// clear the updateValues hashTable for the next set of updates
updateValues
.
clear
();
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
View file @
605c1e6d
...
...
@@ -15,25 +15,79 @@ import org.postgresql.test.TestUtil;
public
class
UpdateableResultTest
extends
TestCase
{
private
Connection
con
;
public
UpdateableResultTest
(
String
name
)
{
super
(
name
);
}
protected
void
setUp
()
throws
Exception
{
con
=
TestUtil
.
openDB
();
TestUtil
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
TestUtil
.
createTable
(
con
,
"second"
,
"id1 int primary key, name1 text"
);
// put some dummy data into second
Statement
st2
=
con
.
createStatement
();
st2
.
execute
(
"insert into second values (1,'anyvalue' )"
);
st2
.
close
();
}
protected
void
tearDown
()
throws
Exception
{
TestUtil
.
dropTable
(
con
,
"updateable"
);
TestUtil
.
dropTable
(
con
,
"second"
);
TestUtil
.
closeDB
(
con
);
}
public
void
testCancelRowUpdates
()
throws
Exception
{
Statement
st
=
con
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_UPDATABLE
);
ResultSet
rs
=
st
.
executeQuery
(
"select * from second"
);
// make sure we're dealing with the correct row.
rs
.
first
();
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"anyvalue"
,
rs
.
getString
(
2
));
// update, cancel and make sure nothings changed.
rs
.
updateInt
(
1
,
99
);
rs
.
cancelRowUpdates
();
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"anyvalue"
,
rs
.
getString
(
2
));
// real update
rs
.
updateInt
(
1
,
999
);
rs
.
updateRow
();
assertEquals
(
999
,
rs
.
getInt
(
1
));
assertEquals
(
"anyvalue"
,
rs
.
getString
(
2
));
// scroll some and make sure the update is still there
rs
.
beforeFirst
();
rs
.
next
();
assertEquals
(
999
,
rs
.
getInt
(
1
));
assertEquals
(
"anyvalue"
,
rs
.
getString
(
2
));
// make sure the update got to the db and the driver isn't lying to us.
rs
.
close
();
rs
=
st
.
executeQuery
(
"select * from second"
);
rs
.
first
();
assertEquals
(
999
,
rs
.
getInt
(
1
));
assertEquals
(
"anyvalue"
,
rs
.
getString
(
2
));
rs
.
close
();
st
.
close
();
}
public
void
testUpdateable
()
{
try
{
Connection
con
=
TestUtil
.
openDB
();
TestUtil
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
TestUtil
.
createTable
(
con
,
"second"
,
"id1 int primary key, name1 text"
);
// put some dummy data into second
Statement
st2
=
con
.
createStatement
();
st2
.
execute
(
"insert into second values (1,'anyvalue' )"
);
st2
.
close
();
Statement
st
=
con
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_UPDATABLE
);
ResultSet
rs
=
st
.
executeQuery
(
"select * from updateable"
);
assertNotNull
(
rs
);
...
...
@@ -123,12 +177,10 @@ public class UpdateableResultTest extends TestCase
st
.
close
();
TestUtil
.
dropTable
(
con
,
"updateable"
);
TestUtil
.
dropTable
(
con
,
"second"
);
TestUtil
.
closeDB
(
con
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
fail
(
ex
.
getMessage
());
}
}
...
...
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