[MDEV-9442] SELECT EXISTS returns false values when missing table information in where clause Created: 2016-01-21  Updated: 2016-02-18  Resolved: 2016-02-18

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Procedure
Affects Version/s: 5.5.46, 10.1.10
Fix Version/s: N/A

Type: Bug Priority: Trivial
Reporter: joey doe Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: need_feedback
Environment:

Debian, Ubuntu



 Description   

I found out, that SELECT Statements always return 0 when the table is empty, and 1 when there's data in the table. Independently of the used query. Let me citate my stack overflow solution.

'Inside of a Stored Procedure Select Exists returns 1 when there is data in the table and null if there is no, when the query is written like that (without specific table set in the where clause): SELECT EXISTS (SELECT * INTO count FROM db.sequencial_host WHERE host_id = host_id_a ORDER BY insert_time DESC LIMIT 1);

If you append the table to the host_id where clause it works as expected. Even counts return the expected value. SELECT EXISTS (SELECT * INTO count FROM db.sequencial_host WHERE sequencial_host.host_id = host_id_a ORDER BY insert_time DESC LIMIT 1);'

http://stackoverflow.com/questions/34909887/mysql-stored-procedure-if-count-is-never-null/34911702#34911702



 Comments   
Comment by Elena Stepanova [ 2016-01-21 ]

joeysql,

Sorry, it's really difficult to follow what you are doing, what you are trying to do, what you are getting, and what seems to be wrong.

I see the pastebin, so, you have a table with a couple of rows, and a procedure which conditionally inserts into the table. However, this procedure does not even use the query which you are complaining about in this bug report.

Instead of describing in words that something is not working, and also giving incremental description, like "i did this and it did not work, then on top of it i also did that and it did not work, and now I have this", which i see in the stackoverflow question, please provide one consistent example of the problem: the table, the data, the procedure description, your call to the procedure, actual result and expected result (and preferably some justification for the expected result, because the procedure uses current timestamps, so results can differ).

Thanks.

Comment by Elena Stepanova [ 2016-02-18 ]

Please comment to re-open if you have more information on the issue.

Generated at Thu Feb 08 07:34:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.