[MDEV-30903] accessing user variables in views Created: 2023-03-22  Updated: 2023-05-19

Status: Open
Project: MariaDB Server
Component/s: Views
Affects Version/s: 10.4, 10.10.3
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Jan Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: Question
Environment:

Windows



 Description   

According to documentation, regarding Views: "Within a stored program, the definition cannot refer to program parameters or local variables". Apparently in practice that does not work, following code completely bypass that rule:

DELIMITER $$
CREATE FUNCTION f()
RETURNS TEXT
BEGIN
RETURN @d;
END;$$
DELIMITER ;
SET @d='6';
CREATE VIEW v1 AS select f() AS F;
select * FROM v1;

Honestly, I am not complaining for that particular inconsistency, I however wonder if you intend to keep it or fix it, in future releases?
It might be useful to have an ability to manipulate views or be able to retain some of subroutine state between its consecutive executions (this way some optimizations can be done), using at least user variables.



 Comments   
Comment by Sergei Golubchik [ 2023-05-19 ]

At the moment there are no plans to disallow such functions in views.

This limitation is a very old one, it was there since the view support was first implemented, and, frankly, I personally don't see the reason for it. May be I'm wrong and there is a reason. Or may be it'll be relaxed.

Generated at Thu Feb 08 10:19:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.