You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`security_invoker`| controls whether the view runs with the permissions of the view owner (false) or the current user (true). Accepts `true`, `false`, `1`, or `0`. Defaults to `true` when specified without a value | No |
276
+
277
+
{{site.data.alerts.callout_info}}
278
+
The `security_invoker` option requires the `enable_view_security_invoker` feature flag to be enabled via the `allow_view_with_security_invoker_clause` session setting.
279
+
{{site.data.alerts.end}}
280
+
281
+
### Examples
282
+
283
+
{% include_cached copy-clipboard.html %}
284
+
~~~sql
285
+
-- Enable the feature flag
286
+
SET allow_view_with_security_invoker_clause =on;
287
+
~~~
288
+
289
+
{% include_cached copy-clipboard.html %}
290
+
~~~sql
291
+
-- Create a view with security invoker enabled (default value)
292
+
CREATEVIEWsecurity_view WITH ( security_invoker ) ASSELECT*FROM sensitive_table;
293
+
~~~
294
+
295
+
{% include_cached copy-clipboard.html %}
296
+
~~~sql
297
+
-- Create a view with security invoker explicitly set to true
298
+
CREATEVIEWuser_permissions_view WITH ( security_invoker = true ) ASSELECT*FROM users;
299
+
~~~
300
+
301
+
{% include_cached copy-clipboard.html %}
302
+
~~~sql
303
+
-- Create a view with security invoker disabled (runs with view owner permissions)
304
+
CREATEVIEWadmin_view WITH ( security_invoker = false ) ASSELECT*FROM admin_data;
305
+
~~~
306
+
307
+
{% include_cached copy-clipboard.html %}
308
+
~~~sql
309
+
-- Using integer values (1 = true, 0 = false)
310
+
CREATEVIEWnumeric_view WITH ( security_invoker =1 ) ASSELECTcount(*) FROM transactions;
311
+
~~~
312
+
313
+
---
314
+
315
+
## ALTER VIEW SET OPTIONS [NEEDS REVIEW]
316
+
317
+
{{site.data.alerts.callout_danger}}
318
+
**Note**: This feature is currently unimplemented. The grammar support has been added but attempting to use this syntax will result in an "unimplemented" error.
The `ALTER VIEW SET OPTIONS` statement would modify view options after creation, specifically the `security_invoker` setting that controls view permission behavior.
330
+
331
+
### Parameters
332
+
333
+
| Parameter | Description | Required |
334
+
| --- | --- | --- |
335
+
|`view_name`| the name of the view to modify | Yes |
336
+
|`security_invoker`| controls whether the view runs with the permissions of the view owner (false) or the current user (true). Accepts `true`, `false`, `1`, or `0`| Yes |
337
+
338
+
### Current Status
339
+
340
+
{% include_cached copy-clipboard.html %}
341
+
~~~sql
342
+
-- This will return an unimplemented error
343
+
ALTERVIEW my_view SET ( security_invoker = false );
344
+
~~~
345
+
346
+
```
347
+
ERROR: at or near ")": syntax error: unimplemented: this syntax
348
+
HINT: You have attempted to use a feature that is not yet implemented.
349
+
```
350
+
351
+
### See Also
352
+
353
+
-[`CREATE VIEW`]({% link {{ page.version.version }}/create-view.md %})
354
+
-[`DROP VIEW`]({% link {{ page.version.version }}/drop-view.md %})
355
+
-[`SHOW CREATE`]({% link {{ page.version.version }}/show-create.md %})
356
+
357
+
---
358
+
359
+
## Related Feature Flag
360
+
361
+
The security invoker functionality is controlled by the `allow_view_with_security_invoker_clause` session setting:
362
+
363
+
{% include_cached copy-clipboard.html %}
364
+
~~~sql
365
+
-- Enable security invoker support
366
+
SET allow_view_with_security_invoker_clause =on;
367
+
368
+
-- Verify the setting
369
+
SHOW allow_view_with_security_invoker_clause;
370
+
~~~
371
+
372
+
When this setting is disabled (default), attempting to create views with the `security_invoker` option will result in:
373
+
374
+
```
375
+
ERROR: security invoker views are not supported
376
+
```
377
+
378
+
[HUMAN REVIEW: The security invoker feature appears to be related to PostgreSQL-style security definer/invoker views, but the specific behavior and security implications should be verified against the intended implementation.]
0 commit comments