fernandobatels / rsfbclient

Rust Firebird Client
MIT License
76 stars 11 forks source link

Error invalid request BLR at offset 132 function POS is not defined module name or entrypoint could not be found #151

Closed Spirit412 closed 10 months ago

Spirit412 commented 10 months ago

I used OS Linux. Version Firebase file fdb 2.5. Database uses UDF My code:

#![allow(unused_variables, unused_mut, unreachable_code, unused_imports)]
use std::path::Path;
use rsfbclient::{prelude::*, FbError};

#[allow(clippy::unnecessary_wraps)]
fn main() -> Result<(), FbError> {

    println!("exists test.fdb: {}", Path::new("/test/rust_firebird/test.fdb").exists());
    println!("exists libfbclient.so: {}", Path::new("/opt/firebird/lib/libfbclient.so").exists());

    #[cfg(not(feature = "pure_rust"))] // No support for embedded with pure rust driver
    {

        let mut conn = rsfbclient::builder_native()
            .with_dyn_load("/opt/firebird/lib/libfbclient.so")
            .with_remote()
            .db_name("/plinor/rust_firebird/test.fdb")
            .user("SYSDBA")
            .pass("masterkey")
            .connect()?;

        let rows = conn.query_iter("SELECT * FROM FZL", ())?;

            println!("-------------");
            println!("Table name");
            println!("-------------");
            for row in rows {
                let (r_name,): (String,) = row?;

                println!("{:^10}", r_name);
            }
    }
    Ok(())
}

I have return error

exists test.fdb: true
exists libfbclient.so: true
Error: Sql { msg: "invalid request BLR at offset 132\nfunction POS is not defined\nmodule name or entrypoint could not be found", code: -104 }
[1]    4102 segmentation fault  cargo run

EDIT COMMENT: Used Python 3.11 on Linux, i readed fdb file Firebird 2.5

con = fdb.connect(
    database=database_selex,
    user=user_selex,
    password=password_selex,
    charset="UTF8",
    sql_dialect=3,   # sql_dialect (int): SQL Dialect for connection (1, 2 or 3).
    no_db_triggers=True,  # no_db_triggers (int): No database triggers flag (FB 2.1).
)
cur = con.cursor()

How setup rsfbclient connect to fdb with sql_dialect and no_db_triggers ?

fernandobatels commented 10 months ago

I have return error

Please, provide the DDL of your FZL table

How setup rsfbclient connect to fdb with sql_dialect and no_db_triggers ?

no_db_triggers is not supported yet.

sql_dialect just call the dialect() method on connection builder. More infos:

 .db_name("/plinor/rust_firebird/test.fdb")
            .user("SYSDBA")
            .pass("masterkey")
            .dialect(Dialect::D1)
            .connect()?;
Spirit412 commented 10 months ago
        let mut conn = rsfbclient::builder_pure_rust()
            .host("localhost")
            .db_name("/plinor/rust_firebird/test.fdb")
            .user("SYSDBA")
            .pass("masterkey")
            .dialect(Dialect::D1)
            .charset(charset::UTF_8)
            .transaction(TransactionConfiguration {
                lock_resolution: TrLockResolution::NoWait,
                ..TransactionConfiguration::default()
            })
            .connect()?;

Error


exists libfbclient.so: true
Error: Sql { msg: "invalid request BLR at offset 132\nfunction POS is not defined\nmodule name or entrypoint could not be found", code: -1 }```
Spirit412 commented 10 months ago

I found the constant rsfbclient_core::ibase::isc_dpb_no_db_triggers, but I don't know how to change it and apply it to the query

fernandobatels commented 10 months ago

I found the constant rsfbclient_core::ibase::isc_dpb_no_db_triggers, but I don't know how to change it and apply it to the query

Your invalid request BLR at offset 132\nfunction POS is it caused by database triggers? Or are you just trying to change this flag for another reason?

I'm investigating how provide this flag on the connection builder

fernandobatels commented 10 months ago

I found the constant rsfbclient_core::ibase::isc_dpb_no_db_triggers, but I don't know how to change it and apply it to the query

Now you can disable the db trigger, try my last commit:

[dependencies]
rsfbclient = { git = "https://github.com/fernandobatels/rsfbclient.git", branch = "feature-151" }
   let mut conn = rsfbclient::builder_pure_rust()
            .host("localhost")
            .db_name("/plinor/rust_firebird/test.fdb")
            .no_db_trigger()
            .....
            .connect()?;
Spirit412 commented 10 months ago

I found the constant rsfbclient_core::ibase::isc_dpb_no_db_triggers, but I don't know how to change it and apply it to the query

Now you can disable the db trigger, try my last commit:

[dependencies]
rsfbclient = { git = "https://github.com/fernandobatels/rsfbclient.git", branch = "feature-151" }
   let mut conn = rsfbclient::builder_pure_rust()
            .host("localhost")
            .db_name("/plinor/rust_firebird/test.fdb")
            .no_db_trigger()
            .....
            .connect()?;

"Cargo.toml" rsfbclient = { git = "https://github.com/fernandobatels/rsfbclient", branch = "feature-151"}


n main() -> Result<(), FbError> {
let file_fdb: &str = "test.fdb";
println!("exists test.fdb: {}", Path::new(&file_fdb).exists());
let mut conn = rsfbclient::builder_pure_rust()
    .host("localhost")
    .db_name("test.fdb")
    .user("SYSDBA")
    .pass("masterkey")
    .dialect(Dialect::D1)
    .no_db_trigger()
    .connect()?;

let rows = conn.query_iter("SELECT * FROM FZL", ())?;

println!("-------------");
println!("Table name");
println!("-------------");

for row in rows {
    let (r_name,): (String,) = row?;

    println!("{:^10}", r_name);
}
Ok(())

Error:

error[E0425]: cannot find function builder_pure_rust in crate rsfbclient --> main.rs:15:36 | 15 | let mut conn = rsfbclient::builder_pure_rust() | ^^^^^^^^^^^^^^^^^ not found in rsfbclient

Spirit412 commented 10 months ago

I found the constant rsfbclient_core::ibase::isc_dpb_no_db_triggers, but I don't know how to change it and apply it to the query

Your invalid request BLR at offset 132\nfunction POS is it caused by database triggers? Or are you just trying to change this flag for another reason?

I'm investigating how provide this flag on the connection builder

Yes, I want to connect without triggers. Because if do not disable triggers, there will be a connection error. The same thing happened when trying to connect to Python using the fdb library

If it is possible to use triggers? I can send you an example database file

fernandobatels commented 10 months ago

Error:

error[E0425]: cannot find function `builder_pure_rust` in crate `rsfbclient`
  --> main.rs:15:36
   |
15 |         let mut conn = rsfbclient::builder_pure_rust()
   |                                    ^^^^^^^^^^^^^^^^^ not found in `rsfbclient`

My bad. Try enabling the pure_rust feature

[dependencies]
rsfbclient = { git = "https://github.com/fernandobatels/rsfbclient.git", branch = "feature-151", features=["pure_rust"] }
Spirit412 commented 10 months ago

Error:

error[E0425]: cannot find function `builder_pure_rust` in crate `rsfbclient`
  --> main.rs:15:36
   |
15 |         let mut conn = rsfbclient::builder_pure_rust()
   |                                    ^^^^^^^^^^^^^^^^^ not found in `rsfbclient`

My bad. Try enabling the pure_rust feature

[dependencies]
rsfbclient = { git = "https://github.com/fernandobatels/rsfbclient.git", branch = "feature-151", features=["pure_rust"] }

Yes, it works! Thanks

fernandobatels commented 10 months ago

Are you still facing BLR offset problems when select?

fernandobatels commented 10 months ago

If it is possible to use triggers? I can send you an example database file

The new flag only disable the database level triggers. Table triggers will still be working.

Spirit412 commented 10 months ago

Are you still facing BLR offset problems when select?

There are no more problems with reading the data.

fernandobatels commented 10 months ago

New version released with this new resource: 0.24.0