gooderp18绿色标准版
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

64 linhas
5.9KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>SET SESSION AUTHORIZATION</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="sql-set-role.html" title="SET ROLE" /><link rel="next" href="sql-set-transaction.html" title="SET TRANSACTION" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">SET SESSION AUTHORIZATION</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-set-role.html" title="SET ROLE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-set-transaction.html" title="SET TRANSACTION">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-SET-SESSION-AUTHORIZATION"><div class="titlepage"></div><a id="id-1.9.3.176.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">SET SESSION AUTHORIZATION</span></h2><p>SET SESSION AUTHORIZATION — set the session user identifier and the current user identifier of the current session</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. SET [ SESSION | LOCAL ] SESSION AUTHORIZATION <em class="replaceable"><code>user_name</code></em>
  4. SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
  5. RESET SESSION AUTHORIZATION
  6. </pre></div><div class="refsect1" id="id-1.9.3.176.5"><h2>Description</h2><p>
  7. This command sets the session user identifier and the current user
  8. identifier of the current SQL session to be <em class="replaceable"><code>user_name</code></em>. The user name can be
  9. written as either an identifier or a string literal. Using this
  10. command, it is possible, for example, to temporarily become an
  11. unprivileged user and later switch back to being a superuser.
  12. </p><p>
  13. The session user identifier is initially set to be the (possibly
  14. authenticated) user name provided by the client. The current user
  15. identifier is normally equal to the session user identifier, but
  16. might change temporarily in the context of <code class="literal">SECURITY DEFINER</code>
  17. functions and similar mechanisms; it can also be changed by
  18. <a class="xref" href="sql-set-role.html" title="SET ROLE"><span class="refentrytitle">SET ROLE</span></a>.
  19. The current user identifier is relevant for permission checking.
  20. </p><p>
  21. The session user identifier can be changed only if the initial session
  22. user (the <em class="firstterm">authenticated user</em>) had the
  23. superuser privilege. Otherwise, the command is accepted only if it
  24. specifies the authenticated user name.
  25. </p><p>
  26. The <code class="literal">SESSION</code> and <code class="literal">LOCAL</code> modifiers act the same
  27. as for the regular <a class="xref" href="sql-set.html" title="SET"><span class="refentrytitle">SET</span></a>
  28. command.
  29. </p><p>
  30. The <code class="literal">DEFAULT</code> and <code class="literal">RESET</code> forms reset the session
  31. and current user identifiers to be the originally authenticated user
  32. name. These forms can be executed by any user.
  33. </p></div><div class="refsect1" id="id-1.9.3.176.6"><h2>Notes</h2><p>
  34. <code class="command">SET SESSION AUTHORIZATION</code> cannot be used within a
  35. <code class="literal">SECURITY DEFINER</code> function.
  36. </p></div><div class="refsect1" id="id-1.9.3.176.7"><h2>Examples</h2><pre class="programlisting">
  37. SELECT SESSION_USER, CURRENT_USER;
  38. session_user | current_user
  39. --------------+--------------
  40. peter | peter
  41. SET SESSION AUTHORIZATION 'paul';
  42. SELECT SESSION_USER, CURRENT_USER;
  43. session_user | current_user
  44. --------------+--------------
  45. paul | paul
  46. </pre></div><div class="refsect1" id="id-1.9.3.176.8"><h2>Compatibility</h2><p>
  47. The SQL standard allows some other expressions to appear in place
  48. of the literal <em class="replaceable"><code>user_name</code></em>, but these options
  49. are not important in practice. <span class="productname">PostgreSQL</span>
  50. allows identifier syntax (<code class="literal">"<em class="replaceable"><code>username</code></em>"</code>), which SQL
  51. does not. SQL does not allow this command during a transaction;
  52. <span class="productname">PostgreSQL</span> does not make this
  53. restriction because there is no reason to.
  54. The <code class="literal">SESSION</code> and <code class="literal">LOCAL</code> modifiers are a
  55. <span class="productname">PostgreSQL</span> extension, as is the
  56. <code class="literal">RESET</code> syntax.
  57. </p><p>
  58. The privileges necessary to execute this command are left
  59. implementation-defined by the standard.
  60. </p></div><div class="refsect1" id="id-1.9.3.176.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-set-role.html" title="SET ROLE"><span class="refentrytitle">SET ROLE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-set-role.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-set-transaction.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SET ROLE </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> SET TRANSACTION</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1