-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ntj/nuo db data reader #37
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ private void InitResultSet(int handle, EncodedDataStream dataStream, bool readCo | |
this.values = new Value[numberColumns]; | ||
this.closed = false; | ||
this.currentRow = 0; | ||
this.afterLast = false; | ||
// this.afterLast = false; | ||
this.declaredColumnTypes = null; | ||
this.declaredColumnTypeNames = null; | ||
|
||
|
@@ -93,6 +93,9 @@ private void InitResultSet(int handle, EncodedDataStream dataStream, bool readCo | |
//RemPreparedStatement ps = (RemPreparedStatement)statement; | ||
//columnNames = ps.columnNames; | ||
} | ||
|
||
// Set afterLast to true if the ResultSet is empty. | ||
this.afterLast = (this.pendingRows == null || this.pendingRows.getInt() == 0); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
|
@@ -307,14 +310,17 @@ public override bool NextResult() | |
|
||
public override bool Read() | ||
{ | ||
if (this.pendingRows == null) | ||
// Currently, afterLast can only be false if pendingRows was non-null in InitResultSet(); | ||
// - but InitResultSet could be changed in the future. | ||
if (afterLast || pendingRows == null) | ||
return false; | ||
|
||
//int maxRows = statement == null ? 0 : statement.MaxRows; | ||
int maxRows = 0; | ||
int maxRows = 0; // this local maxRows HIDES this.maxRows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this variable is hiding a class field, why not rename it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I regard this as a hack, It was in the original code - I didn't make this change originally. I left this highly dubious code for now, because I wanted just to implement the needed feature in this PR - and not get embroiled in cleaning this code up and ensuring the correct behaviour remains. In a later PR, I will fix this code by removing the hiding, and cleaning up the code that relies on the hidden var. To answer you question, there is a condition later in this method that tests maxRows, so hiding maxRows with a local zero (0) value effectively disables that test. I think the long term solution is to just make sure this class works correctly in the absence of a reliable maxRows value. |
||
|
||
for (; ; ) | ||
{ | ||
// NOTE: this is a LOCAL maxRows which is hiding this.maxRows. | ||
if (maxRows > 0 && currentRow >= maxRows) | ||
{ | ||
afterLast = true; | ||
|
@@ -324,7 +330,8 @@ public override bool Read() | |
|
||
if (!pendingRows.EndOfMessage) | ||
{ | ||
int result = pendingRows.getInt(); | ||
// InitResultSet() performs the pendingRows.getInt() for currentRow == 0 | ||
int result = currentRow > 0 ? pendingRows.getInt() : -1; | ||
|
||
if (result == 0) | ||
{ | ||
|
@@ -653,7 +660,7 @@ public override System.Collections.IEnumerator GetEnumerator() | |
|
||
public override bool HasRows | ||
{ | ||
get { throw new NotImplementedException(); } | ||
get { return (!afterLast); } | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why leave code commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was in a block that previously set ALL the member fields.
I agree that leaving a commented line is poor style.
I'll replace the commented line with a comment that explains why afterLast is not being set now.
The alternative was to set afterLast = false here, as originally done, and then set its value later.
But, I thought was was potentially confusing.