|
| 1 | +<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/set_session_auth.sgml,v 1.1 2001/05/08 21:06:42 petere Exp $ --> |
| 2 | +<refentry id="SQL-SET-SESSION-AUTHORIZATION"> |
| 3 | + <docinfo> |
| 4 | + <date>2001-04-21</date> |
| 5 | + </docinfo> |
| 6 | + |
| 7 | + <refmeta> |
| 8 | + <refentrytitle>SET SESSION AUTHORIZATION</refentrytitle> |
| 9 | + <refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 10 | + </refmeta> |
| 11 | + |
| 12 | + <refnamediv> |
| 13 | + <refname>SET SESSION AUTHORIZATION</refname> |
| 14 | + <refpurpose>Set the session user identifier and the current user identifier |
| 15 | + of the current SQL-session context</refpurpose> |
| 16 | + </refnamediv> |
| 17 | + |
| 18 | + <refsynopsisdiv> |
| 19 | +<synopsis> |
| 20 | +SET SESSION AUTHORIZATION '<parameter>username</parameter>' |
| 21 | +</synopsis> |
| 22 | + </refsynopsisdiv> |
| 23 | + |
| 24 | + <refsect1> |
| 25 | + <title>Description</title> |
| 26 | + |
| 27 | + <para> |
| 28 | + This command sets the session user identifier and the current user |
| 29 | + identifer of the current SQL-session context to be |
| 30 | + <parameter>username</parameter>. |
| 31 | + </para> |
| 32 | + |
| 33 | + <para> |
| 34 | + The session user identifier is initially set to be the (possibly |
| 35 | + authenticated) user name provided by the client. The current user |
| 36 | + identifier is normally equal to the session user identifier, but |
| 37 | + may change temporarily in the context of <quote>setuid</quote> |
| 38 | + functions and similar mechanisms. The current user identifer is |
| 39 | + relevant for permission checking. |
| 40 | + </para> |
| 41 | + |
| 42 | + <para> |
| 43 | + Execution of this command is only permitted if the initial session |
| 44 | + user (the <firstterm>authenticated user</firstterm>) had the |
| 45 | + superuser privilege. This permission is kept for the duration of a |
| 46 | + connection; for example, it is possible to temporarily become an |
| 47 | + unprivileged user and later switch back to become a superuser. |
| 48 | + </para> |
| 49 | + </refsect1> |
| 50 | + |
| 51 | + <refsect1> |
| 52 | + <title>Examples</title> |
| 53 | + |
| 54 | +<screen> |
| 55 | +<userinput>SELECT SESSION_USER, CURRENT_USER;</userinput> |
| 56 | + current_user | session_user |
| 57 | +--------------+-------------- |
| 58 | + peter | peter |
| 59 | + |
| 60 | +<userinput>SET SESSION AUTHORIZATION 'paul';</userinput> |
| 61 | + |
| 62 | +<userinput>SELECT SESSION_USER, CURRENT_USER;</userinput> |
| 63 | + current_user | session_user |
| 64 | +--------------+-------------- |
| 65 | + paul | paul |
| 66 | +</screen> |
| 67 | + </refsect1> |
| 68 | + |
| 69 | + <refsect1> |
| 70 | + <title>Compatibility</title> |
| 71 | + |
| 72 | + <simpara>SQL99</simpara> |
| 73 | + |
| 74 | + <para> |
| 75 | + SQL99 allows some other expressions to appear in place of the |
| 76 | + literal <parameter>username</parameter> which are not important in |
| 77 | + practice. <application>PostgreSQL</application> allows identifier |
| 78 | + syntax (<literal>"username"</literal>), which SQL does not. SQL |
| 79 | + does not allow this command during a transaction; |
| 80 | + <application>PostgreSQL</application> does not make |
| 81 | + this restriction because there is no reason to. The |
| 82 | + privileges necessary to execute this command are left |
| 83 | + implementation-defined by the standard. |
| 84 | + </para> |
| 85 | + </refsect1> |
| 86 | +</refentry> |
| 87 | + |
| 88 | +<!-- Keep this comment at the end of the file |
| 89 | +Local variables: |
| 90 | +mode:sgml |
| 91 | +sgml-omittag:nil |
| 92 | +sgml-shorttag:t |
| 93 | +sgml-minimize-attributes:nil |
| 94 | +sgml-always-quote-attributes:t |
| 95 | +sgml-indent-step:1 |
| 96 | +sgml-indent-data:t |
| 97 | +sgml-parent-document:nil |
| 98 | +sgml-default-dtd-file:"../reference.ced" |
| 99 | +sgml-exposed-tags:nil |
| 100 | +sgml-local-catalogs:("/usr/lib/sgml/catalog") |
| 101 | +sgml-local-ecat-files:nil |
| 102 | +End: |
| 103 | +--> |