[
https://issues.apache.org/jira/browse/NIFI-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16233580#comment-16233580
]
ASF GitHub Bot commented on NIFI-4561:
--------------------------------------
GitHub user patricker opened a pull request:
https://github.com/apache/nifi/pull/2243
NIFI-4561 ExecuteSQL returns no FlowFile for some queries
In some scenarios the updated ExecuteSQL returns no FlowFile, even when the
SQL was executed without error. This is a bug I introduced in
https://github.com/apache/nifi/pull/1471.
If you execute a stored procedure that returns only a row count, or if the
row count is the first result and the ResultSet follows it, then no FlowFile
will be generated. This is because `getMoreResults()` and `execute()` return
false to indicate that the ResultSet does not exist OR that the statement
returned a number and not a ResultSet. So if ResultSet's and numerical
responses are inter mixed this will also result in missed result sets.
Some JDBC drivers allow for multi-statement requests to be submitted using
`Statement.execute`. In these cases you can have an INSERT statement followed
by a SELECT statement. In this case no ResultSet would be returned either.
Prior to NIFI-3432, executing any number of statements would result in a
single ReslutSet, which may or may not include data. I've seen examples of a
DELETE followed by several INSERT statements and our JDBC driver (Teradata)
would execute them and NiFi would return a single empty FlowFile.
This update corrects the logic. The new logic:
- For every ResultSet, output a FlowFile
- Skip non-ResultSet outputs
- If we have no more results, there were no errors, there was no original
inbound FlowFile, and no ResultSet's were found at all (statements were
Insert/Update/Delete only), then output a blank FlowFile.
@mattyb149 You reviewed https://github.com/apache/nifi/pull/1471 for me,
not sure if you have the time to review this fix as well. I know in the past
you weren't big on the idea of executing non SELECT statements from ExecuteSQL,
but it's something I'm seeing in our environment since the JDBC driver allows
it, and since we can do multi-statement requests.
### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number
you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [x] Has your PR been rebased against the latest commit within the target
branch (typically master)?
- [x] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via mvn
-Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file, including the main
LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main
NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to
.name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in
which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check travis-ci for build
issues and submit an update to your PR as soon as possible.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/patricker/nifi NIFI-4561
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/2243.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2243
----
commit 59391ca9adf8ab69defa611237b3dc009cf563f9
Author: patricker <[email protected]>
Date: 2017-11-01T02:25:26Z
NIFI-4561 ExecuteSQL returns no FlowFile for some queries
----
> ExecuteSQL Stopped Returning FlowFile for non-ResultSet Queries
> ---------------------------------------------------------------
>
> Key: NIFI-4561
> URL: https://issues.apache.org/jira/browse/NIFI-4561
> Project: Apache NiFi
> Issue Type: Bug
> Reporter: Peter Wicks
> Assignee: Peter Wicks
> Priority: Major
>
> While most people use ExecuteSQL for Select statements, some JDBC drivers
> allow you to execute any kind of statement, including multi-statement
> requests.
> This allowed users to submit multiple SQL statements in one JDBC Statement
> and get back multiple result sets. This was part of the reason I wrote
> [NIFI-3432].
> After having NIFI-3432 merged, I found that some request types no longer
> cause a FlowFile to be generated because there is no ResultSet. Also, if
> request types are mixed, such as an insert followed by a Select, then no
> ResultSet is returned because the first result is not a result set but an
> Update Count.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)