[Gambas-user] Doing query of Stored procedure with no related data crashes gambas

BB adamnt42 at gmail.com
Sun Feb 19 11:37:55 CET 2023


On 19/2/23 8:47 pm, Christof Thalhofer wrote:
> Am 19.02.23 um 09:23 schrieb BB:
>
>> This is a gambas "bug" in one sense and not so in others.EXEC expects a
>> Result object to be returned, no matter whether the provided parameter
>> is a valid SQL sentence or not! In his case I believe it may have not
>> returned such. Further, his report of the Gambas error "Query failed:
>> Commands out of sync; you can't run this command now" indicates that
>> there could be a further and actual bug in the Gambas db component.
>
> In short: I cannot see a bug.
>
> I just created a stored procedure in PG which does nothing (except 
> querying some stuff inside):
>
>> testdb=> CREATE PROCEDURE testcall()
>> testdb-> LANGUAGE SQL
>> testdb-> AS $$
>> testdb$> select test from tbtest;
>> testdb$> $$;
>> CREATE PROCEDURE
>
> Tested it inside PG:
>
>> testdb=> call testcall();
>> CALL
>
> Ok, it runs so far...
>
> So now let's execute it from Gambas:
>
> >     ConTest.Exec("call testcall();")
> >     Print "ok"
>
> Runs the statement 'call testcall();' and prints ok.
>
>>     res = ConTest.Exec("call testcall();")
>>     Print "ok"
>
> Also runs the statement 'call testcall();' and prints ok.
>
> The Result object ('res') is returned and is empty.
>
> A last test:
>
> >     res = ConTest.Exec("glibberish thing") ' No valid SQL!
> >     Print "ok"
>>         Catch         Print Error.Text
>
> Gambas throws an error which contains the error, the database threw:
>
> 'Query failed: ERROR:  syntax error at or near "glibberish"'
>
> -----------------------------------------------------------------
>
> So Conection.Exec() does what it has to do:
>
> It sends a string to the DB and let the DB execute it.
>
> If there's a result it returns a Result object.
>
> If the result is empty it returns a Result object which is empty.
>
> If the DB reports an error, it throws an error.
>
> At least with Postgresql.
>
> Alles Gute
>
> Christof Thalhofer
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

Oh and I have no problem with postgres*, it was looking into the code in 
the mysql/mariadb case where I have little experience that I wrote the 
notes.

* Apart when I stuff up the EXEC(value)

If it returns a Result all is good and we can check it with 
Result.Available BUT if it doesn't then the problem is proven.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230219/70d4f591/attachment-0001.htm>


More information about the User mailing list