Validating database operation causes crash

Creating desktop or client-server database solutions?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
WebiWan
Posts: 6
Joined: Fri Apr 20, 2018 2:21 am

Validating database operation causes crash

Post by WebiWan » Fri Apr 20, 2018 2:49 am

I searched for a similar problem and didn't find it.

This is one of the weirdest things I've ever seen. Whenever I try to validate a Db operation the whole thing crashes. As a compiled exe it crashes every time; as code in the IDE it crashes only sometimes (by that I mean some of them validate every time and some of them crash every time). Example:
This crashes...
...
put "UPDATE hardware SET make = '" & tvMake & "', model = '" & tvModel & "', nickname = '" & tvNick & \
"', os = '" & tvOS & "', svcTagSerial = '" & tvTag & "', specLink = '" & tvSpec & "', suptLink = '" & tvSupp & \
"' WHERE idhardware = '" & tvHdwID & "' AND Indeks = '" & tvClientID & "';" into tvSQL
revExecuteSQL gvConnectionID, tvSQL

if the result is a number then
answer info "Record Updated"
else
answer error "Something went wrong." & cr & the result
end if

cmdClearAll
cmdReadyList
cmdPlaceList
end mouseUp

This does not...
...
put "UPDATE hardware SET make = '" & tvMake & "', model = '" & tvModel & "', nickname = '" & tvNick & \
"', os = '" & tvOS & "', svcTagSerial = '" & tvTag & "', specLink = '" & tvSpec & "', suptLink = '" & tvSupp & \
"' WHERE idhardware = '" & tvHdwID & "' AND Indeks = '" & tvClientID & "';" into tvSQL
revExecuteSQL gvConnectionID, tvSQL

cmdClearAll
cmdReadyList
cmdPlaceList
end mouseUp
I've also tried reversing the check so "if the result is not a number then"
I've tried "if the result is 1 then"

No matter if it crashes or it doesn't it still does the Db operation just fine. This is happening with SELECT, INSERT INTO, UPDATE, you name it. But if I validate the operation the application crashes with no error message.

Finally... this is new behavior. The app didn't used to do this. So it's something I've done. :(

AxWald
Posts: 309
Joined: Thu Mar 06, 2014 2:57 pm

Re: Validating database operation causes crash

Post by AxWald » Fri Apr 20, 2018 10:01 am

Hi,
WebiWan wrote:
Fri Apr 20, 2018 2:49 am
This is one of the weirdest things I've ever seen.
I agree. This is really weird.

You tried in the debugger? Which line crashes actually? The "if the result ..."?
Testing "the result" really shouldn't crash ;-))
So set breakpoint at the line where you construct your tvSQL and watch what happens.

My suspicion:
  • Do a search in "Stack File and its stack Files" for "result", especially following a "put" or without the "the". Or check the variables list in the debugger just before the offending line: You might have created a variable named "result".
  • You might also try replacing the command version of the db calls (revExecuteSQL etc.) with the function version (revdb_execute etc.). This avoids "the result" ...
  • If this all doesn't help: Try to reproduce this problem in a new stack, using only the bare minimum of code necessary. If you can, try with an older, well tested LC version.
Have fun!
Livecode programming until the cat hits the fan ...

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 788
Joined: Fri Aug 15, 2008 7:15 am

Re: Validating database operation causes crash

Post by bangkok » Fri Apr 20, 2018 11:47 am

Which OS ? Which version of LiveCode ? And which database (sqlite ? mysql ? postgresql ?)

2 hints :

-delete the ";" after your SQL query
-put the result into a variable before to test it

Code: Select all

put "UPDATE hardware SET make = '" & tvMake & "', model = '" & tvModel & "', nickname = '" & tvNick & \
"', os = '" & tvOS & "', svcTagSerial = '" & tvTag & "', specLink = '" & tvSpec & "', suptLink = '" & tvSupp & \
"' WHERE idhardware = '" & tvHdwID & "' AND Indeks = '" & tvClientID & "' into tvSQL
revExecuteSQL gvConnectionID, tvSQL

put the result into tResult

answer tResult

if tResult is a number then
answer info "Record Updated"
else
answer error "Something went wrong." & cr & tResult
end if

cmdClearAll
cmdReadyList
cmdPlaceList

WebiWan
Posts: 6
Joined: Fri Apr 20, 2018 2:21 am

Re: Validating database operation causes crash

Post by WebiWan » Fri Apr 20, 2018 9:15 pm

Thanks so much for the input.

I'm using: Windows 7, LC Community 9 build 15010, MySQL

I remember adding the semicolon to all the queries in my project thinking I was "cleaning up" the code. I thought it had to be there. Unfortunately that didn't do it.

Now, however, it runs perfectly in the IDE but still crashes the standalone. It also still does the Db operation.

I had checked the result earlier, it's 1 for everything.

WebiWan
Posts: 6
Joined: Fri Apr 20, 2018 2:21 am

Re: Validating database operation causes crash

Post by WebiWan » Fri Apr 20, 2018 11:31 pm

AxWald wrote:
Fri Apr 20, 2018 10:01 am
Hi,
WebiWan wrote:
Fri Apr 20, 2018 2:49 am
This is one of the weirdest things I've ever seen.
I agree. This is really weird.

You tried in the debugger? Which line crashes actually? The "if the result ..."?
Testing "the result" really shouldn't crash ;-))
So set breakpoint at the line where you construct your tvSQL and watch what happens.
Yup, the debugger is running and it doesn't choke on anything. It just causes the stack title bar to dim, as if it lost focus, and freezes there. I have to use the Task Manager to close it.

I'll absolutely try the other method, after I read about what the heck it is. :D

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 788
Joined: Fri Aug 15, 2008 7:15 am

Re: Validating database operation causes crash

Post by bangkok » Fri Apr 20, 2018 11:43 pm

WebiWan wrote:
Fri Apr 20, 2018 9:15 pm
I'm using: Windows 7, LC Community 9 build 15010, MySQL
You should try with LiveCode 8.1.9

https://downloads.livecode.com/livecode/

In the standalone, do you have a function that does a simple "select" on the DB ?

If not, try it.

Other question : do you have another PC on which to test your standalone ?

Last but not least : does your stack contains something else (datagrids etc.), other cards etc ?

idea : create a new stack from scratch, with just 1 button containing your update function, nothing else.

My point is : Windows 7, Livecode, Mysql, databases... those are really straightforward. I personally use extensively DB functions on windows 7, 8, 10, MySQL, SQLlite, Postgresql... with LC from 5.5.3 to 8.x, never had such problem.

AxWald
Posts: 309
Joined: Thu Mar 06, 2014 2:57 pm

Re: Validating database operation causes crash

Post by AxWald » Tue Apr 24, 2018 1:25 pm

Hi,

you already tried to delete your LC preferences file? This sounds like voodoo, but actually every LC version I ever tried has managed to corrupt this one once at least, with quite entertaining results partially.

Have fun!
Livecode programming until the cat hits the fan ...

WebiWan
Posts: 6
Joined: Fri Apr 20, 2018 2:21 am

Re: Validating database operation causes crash

Post by WebiWan » Tue Apr 24, 2018 10:04 pm

bangkok wrote:
Fri Apr 20, 2018 11:43 pm
WebiWan wrote:
Fri Apr 20, 2018 9:15 pm
I'm using: Windows 7, LC Community 9 build 15010, MySQL
In the standalone, do you have a function that does a simple "select" on the DB ?

Other question : do you have another PC on which to test your standalone ?

Last but not least : does your stack contains something else (datagrids etc.), other cards etc ?
Thanks much for your response! As to your questions:
1. Yes, Select queries work fine
2. Good question, stand by... ... ... ... Yes, it crashes on two other computers as well.
3. Yes, it has two datagrids, two substacks and three cards.
4. Maybe this will help. This is actually the third program in a series that all use the same master database. They do different things but a lot of the tables get used in the other programs as well. They work with no problems. It really seems like something I did to this program that is causing the problem.

I'll try the earlier version of Livecode, but since the other programs I wrote work fine I doubt that's it either.

WebiWan
Posts: 6
Joined: Fri Apr 20, 2018 2:21 am

Re: Validating database operation causes crash

Post by WebiWan » Tue Apr 24, 2018 10:09 pm

AxWald wrote:
Tue Apr 24, 2018 1:25 pm
Hi,

you already tried to delete your LC preferences file? This sounds like voodoo, but actually every LC version I ever tried has managed to corrupt this one once at least, with quite entertaining results partially.

Have fun!
It's only crashing in the standalone. But thanks for the tip. I'll remember that for the future. :idea:

WebiWan
Posts: 6
Joined: Fri Apr 20, 2018 2:21 am

Re: Validating database operation causes crash

Post by WebiWan » Mon May 07, 2018 12:21 am

I have an update that is also quite interesting. Since the last post I had commented out all the validation code and moved on to other things. But then I realized I could test this another way... by changing the visible confirmation. So instead of the 'answer' I put in code to change the background color of the button clicked.

So this runs:
...
put "UPDATE hardware SET make = '" & tvMake & "', model = '" & tvModel & "', nickname = '" & tvNick & \
"', os = '" & tvOS & "', svcTagSerial = '" & tvTag & "', specLink = '" & tvSpec & "', suptLink = '" & tvSupp & \
"' WHERE idhardware = '" & tvHdwID & "' AND Indeks = '" & tvClientID & "';" into tvSQL
revExecuteSQL gvConnectionID, tvSQL

if the result is a number then
set the backcolor of me to 221,255,221
else
set the backcolor of me to 255,128,128
end if

cmdClearAll
cmdReadyList
cmdPlaceList
end mouseUp
The standalone does not crash (freeze) when I change the 'answer' to a more visual cue.

Post Reply

Return to “Databases”