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
Fetching diagnostic records with iodbc and HFSQL #266
Comments
It seems to get an error executing the statement and getting an invalid free than trying to fetch the error message. I actually would be suprised if I know from the other thread that you use a connection pool library which hides that unsafe code behind a safe function call, but it doesn't actually do anything to make it safe (nor can it, if the underlying C-Lirbrary is not thread safe). As you might be able to imagine I would have a hard time reproducing your error. Best I can do is provide a couple of guesses. First thing I would try is to have a really simple program outside of any server implementation just executing this one query. No multithreading, no fancy connection pooling and see if that works. Best, Markus |
Oh for this case I didn't use r2d2. My code is this: [dependencies]
anyhow = "1.0.65"
dotenv = "0.15.0"
odbc-api = { version = "0.49.0", features = [ "iodbc" ] } use anyhow::{Context, Error};
use dotenv::dotenv;
use odbc_api::{buffers::TextRowSet, Cursor, Environment, ResultSetMetadata};
use std::{
env,
ffi::CStr,
io::{stdout, Write},
path::PathBuf,
};
const BATCH_SIZE: usize = 5000;
fn main() -> Result<(), Error> {
dotenv().ok();
let conn_str = env::var("SQL_STR").unwrap();
let environment = Environment::new()?;
let mut connection = environment.connect_with_connection_string(&conn_str)?;
match connection.execute("SELECT 1;", ())? {
Some(mut cursor) => {
println!("ok!");
}
None => {
eprintln!("Query came back empty. No output has been created.");
}
}
Ok(())
} I also tested other queries:
@genusistimelord suggested that it "it must not like selects without From". |
Okay interessting. Yeah, there might be something it doesn't like about these |
To clarify, in case an error occurrs Stuff that is currently beyond my understanding:
I feel the first point may hold more relevance though. |
yeah in this case connection is only on a single thread to begin with so multi threading should not cause any issues here. I wounder if the error from hfsql is different from those in other SQL so it doesn't know how to parse it. which it fails and then tries to call Free on memory that doesn't exist due to the failure. |
Could this happen if my database's charset is latin1? If I run Which means that there's an error in the SQL query. The next character should be "ê" so maybe there's an encoding problem there. I wonder if it could be similar with odbc-api. |
ahh yeah it might be having a hard time since the string doesn't have a nul terminator? |
not sure. but with odbc-api, I just found something. If I add EDIT: with the full error.
I tried this because I was wondering if it could be related to odbc-api/odbc-api/src/handles/buffer.rs Lines 13 to 19 in c37869f
|
Hello together, sorry for the delayed response. I am a bit swamped this week, and I did not have internet on my train rides recently. @bbigras Thanks for taking a closer look at it. It might be helpful to know, that at least for the first diagnostic message associated with an error, @genusistimelord You are not wrong either. You identified the reason why the replacement character shows instead of the I won't be able to do much this week, please do not mistake my inactivity for me being unsympathetic to your problem. Cheers, Markus |
With size
Thanks, I appreciate your replies, but no hurries at all. This issue doesn't block me at all. Btw, we probably can rename this issue as |
SELECT 1;
: free(): invalid pointer
The other issue that came up, is the confusion of encodings. Any encoding other than Best, Markus |
thank you Markus. |
You are welcome |
Using the weird HFSQL database with iodbc.
The query seems to work when I'm using HFSQL's UI thing.
backtrace
odbc-api = { version = "0.49.0", features = [ "iodbc" ] }
Note that will the old
odbc
crate I get:The text was updated successfully, but these errors were encountered: