Page 1 of 1

Next doesn't work in Android Arm v7a

Posted: 27.10.2024, 21:42
by dseligo
I successfully use Zeos with LAMW (FPC 3.2.2) and Sqlite for Android Aarch64 target (using binaries for Android from sqlite.org).

But when target is ARM v7a (armeabi), 'Next' and 'Prior' methods of TZQuery doesn't work. 'First' and 'Last' does work (correction: Last does something, but not exactly what is expected).

I use Zeos version 7.2.4, but I also tried with 8.0.0. stable and current trunk.
I tried several Sqlite versions, from 3.47.0 to 3.25.0.

I create table and test data with:

Code: Select all

SQL.Text :=
  'create table if not exists mytable ' +
  '(' +
  'id integer not null, ' +
  'value integer, ' +
  'primary key (id)' +
  ')';
ExecSQL;

SQL.Text := 'insert into mytable (id, value) values (1, 100)';
ExecSQL;
SQL.Text := 'insert into mytable (id, value) values (2, 200)';
ExecSQL;
SQL.Text := 'insert into mytable (id, value) values (3, 300)';
ExecSQL;
Then I test with following code:

Code: Select all

procedure TAndroidModule1.btnNextTestClick(Sender: TObject);
var i: Integer;

  procedure PrintLine(const AText: String);
  var sEOF: String;
  begin
    If ZQry.EOF then
      sEOF := 'true'
    else
      sEOF := 'false';

    edLog.Append(
      AText + ': ID = ' + ZQry.FieldByName('id').AsString +', value = ' +
      ZQry.FieldByName('value').AsString + ', RecNo: ' + ZQry.RecNo.ToString +
      ', EOF: ' + sEOF + #13#10);
  end;

begin
  With ZQry do
  begin
    Close;
    SQL.Text := 'select count(*) from mytable';
    Open;
    edLog.Append('Count: ' + IntToStr(Fields[0].AsInteger) + #13#10);

    Close;
    SQL.Text := 'select id, value from mytable';
    Open;

    i := 0;
    While (not Eof) and (i < 5) do
    begin
      inc(i);
      PrintLine('Loop ' + i.ToString);
      Next;
    end;

    Last;
    PrintLine('Last');

    Prior;
    PrintLine('Prior');

    First;
    PrintLine('First');
  end;
end;
And this is result:

Code: Select all

Count: 3
Loop 1: ID = 1, value = 100, RecNo: 1, EOF: false
Loop 2: ID = 1, value = 100, RecNo: 1, EOF: false
Loop 3: ID = 1, value = 100, RecNo: 1, EOF: false
Loop 4: ID = 1, value = 100, RecNo: 1, EOF: false
Loop 5: ID = 1, value = 100, RecNo: 1, EOF: false
Last: ID = , value = , RecNo: 4, EOF: true
Prior: ID = , value = , RecNo: 4, EOF: true
First: ID = 1, value = 100, RecNo: 1, EOF: false
This are expected results (I got this with Aarch64 target):

Code: Select all

Count: 3
Loop 1: ID = 1, value = 100, RecNo: 1, EOF: false
Loop 2: ID = 2, value = 200, RecNo: 2, EOF: false
Loop 3: ID = 3, value = 300, RecNo: 3, EOF: false
Last: ID = 3, value = 300, RecNo: 3, EOF: true
Prior: ID = 2, value = 200, RecNo: 2, EOF: false
First: ID = 1, value = 100, RecNo: 1, EOF: false
Does anybody have clue what could be culprit?

Thank you.

P.S.: I will also post this in Freepascal forum and report here if somebody there has a solution.

Re: Next doesn't work in Android Arm v7a

Posted: 29.10.2024, 12:04
by marsupilami
Duh - hmm - I don't have a clue (yet). The problem is that I cannot test for this target at all. I will have to see if I can set up a test environment. Could you do a small test if this also happens with the FPC builtin components?

Re: Next doesn't work in Android Arm v7a

Posted: 29.10.2024, 19:40
by dseligo
I tried with built-in FPC components (SQLDB) and it works with them.

Re: Next doesn't work in Android Arm v7a

Posted: 01.11.2024, 07:45
by marsupilami
Ok, thanks for the reply. Unfortunately it will take some time, before I can do a test. I first have to familiarize myself with Android development on Lazarus/Freepascal.

Re: Next doesn't work in Android Arm v7a

Posted: 01.11.2024, 08:33
by dseligo
Great, thank you.

If I can test something just say.