DRILL-1735: Have closing of JDBC connection free embedded-server resources.
Hooked up closing of JDBC connection to shut down embedded Drillbit, and then
fixed chain of bugs exposed by that:
1. Added test org.apache.drill.jdbc.test.Bug1735ConnectionCloseTest.
2. Hooked up connection handler in Driver to actually close JDBC connection.
3. Released a QueryResultsBatch in DrillCursor.
4. Reset DrillMetrics in BootStrapContext.close() (so stopping local DrillBit
and starting new DrillBit doesn't yield "duplicate metric" error.)
5. Checked cursor/row state before trying to retrieve value in DrillResultSet's
column accessor methods.
- Added org.apache.drill.jdbc.JdbcApiSqlException (for JDBC-level errors).
- Added org.apache.drill.jdbc.InvalidCursorStateSqlException.
[SqlAccessor, AvaticaDrillSqlAccessor, DrillConnectionImpl, DrillCursor,
DrillResultSet, InvalidCursorStateSqlException, JdbcApiSqlException,
DrillResultSetTest]
6. Released vectors in DrillResultSet.cleanup().
Added org.apache.drill.jdbc.test.Bug1735ResultSetCloseReleasesBuffersTest.
7. Delayed last-chunk batch until COMPLETED batch in QueryResultHandler.
8. Added nextUntilEnd(...) workarounds for fragment cancelation race condition
to TestView and other JDBC module/subproject tests.
9. Tracked open statements in orer to close at connection close (DrillStatementRegistry, etc.)
10. Commented out nextUntilEnd(...) workarounds for fragment cancelation race
condition.
11 Miscellaneous:
- Added some toString() methods
- Adjusted some logging (e.g., "// log.debug(...)" -> "log.trace(...)".
- Cleaned up a bit. [DrillCursor, DrillResultSet, QueryResultHandler]
- Added a few documentation comments.
- Added various TODO comments.