Skip to content
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

Firebird server on Android has problem with numerics [CORE5888] #6146

Closed
firebird-automations opened this issue Aug 10, 2018 · 29 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @livius2

Attachments:
FBAndroid3.7z.001
FBAndroid3.7z.002
Firebird3Deploy.png

Votes: 2

Any select from Firebird containing numeric data type cause

"Fixed length column [F_NUMERIC] data length mismatch. Value length - [2], column fixed length - [8]"

when run from Delphi Firedac.
Same select throught firebird client to remote server works ok.

It looks like (from Firedac error message) that this is metadata/buffer retrurn problem to the client.

Commits: 479d39a 638c4a8

====== Test Details ======

The sample that Alex gave works fine on any common (non-android) FB build:

C:\FB\30SS>isql /:e30
Database: /:e30, User: SYSDBA
SQL> recreate table test(x numeric(8,2));
SQL> insert into test values(3.62);
SQL> commit;
SQL> select * from test;

       X

============
3.62

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

i have enabled trace on Firedac side and it looks like scale is wrongly reported

F_NUMERIC is declared as NUMERIC(18,2)

wrong
. Col add [Index=1, SrcName="F_NUMERIC", SrcType=BCD, SrcSize=0, SrcPrec=18, SrcScale=254, Type=BCD, Size=0, Prec=18, Scale=254, OrigTabName="POLA", OrigColName="F_NUMERIC"]
ok
. Col add [Index=1, SrcName="F_NUMERIC", SrcType=BCD, SrcSize=0, SrcPrec=18, SrcScale=2, Type=BCD, Size=0, Prec=18, Scale=2, OrigTabName="POLA", OrigColName="F_NUMERIC"]

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Could you try non-Firedac components ?
Or, could you run isql on Android ?

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

I have tried but only succesfully with Firedac.I can try more if you realy wish. But i suppose problem is not Firedac itself.
And as tested previously using Firedac on Android and connecting to remote Firebird all works ok, including numerics.
But using Android embbeded FB numerics are broken.

>>could you run isql on Android

I do not know how to do this..

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

environment: Android 8.0
Firebird version: LI-V3.0.3.32900

=>

Android 8.0
Firebird version: LI-V3.0.3.32900
same with LI-V3.0.4.33054

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Karol, can you prepare binary I can run to reproduce the problem? It will be great to make it possible to connect to embedded and remote datasources.

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

Hi Alexander
i have attached apk file if it is what you need.
It is compressed with 7zip into 2 volumes(as there is a limit of 10MB on the FBtracker)
1. run app
2. click "link"
this assign VendorLib to "libfbclientembed" this is renamed file of http://libfbclient.so
and this also set FIREBIRD_LOCK variable
3. click on connect
if succesfull then you should see version of Firebird below
4. Go to "Data" tab
you can change which field to query from the combobox - you can also type query self in the memo
5. click on "Open dataset"
you should see resultset in the grid or an error

for F_NUMERIC_3 error is different then for F_NUMERIC_2 or F_DECIMAL

if you have any questions or need to change something in the app feel free

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

Attachment: FBAndroid3.7z.001 [ 13342 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

Attachment: FBAndroid3.7z.002 [ 13343 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: emailx45 (emailx45)

hi Karol,

is possible you send or show you did your app to access Firrbird embedded in Android.

I use RAD Studio 10.3.1 (Delphi), Android 7.0 Nougat, Firebird v3.04, BUT only have tested in MSWindows, and I would like to know config it to use in my test to Android.

I downloaded your APK and was installed in my Android and works showing the error that you talk.

its great for me because I would like to know how config one FMX project using Firebird embedded to Android.

I have some suites like UniDAC, FireDAC, IBX and others to test it.
I want only test i dont want create any app ok

then if you can send me this project test in a zip, and some text about, would be great.

hug

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

Hi, thank you for the interest and test on Android 7.

You can not connect to Andorid from Firedac by only some configuration changing, sadly.
To connect from Delphi you must change source files and dissable Interbase To Go.

When the issue on the Firebird side will be fixed i will post to Embarcadero quality portal detailed description what should be changed to allow connection.
They must addapt this changes to support both Firebird and Interbase To Go as my modification work only with Firebird.
When i create RSP ticket i will post here the link and you can then change your source filess too.

@firebird-automations
Copy link
Collaborator Author

Commented by: emailx45 (emailx45)

hi Karol,

thanks for your reply.

I would like know only you created your project th0at at least show info about Firebird in your APK.
or be, just curiosity about how this project was done.
what components, whats Firebird files and folders was deployed etc.
you see?
really i know that Firebird is not prepared to Android, but my curiosity is more than my brain. hehehe :)))
if possible one zip will be great for while.

hug

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Let me confirm an issue using plain isql:

SQL> create database 'num.fdb';
SQL> create table numTest(x Numeric(8,2));
SQL> insert into numTest values(3.62);
SQL> commit;
SQL> select * from numTest;

       X 

============
-362

SQL> show version;
ISQL Version: LI-V3.0.4.33054 Firebird 3.0
Server version:
Firebird/Linux/ARM (access method), version "LI-V3.0.4.33054 Firebird 3.0"
on disk structure version 12.2

Not an error but wrong result, and I'm sure it can make some clients raise error.

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

@alexander Peshkov

Maybe this is the issue.
If you have some updated files to test i am interested :)

PS> If i can ask here - how do you run isql on Android?

@emailx45
I am not on the computer now i will attach screen from deploynment page if thsi is helpfull
But maybe earlier Alexander will fix the problem ;-)

@firebird-automations
Copy link
Collaborator Author

Commented by: emailx45 (emailx45)

hi @Karol
i'll wait. but the complete project (all files) in a zip will be great for that i can reproduce/compile in my Android and see like you did, and who know help with some idea. but if not possible for any cause, ok.

hug

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Here you can find binaries that should fix this problem:
http://web.firebirdsql.org/rabbits/alex/Android/firebird.tgz
Looks like an issue was due to default unsigned char on ARM (unlike x86 where char is signed by default).
Also I've fixed some issues that prevented running on relatively fresh Android version (I can't say for sure what I've used when did port a few years ago but you can imagine how old was it).
Cause most of fixes were compiler-flags related all binaries should better be replaced.

To run isql I did the following:
1. Installed ssh server on android device (I use SSHDroid, but suppose a lot of others will work for you).
Using ssh server has some advantages:
- I need not switch android to dev mode (i.e. it works at conditions maximum close to real world)
- I can use normal keyboard on noraml PC ;)

2. Copied using it firebird binaries and untarred them, next:

export FIREBIRD_LOCK=/data/data/berserker.android.apps.sshdroid/home #⁠ /data/local/tmp does not work any more as 'good old' tmp
cd /data/data/berserker.android.apps.sshdroid/home/firebird/bin
export LD_LIBRARY_PATH=../lib #⁠ my kernel does not understand appropriate option in ELF header
./isql is ready to run

BUT - on my device only using new binaries, there were a few issues breaking released binaries! Among them:
- executables should be linked with -pie option (kernel does not want to start other binaries at all)
- control upon the library pathname using dladdr() function does not work on Android - had to turn it off

I suppose second is not a problem for your android or you would never start embedded access. So please test how does it work now.

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

@alexander Peshkov

It looks like fixed issue :)
It will be good if you attache fixed build to official download page
I then create ticket on Embarcadero site about official supported and working version of Firebird on Android :)

Thank you fro the fix

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

summary: Firebird server on Android have problem with numerics => Firebird server on Android has problem with numerics

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

What about attaching fixed build to official download page - we do not publish intermediate binaries (may be it's time to have snapshot builds) but very soon plan to release 3.0.5.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0.5 [ 10885 ]

Fix Version: 4.0 Beta 2 [ 10888 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Cannot be tested

Test Details: The sample that Alex gave works fine on any common (non-android) FB build:

C:\FB\30SS>isql /:e30
Database: /:e30, User: SYSDBA
SQL> recreate table test(x numeric(8,2));
SQL> insert into test values(3.62);
SQL> commit;
SQL> select * from test;

       X

============
3.62

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

As requested by users [maybe offtopic for the tracker] i have attached deployment screenshot from Delphi
"project name is FBAndroid4" - 4 is 4th attempt not firebird 4 ;-)

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

Attachment: Firebird3Deploy.png [ 13353 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: emailx45 (emailx45)

thanks, and lets try it

@firebird-automations
Copy link
Collaborator Author

Commented by: Geferson Dietze (dietze.gefe)

How to get the file http://libfbclientembed.so? It is not included in the download.

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

It is simply renamed file http://libfbclient.so
It was needed for my tests only

@juliogyn
Copy link

juliogyn commented Apr 30, 2023

Hi All,

is there any updates on this? how to install on android? is there any sdk or flutter package? I use SQLite, but I miss a lot of the resources from Firebird

@asfernandes
Copy link
Member

This issue is about a fixed thing, not related to your question.

But for FB 5 you may see this: https://github.com/FirebirdSQL/examples/blob/main/android-cpp/README.md

For things like Delphi, it should be very easy to map these C++ instructions.

We still do not have an Android, ReactNative or Flutter SDK that works in Android.

I've started one for ReactNative based on node-firebird-driver-native, but ReactNative instability and slow builds made me crazy, so this project is suspended in this moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment