[
https://issues.apache.org/jira/browse/HIVE-7680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14097957#comment-14097957
]
Alexander Pivovarov commented on HIVE-7680:
-------------------------------------------
Thejas
Statement.execute(sql) returns true or false
true if the first result is a ResultSet object; false if it is an update count
or there are no results
after that jdbc client should call getResultSet or getUpdateCount
if execute() returns false and getUpdateCount returns -1 It means no result.
It is NORMAL execution result. it is NOT an ERROR.
I's exactly what hive jdbc driver should return to client. you run "insert
into ...". hive does not have facility to tell you update count. Hive return
you no result in response. No result is normal result. It's not an error.
if there is an error, e.g. table does not exist then driver will throw SQL
Exception
java.sql.SQLSyntaxErrorException: table or view does not exist
This is how jdbc client will get error message but not by getting -1 from
getUpdateCount
Some databases including hive can not tell how many rows were inserted and they
should return -1 in getUpdateCount but no to fool the user returning 0
When user gets all result from Statement then Statement object should be in
final state. According to API spec
There are no more results when the following is true:
// stmt is a Statement object
((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
Even if database support getUpdateCount it should return some update count
value only first time you call getUpdateCount
Second time you call it it will return -1 anyway. I tested it with oracle jdbc
12.1.0.1
Some jdbc clients keep to retrive result or update count from Statement until
Statement gets into final state (false / -1)
e.g. SQL Workbench continue to call getUpdateCount() millions of times because
HiveStatement never gets into final state false/ -1
Final state of HiveStatement should be
getMoreResults = false
getUpdateCount = -1
I assume hive jdbc implementation is not going to return getUpdateCount=0
first time user calls it and then for consequent calls return getUpdateCount=-1
so, lets return getUpdateCount=-1 for the fist and all other consequent calls
> Do not throw SQLException for HiveStatement getMoreResults and
> setEscapeProcessing(false)
> -----------------------------------------------------------------------------------------
>
> Key: HIVE-7680
> URL: https://issues.apache.org/jira/browse/HIVE-7680
> Project: Hive
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 0.13.1
> Reporter: Alexander Pivovarov
> Assignee: Alexander Pivovarov
> Priority: Minor
> Attachments: HIVE-7680.patch
>
>
> 1. Some JDBC clients call method setEscapeProcessing(false) (e.g. SQL
> Workbench)
> Looks like setEscapeProcessing(false) should do nothing.So, lets do nothing
> instead of throwing SQLException
> 2. getMoreResults is needed in case Statements returns several ReseltSet.
> Hive does not support Multiple ResultSets. So this method can safely always
> return false.
> 3. getUpdateCount. Currently this method always returns 0. Hive cannot tell
> us how many rows were inserted. According to JDBC spec it should return " -1
> if the current result is a ResultSet object or there are no more results"
> if this method returns 0 then in case of execution insert statement JDBC
> client shows "0 rows were inserted" which is not true.
> if this method returns -1 then JDBC client runs insert statements and shows
> that it was executed successfully, no result were returned.
> I think the latter behaviour is more correct.
> 4. Some methods in Statement class should throw
> SQLFeatureNotSupportedException if they are not supported. Current
> implementation throws SQLException instead which means database access error.
--
This message was sent by Atlassian JIRA
(v6.2#6252)