Open morsapaes opened 1 year ago
Hello, I would like to work on this one.
However, after some digging, I found out that this is not a very trivial work (maybe I'm missing something). It seems like the functions current_schema
, current_user
and session_user
are built-in functions that are parsed by the the role of function with parentheses. The reason why current_role
works is because it is parsed as a special identifier that is transformed to a function call of current_user()
: here.
Is there a way to reject user from calling these functions with parentheses?
nvm, I found the place to make the prevention. PR is up: https://github.com/MaterializeInc/materialize/pull/20627. Need to also update docs accordingly.
From a discussion on Slack: I suggest we move in the opposite direction on this and:
current_*
, session_user
, and user
functions.This will be a superset of PostgreSQL's behavior, so we'll remain compatible. I can't see a reason to match PostgreSQL's behavior of prohibiting trailing parentheses for everything but current_schema
. It's just purely confusing for users.
Snowflake, FWIW, allows trailing parenthesis for all of these functions.
I've implemented the unification logic in #27171.
What version of Materialize are you using?
v0.51.0
How did you install Materialize?
Materialize Cloud
What is the issue?
According to the PostgreSQL documentation:
We seem to break compatibility by allowing calls using trailing parentheses for
current_schema
,current_user
andsession_user
(current_role
behaves as expected).EDIT: @benesch proposes we lean into the more permissive take and allow calling all such functions with trailing parentheses in Materialize. See https://github.com/MaterializeInc/materialize/issues/18824#issuecomment-1745726526 for details.
See also