File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed
src/main/java/com/github/pgasync Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,14 @@ public byte getMessageId() {
5454 @ Override
5555 public CommandComplete read (ByteBuffer buffer , Charset encoding ) {
5656 String tag = getCString (buffer , encoding );
57- return new CommandComplete (tag );
57+ int affectedRows ;
58+ if (tag .contains ("INSERT" ) || tag .contains ("UPDATE" ) || tag .contains ("DELETE" )) {
59+ String [] parts = tag .split (" " );
60+ affectedRows = Integer .parseInt (parts [parts .length - 1 ]);
61+ } else {
62+ affectedRows = 0 ;
63+ }
64+ return new CommandComplete (tag , affectedRows );
5865 }
5966
6067}
Original file line number Diff line number Diff line change 1717import com .github .pgasync .message .Message ;
1818
1919/**
20- * @author Antti Laisi
20+ * @author Antti Laisi
2121 */
2222public class CommandComplete implements Message {
2323
24+ private final String tag ;
2425 private final int affectedRows ;
2526
26- public CommandComplete (String tag ) {
27- if ( tag . contains ( "INSERT" ) || tag . contains ( "UPDATE" ) || tag . contains ( "DELETE" )) {
28- String [] parts = tag . split ( " " ) ;
29- affectedRows = Integer . parseInt ( parts [ parts . length - 1 ]);
30- } else {
31- affectedRows = 0 ;
32- }
27+ public CommandComplete (String tag , int affectedRows ) {
28+ this . tag = tag ;
29+ this . affectedRows = affectedRows ;
30+ }
31+
32+ public String getTag () {
33+ return tag ;
3334 }
3435
3536 public int getAffectedRows () {
@@ -38,6 +39,9 @@ public int getAffectedRows() {
3839
3940 @ Override
4041 public String toString () {
41- return String .format ("CommandComplete(affectedRows=%d)" , affectedRows );
42+ return "CommandComplete(" +
43+ "tag='" + tag + '\'' +
44+ ", affectedRows=" + affectedRows +
45+ ')' ;
4246 }
4347}
You can’t perform that action at this time.
0 commit comments