Add ODBC DirectExec public API#3502
Merged
aleks-f merged 8 commits intopocoproject:develfrom Mar 22, 2023
Merged
Conversation
IllidanSR
reviewed
Jan 24, 2022
IllidanSR
reviewed
Jan 24, 2022
dedlocc
suggested changes
Jan 24, 2022
Data/ODBC/src/ODBCStatementImpl.cpp
Outdated
| auto data=&query.at(0); | ||
| SQLCHAR * statementText=reinterpret_cast<unsigned char*>(data); | ||
| SQLINTEGER textLength=query.size(); | ||
| SQLRETURN rc = SQLExecDirect(_stmt,statementText,textLength); |
There was a problem hiding this comment.
- Add spaces around
=and after commas. - Better use
query.data()instead of&query.at(0)and then there's no need of a separate variable. - Even though it seems you do need to pass a non-const char pointer to
SQLExecDirect, you don't need it for every possible implementation of this method (e.g. inStatementImpl::execDirectImpl). So I'd suggest passing it as const reference and only make a copy if needed. *should be a part of type (so no whitespace before it), as suggested here.
Contributor
Author
There was a problem hiding this comment.
- data is non const only since c++17 https://en.cppreference.com/w/cpp/string/basic_string/data
2039682 to
32949be
Compare
430296d to
a23a419
Compare
a23a419 to
dc6a9c8
Compare
Contributor
Author
|
@aleks-f sorry for ping, but are there any chances for this pr? |
Member
|
@Jihadist yes, but there are still some unanswered questions above |
Contributor
Author
If you mean async part, I don't know how to implement it. Maybe you can suggest something |
Member
I did suggest something, you just have to read it |
Contributor
Author
|
@aleks-f it sounds strange, but I don't see anything |
aleks-f
requested changes
Mar 20, 2023
8c01569 to
094ebfb
Compare
aleks-f
approved these changes
Mar 20, 2023
aleks-f
pushed a commit
that referenced
this pull request
Nov 27, 2023
* ODBC sqlDirectExec * doc * Small fix * Fix tabs, add missing const, fix style * Add test case * Small fixes * suggested fix for async * test for returned values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


It was a very long story how i couldn't determine why temp tables dont work in Poco between statements (#3499). After all, I compared how Poco use ODBC api and NanoODBC
For 1 single statement Poco call stack (except attrs and some non-related things):
For 1 single statement NanoODBC call stack (except attrs and some non-related things):
Looks like Poco uses only prepared statement while nanodbc calls execute direct every time. I tried to investigate deeper and deeper. If I create temp table with prepared statement, temp table will not be available in the next statement. How it works with sessions but with statements. But if I create temp table with direct execute, it will be available in the statements...
So I tried to add direct execute to Poco but I dont understand well Poco architecture and it needs to change a lot of classes and maybe architecture too. So I create this PR as proposal or draft.
If you provide me some help I'll be very thankful.
Closes #3499
MS mention this in docs https://learn.microsoft.com/en-us/sql/relational-databases/native-client-odbc-queries/executing-statements/prepared-execution?view=sql-server-ver16
Prepared statements cannot be used to create temporary objects on SQL Server.