UniDAC 5.5.12 TDAMetaData.Open issue

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

UniDAC 5.5.12 TDAMetaData.Open issue

Post by CristianP » Wed 08 Oct 2014 15:52

I have a function to get index names for a table.
It worked in UniDAC 5.2.5 and XE5 for both Android and iOS (also Win32).
Now with 5.5.12 in XE7 for Win32 is working but not for Android or iOS Simulator 7.1. With iOS device I have not tested yet.
This exception is for SQLite.

I receive this exception when I try to open metadata:
Project ****** raised exception class Exception with message 'SQL statement doesn't return rows'.

I have UniDAC sources but you changed the password so I can not debug. My developer license number is 01811. I suppose you have my email to send me the new password.

Code: Select all

procedure GetIndexNames(uc: TUniConnection; TableName: String; SList: TStringList);
var
  meta: TDAMetaData;
begin
  meta := uc.CreateMetaData;
  try
    meta.MetaDataKind := 'Indexes';
    //some code to set TABLE_SCHEMA and TABLE_CATALOG for non SQLite servers
    //.......
    meta.Restrictions.Values['TABLE_NAME'] := OnlyTableName;
    meta.Open;//<------- here is the exception raised
And call stack:
System._DbgExcNotify(0,$190C0FD0,$1314EAF {'Exception'},$9ECDE3,nil)
System.NotifyReRaise
:00018c47 NotifyReRaise + $13
:009ecde3 TSQLiteRecordSet.CreateFieldDescs + $8F
:00742051 TData.InternalInitFieldDescs + $99
:0082dd47 TCRRecordSet.InternalInitFieldDescs + $2F
:007405c9 TData.InitFields + $25
:0082cea1 TCRRecordSet.ExecFetch + $61
:0073fb79 TData.Open + $45
:009f120f TSQLiteMetaData.GetIndexes + $15F
:00834977 TCRMetaData.InternalGetMetaData + $16F
:00834779 TCRMetaData.GetMetaData + $A5
:00802e76 TDAMetaData.InternalOpen + $7A
Data.DB.TDataSet.DoInternalOpen
:00623d0c TDataSet.DoInternalOpen + $2C
Data.DB.TDataSet.SetActive(True)
Data.DB.TDataSet.Open

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by CristianP » Thu 09 Oct 2014 06:36

I tried to workaround but I receive same exception for iOS.
On Win32 is working...

Code: Select all

    uq := TUniQuery.Create(nil);
    try
      uq.Connection := uc;
      uq.SQL.Text := 'PRAGMA index_list(' + TableName + ')';
      uq.Open;//<--- same exception

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by AlexP » Thu 09 Oct 2014 09:39

Hello,

Please make sure that such table exists and you have correctly deployed the database and specified the path to it.

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by CristianP » Thu 09 Oct 2014 09:57

I have tried this and the table exists because the exception is raised only for PRAGMA.
The database and table are created on iOS. I have ForceCreateDatabase to True.
But it is the same when I run second time and the database and table are there.

Code: Select all

  procedure Test;
  var
    uq: TUniQuery;
  begin
    uq := TUniQuery.Create(nil);
    try
      ucDL.ExecSQL('CREATE TABLE IF NOT EXISTS Test1(F1 INTEGER)');
      uq.Connection := ucDL;
      uq.SQL.Text := 'SELECT * FROM Test1';
      uq.Open;// it's OK
      uq.Close;
      uq.SQL.Text := 'PRAGMA index_list(Test1)';
      uq.Open;//<---- exception 'SQL statement doesn't return rows'
    finally
      uq.Free;
    end;
  end;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by AlexP » Fri 10 Oct 2014 09:46

We have reproduced this behavior. This is most likely the specificity of SQLite functioning on mobile platforms. If pragma doesn't return data, then the sqlite3_column_count API method returns 0 (on Windows, it returns correct data in any case). We use this method to define the result type, and since 0 is returned - we return this error. We will continue investigation of this behavior.

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by CristianP » Fri 10 Oct 2014 10:06

AlexP wrote:This is most likely the specificity of SQLite functioning on mobile platforms.
I have tested on OSX and there is the same exception.

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by CristianP » Fri 10 Oct 2014 10:23

AlexP wrote:If pragma doesn't return data, then the sqlite3_column_count API method returns 0
Good to know. I have workarounded with a try except bloc ignoring specifically this exception.

Best regards,
Cristian Peta

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by CristianP » Fri 10 Oct 2014 11:12

CristianP wrote:
AlexP wrote:This is most likely the specificity of SQLite functioning on mobile platforms.
I have tested on OSX and there is the same exception.
Also on the same iPad (iOS 8.0.2) I tried old (XE5+UniDAC 5.2.5) and new (XE7+UniDAC 5.5.12) and only new version do have this issue.

Best regards,
Cristian Peta

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UniDAC 5.5.12 TDAMetaData.Open issue

Post by AlexP » Wed 15 Oct 2014 07:44

This is due to that we have changed the process of obtaining metadata. An explicit call of the PRAGMA index_list(TableName) command in a query causes an error in all the UniDAC versions.
We have returned the old behavior to avoid the error.

Post Reply