[MDEV-8812] Giving an alias to function argument (now can make the query to fail) Created: 2015-09-17 Updated: 2017-05-30 Resolved: 2017-05-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Minor |
| Reporter: | Olivier Bertrand | Assignee: | Sergei Golubchik |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The query, calling a UDF:
works fine; however, this one:
fails saying: "Incorrect parameters in the call to native function "greatest". Indeed, in this case, aliases are useless but why flag this as an error? Perhaps a warning saying that these aliases are ignored would be acceptable. BTW: The MariaDB documentation on aliases (in the tutorial) does not say anything about aliasing function arguments. This is an important feature for UDF's as it correspond to the attribute of arguments. |
| Comments |
| Comment by Elena Stepanova [ 2015-09-20 ] | ||
|
I created a subtask (MDEV-8822) for the documentation shortage. Aliases for function arguments is a feature request, so the issue has been switched from Bug to Task. | ||
| Comment by Sergei Golubchik [ 2017-05-30 ] | ||
|
As far as I can see, AS UDT only applies to stored routines, not to built-in functions. AS xxx in built-in functions is non-standard and doesn't serve any useful (or useless, fwiw) purpose. In UDFs it's non-standard and very non-conventional and inconsistent. But it's a historical feature that we preserve for compatibility reasons. I don't see why it should work for other (not UDF) functions, if it's useless there. Especially, as it might conflict with future extensions (like AS UDT). | ||
| Comment by Olivier Bertrand [ 2017-05-30 ] | ||
|
I agree on this, I was just suggesting to treat it as a warning instead of a syntax error. By the way, as I commented in In the JSON UDFs, I am using the alias to test this and I don't know what I could use if this was not kept in future versions. For instance, using alias is what enables a function like JSON_MAKE_OBJECT to make a JSON object from values retrieved from a table, the alias being the column name. For instance:
Returns:
I don' think this can be achieved with a native function. |