> Can you reproduce the problem using the sqlite shell?
This won't be easy as the UDF is in an ActiveX dll, not in sqlite3.dlll

This is the output from explain, run on this SQL:
SELECT XXX(F1, F2) as A, XXX(F1, F2) as B FROM UDF_TEST limit 3
XXX will just add the results of the integer values of fields F1 and F2.
I put the underscore in the below table to indicate empty values as it
is a bit tricky to get this nicely lined up in the e-mail.
addr opcode p1 p2 p3 p4 p5
0 Init 0 15 0 _ 0
1 Integer 3 1 0 _ 0
2 OpenRead 0 664359 0 _ 0
3 Rewind 0 13 0 _ 0
4 Column 0 0 4 _ 0
5 Column 0 1 5 _ 0
6 Function0 0 4 2 XXX(2) 2
7 Column 0 0 4 _ 0
8 Column 0 1 5 _ 0
9 Function0 0 4 3 XXX(2) 2
10 ResultRow 2 2 0 _ 0
11 DecrJumpZero 1 13 0 _ 0
12 Next 0 4 0 _ 1
13 Close 0 0 0 _ 0
14 Halt 0 0 0 _ 0
15 Transaction 0 0 867 0 1
16 TableLock 0 664359 0 UDF_TEST 0
17 Goto 0 1 0 _ 0

UDF_TEST is the name of the callback function that resides in the ActiveX
dll.

> Also, your function needs to call exactly one sqlite3_result_xxx()
function, specifying the context received as the first parameter.
Yes, it does that.

I also tried simply just setting the result and nil else:

Public Sub Sum2Fields3(ByVal lPtr_ObjContext As Long, ByVal lArgCount As
Long, ByVal lPtr_ObjSQLite3_Value As Long)
  sqlite3_result_int lPtr_ObjContext, 123
End Sub

And still the same crash, so that is if the UDF is called twice in the same
statement.
The crash happens on the first sqlite3_step.
All result codes prior to this are fine.

Thanks.


RBS

On Wed, Oct 21, 2015 at 7:16 AM, Hick Gunter <hick at scigames.at> wrote:

> Can you reproduce the problem using the sqlite shell?
>
> You can access the SQLite machine instructions by issuing
>
> .explain
> Explain <your query>
>
> You should see something similar to:
>
> asql> explain select XXX(Field1), XXX(Field2) from table1;
> addr  opcode         p1    p2    p3    p4             p5  comment
> ----  -------------  ----  ----  ----  -------------  --  -------------
> ?
> 2     VOpen          0     0     0     vtab:4B2B328:2B0BE53349D0  00  NULL
> 3     Integer        0     1     0                    00  NULL
> 4     Integer        0     2     0                    00  NULL
> 5     VFilter        0     12    1                   00  NULL
> 6     VColumn        0     8     1                    00  table1.Field1
> 7     Function       0     1     3     XXX(1)         01  NULL
> 8     VColumn        0     9     2                    00  table1.Field2
> 9     Function       0     2     4     XXX(1)         01  NULL
> 10    ResultRow      3     2     0                    00  NULL
> 11    VNext          0     6     0                    00  NULL
> 12    Close          0     0     0                    00  NULL
> 13    Halt           0     0     0                    00  NULL
> ?
>
>
> Also, your function needs to call exactly one sqlite3_result_xxx()
> function, specifying the context received as the first parameter.
>
> -----Urspr?ngliche Nachricht-----
> Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:
> sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von Bart
> Smissaert
> Gesendet: Mittwoch, 21. Oktober 2015 00:31
> An: General Discussion of SQLite Database
> Betreff: Re: [sqlite] Problem with sqlite3_create_function
>
> Could somebody tell me what happens after the callback function (to do with
> sqlite3_create_function) has run, so after it has finished processing one
> row?
> Does it return to the code line (in my case in an AciveX dll) directly
> after the line with sqlite3_step?
> Or are there other things going on first in sqlite3.dll?
> The problems is that if I call the user function more that once in the
> same SQL, eg:
> select XXX(field1), XXX(field2) from table1 I get a crash directly after
> the last run of the UDF to do with the first row.
> The 2 calls to the UDF are running fine, so no error message.
>
> RBS
>
> On Mon, Oct 19, 2015 at 2:19 PM, Bart Smissaert <bart.smissaert at gmail.com
> <mailto:bart.smissaert at gmail.com>>
> wrote:
>
> > > The "context" passed to a user defined function is not and cannot be
> > > a
> > "statement handle".
> >
> > Yes, you are right there. Not sure now how I thought it was a
> > statement handle, but this doesn't alter the problem.
> > Thanks in any case for correcting this mis-conception.
> >
> > RBS
> >
> > On Mon, Oct 19, 2015 at 1:40 PM, Hick Gunter <hick at scigames.at<mailto:
> hick at scigames.at>> wrote:
> >
> >> The "context" passed to a user defined function is not and cannot be
> >> a "statement handle". How would an aggregate function tell the
> >> difference between
> >>
> >> Select SUM(x) ...
> >>
> >> and
> >>
> >> Select SUM(x), SUM(y) ...
> >>
> >> if not by virtue of sqlite3_aggregate_context() returning different
> >> adresses?
> >>
> >> -----Urspr?ngliche Nachricht-----
> >> Von: sqlite-users-bounces at mailinglists.sqlite.org<mailto:
> sqlite-users-bounces at mailinglists.sqlite.org> [mailto:
> >> sqlite-users-bounces at mailinglists.sqlite.org<mailto:
> sqlite-users-bounces at mailinglists.sqlite.org>] Im Auftrag von Bart
> >> Smissaert
> >> Gesendet: Montag, 19. Oktober 2015 13:49
> >> An: General Discussion of SQLite Database
> >> Betreff: Re: [sqlite] Problem with sqlite3_create_function
> >>
> >> Still getting a crash here if I use the UDF more than once in the
> >> same
> >> statement:
> >>
> >> So, table with 2 integer columns and then doing:
> >>
> >> select XXX(field1), XXX(field2) from table1
> >>
> >> causes a crash.
> >>
> >> I can see that the statement prepares fine and that the UDF gets
> >> called twice (for the first row), but with no error, so
> >> sqlite3_errmsg(lDBHandle) gives not an error, but than my application
> >> crashes.
> >> I get the following information about this if it is of any help:
> >>
> >> Problem signature:
> >>   Problem Event Name: APPCRASH
> >>   Application Name: EXCEL.EXE
> >>   Application Version: 12.0.6732.5000
> >>   Application Timestamp: 55f969a5
> >>   Fault Module Name: sqlite3.dll
> >>   Fault Module Version: 3.9.1.0
> >>   Fault Module Timestamp: 562138c8
> >>   Exception Code: c0000005
> >>   Exception Offset: 0005a28b
> >>   OS Version: 6.1.7601.2.1.0.256.48
> >>   Locale ID: 2057
> >> Additional information about the problem:
> >>   LCID: 1033
> >>   Brand: Office12Crash
> >>   skulcid: 1033
> >>
> >> Using the UDF once in a statement is fine:
> >>
> >> select XXX(field1) from table1
> >>
> >> One thing I noticed is that every time the UDF is called (that is
> >> only twice, so once for field1 then again for field2) it is with a
> >> different statement handle.
> >> Is this to be expected?
> >>
> >>
> >> RBS
> >>
> >>
> >> On Mon, Oct 19, 2015 at 1:21 AM, Bart Smissaert
> >> <bart.smissaert at gmail.com
> >> >
> >> wrote:
> >>
> >> > Actually, I can see now that the result of
> >> > sqlite3_extended_errcode(lDBHandle) is in fact the same as the
> >> > result of sqlite3_step as I get for the 3 rows 100, 100, 100, 101
> >> > so SQLITE_ROW 3 times then SQLITE_DONE.
> >> >
> >> > Note sure though why this is and why I get unknown error as a
> >> > result of sqlite3_errmsg(lDBHandle). Should that not be: Not an error?
> >> >
> >> > In any case it does all work now.
> >> >
> >> > RBS
> >> >
> >> >
> >> >
> >> > On Mon, Oct 19, 2015 at 1:05 AM, Bart Smissaert
> >> > <bart.smissaert at gmail.com<mailto:bart.smissaert at gmail.com>>
> >> > wrote:
> >> >
> >> >> Some progress with this.
> >> >> Still get an error: unknown error, Extended error code: 100, but
> >> >> it all runs and get the right results and no crash.
> >> >> Problem was I did put the result of sqlite3_step in a VB Long
> datatype:
> >> >>
> >> >> Dim lStepResult As Long
> >> >>
> >> >> lStepResult = sqlite3_step(lStatementHandle)
> >> >>
> >> >> Now I do instead:
> >> >>
> >> >> Dim lStepResult 'VB variant datatype
> >> >>
> >> >>
> >> >> RBS
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> On Sun, Oct 18, 2015 at 10:16 PM, Bart Smissaert <
> >> >> bart.smissaert at gmail.com<mailto:bart.smissaert at gmail.com>> wrote:
> >> >>
> >> >>> > Is that binary ?  Or hex ?
> >> >>>
> >> >>> Normal decimal, it is the result of
> >> >>> sqlite3_extended_errcode(lDBHandle)
> >> >>>
> >> >>> > Just to verify, can you download the SQLite shell tool and try
> >> >>> > to
> >> >>> execute the same sequence ?
> >> >>>
> >> >>> Not sure that is that simple as the code to produce the result is
> >> >>> in an ActiveX dll, not in sqlite3.dll.
> >> >>>
> >> >>> RBS
> >> >>>
> >> >>> On Sun, Oct 18, 2015 at 9:43 PM, Simon Slavin
> >> >>> <slavins at bigfraud.org<mailto:slavins at bigfraud.org>>
> >> >>> wrote:
> >> >>>
> >> >>>>
> >> >>>> On 18 Oct 2015, at 8:35pm, Bart Smissaert
> >> >>>> <bart.smissaert at gmail.com<mailto:bart.smissaert at gmail.com>>
> >> >>>> wrote:
> >> >>>>
> >> >>>> > I get an error: unknown error, Extended error code: 100.
> >> >>>>
> >> >>>> Is that binary ?  Or hex ?
> >> >>>>
> >> >>>> > I do understand that most likely the problem is somewhere in
> >> >>>> > my
> >> >>>> > VB6
> >> >>>> code,
> >> >>>> > but I can't see it and maybe somebody can shed some light on
> >> >>>> > this
> >> >>>> from the
> >> >>>> > SQLite side.
> >> >>>>
> >> >>>> Just to verify, can you download the SQLite shell tool and try
> >> >>>> to execute the same sequence ?
> >> >>>>
> >> >>>> Simon.
> >> >>>> _______________________________________________
> >> >>>> sqlite-users mailing list
> >> >>>> sqlite-users at mailinglists.sqlite.org<mailto:
> sqlite-users at mailinglists.sqlite.org>
> >> >>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-u
> >> >>>> ser
> >> >>>> s
> >> >>>>
> >> >>>
> >> >>>
> >> >>
> >> >
> >> _______________________________________________
> >> sqlite-users mailing list
> >> sqlite-users at mailinglists.sqlite.org<mailto:
> sqlite-users at mailinglists.sqlite.org>
> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >>
> >>
> >> ___________________________________________
> >>  Gunter Hick
> >> Software Engineer
> >> Scientific Games International GmbH
> >> FN 157284 a, HG Wien
> >> Klitschgasse 2-4, A-1130 Vienna, Austria
> >> Tel: +43 1 80100 0
> >> E-Mail: hick at scigames.at<mailto:hick at scigames.at>
> >>
> >> This communication (including any attachments) is intended for the
> >> use of the intended recipient(s) only and may contain information
> >> that is confidential, privileged or legally protected. Any
> >> unauthorized use or dissemination of this communication is strictly
> >> prohibited. If you have received this communication in error, please
> >> immediately notify the sender by return e-mail message and delete all
> >> copies of the original communication. Thank you for your cooperation.
> >>
> >>
> >> _______________________________________________
> >> sqlite-users mailing list
> >> sqlite-users at mailinglists.sqlite.org<mailto:
> sqlite-users at mailinglists.sqlite.org>
> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >>
> >
> >
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org<mailto:
> sqlite-users at mailinglists.sqlite.org>
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
> ___________________________________________
>  Gunter Hick
> Software Engineer
> Scientific Games International GmbH
> FN 157284 a, HG Wien
> Klitschgasse 2-4, A-1130 Vienna, Austria
> Tel: +43 1 80100 0
> E-Mail: hick at scigames.at
>
> This communication (including any attachments) is intended for the use of
> the intended recipient(s) only and may contain information that is
> confidential, privileged or legally protected. Any unauthorized use or
> dissemination of this communication is strictly prohibited. If you have
> received this communication in error, please immediately notify the sender
> by return e-mail message and delete all copies of the original
> communication. Thank you for your cooperation.
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to