Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
29a20145
Commit
29a20145
authored
Sep 03, 2003
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass session_authorization to the client and make psql update its prompt
accordingly.
parent
4e85f760
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
15 deletions
+54
-15
doc/src/sgml/libpq.sgml
doc/src/sgml/libpq.sgml
+3
-2
doc/src/sgml/protocol.sgml
doc/src/sgml/protocol.sgml
+3
-2
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+18
-5
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+2
-2
src/bin/psql/common.c
src/bin/psql/common.c
+24
-1
src/bin/psql/common.h
src/bin/psql/common.h
+2
-1
src/bin/psql/prompt.c
src/bin/psql/prompt.c
+2
-2
No files found.
doc/src/sgml/libpq.sgml
View file @
29a20145
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.13
4 2003/09/01 23:04:49
petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.13
5 2003/09/03 22:05:01
petere Exp $
-->
-->
<chapter id="libpq">
<chapter id="libpq">
...
@@ -857,7 +857,8 @@ is not known.
...
@@ -857,7 +857,8 @@ is not known.
Parameters reported as of the current release include
Parameters reported as of the current release include
<literal>server_version</> (cannot change after startup);
<literal>server_version</> (cannot change after startup);
<literal>client_encoding</>,
<literal>client_encoding</>,
<literal>is_superuser</>, and
<literal>is_superuser</>,
<literal>session_authorization</literal>, and
<literal>DateStyle</>.
<literal>DateStyle</>.
</para>
</para>
...
...
doc/src/sgml/protocol.sgml
View file @
29a20145
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.4
2 2003/09/01 23:04:49
petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.4
3 2003/09/03 22:05:07
petere Exp $ -->
<chapter id="protocol">
<chapter id="protocol">
<title>Frontend/Backend Protocol</title>
<title>Frontend/Backend Protocol</title>
...
@@ -1006,7 +1006,8 @@
...
@@ -1006,7 +1006,8 @@
<literal>server_version</> (a pseudo-parameter that cannot change after
<literal>server_version</> (a pseudo-parameter that cannot change after
startup);
startup);
<literal>client_encoding</>,
<literal>client_encoding</>,
<literal>is_superuser</>, and
<literal>is_superuser</>,
<literal>session_authorization</literal>, and
<literal>DateStyle</>.
<literal>DateStyle</>.
This set might change in the future, or even become configurable.
This set might change in the future, or even become configurable.
Accordingly, a frontend should simply ignore ParameterStatus for
Accordingly, a frontend should simply ignore ParameterStatus for
...
...
doc/src/sgml/ref/psql-ref.sgml
View file @
29a20145
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.9
5 2003/08/31 17:32:24
petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.9
6 2003/09/03 22:05:08
petere Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -2214,8 +2214,14 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
...
@@ -2214,8 +2214,14 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
<varlistentry>
<varlistentry>
<term><literal>%n</literal></term>
<term><literal>%n</literal></term>
<listitem><para>The user name you are connected as (not your local system
<listitem>
user name).</para></listitem>
<para>
The database session user name. (The expansion of this
value might change during a database session as the result
of the command <command>SET SESSION
AUTHORIZATION</command>.)
</para>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<varlistentry>
...
@@ -2231,8 +2237,15 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
...
@@ -2231,8 +2237,15 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
<varlistentry>
<varlistentry>
<term><literal>%#</literal></term>
<term><literal>%#</literal></term>
<listitem><para>If the current user is a database superuser, then a
<listitem>
<literal>#</literal>, otherwise a <literal>></literal>.</para></listitem>
<para>
If the session user is a database superuser, then a
<literal>#</literal>, otherwise a <literal>></literal>.
(The expansion of this value might change during a database
session as the result of the command <command>SET SESSION
AUTHORIZATION</command>.)
</para>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<varlistentry>
...
...
src/backend/utils/misc/guc.c
View file @
29a20145
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.15
3 2003/09/01 23:04:49
petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.15
4 2003/09/03 22:05:08
petere Exp $
*
*
*--------------------------------------------------------------------
*--------------------------------------------------------------------
*/
*/
...
@@ -1501,7 +1501,7 @@ static struct config_string ConfigureNamesString[] =
...
@@ -1501,7 +1501,7 @@ static struct config_string ConfigureNamesString[] =
{
"session_authorization"
,
PGC_USERSET
,
UNGROUPED
,
{
"session_authorization"
,
PGC_USERSET
,
UNGROUPED
,
gettext_noop
(
"Current session userid"
),
gettext_noop
(
"Current session userid"
),
NULL
,
NULL
,
GUC_NO_SHOW_ALL
|
GUC_NO_RESET_ALL
|
GUC_NOT_IN_SAMPLE
|
GUC_DISALLOW_IN_FILE
GUC_
REPORT
|
GUC_
NO_SHOW_ALL
|
GUC_NO_RESET_ALL
|
GUC_NOT_IN_SAMPLE
|
GUC_DISALLOW_IN_FILE
},
},
&
session_authorization_string
,
&
session_authorization_string
,
NULL
,
assign_session_authorization
,
show_session_authorization
NULL
,
assign_session_authorization
,
show_session_authorization
...
...
src/bin/psql/common.c
View file @
29a20145
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.7
2 2003/08/14 18:48:35 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.7
3 2003/09/03 22:05:08 petere
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "common.h"
#include "common.h"
...
@@ -724,3 +724,26 @@ is_superuser(void)
...
@@ -724,3 +724,26 @@ is_superuser(void)
return
false
;
return
false
;
}
}
/*
* Return the session user of the current connection.
*
* Note: this will correctly detect the session user only with a
* protocol-3.0 or newer backend; otherwise it will return the
* connection user.
*/
const
char
*
session_username
(
void
)
{
const
char
*
val
;
if
(
!
pset
.
db
)
return
NULL
;
val
=
PQparameterStatus
(
pset
.
db
,
"session_authorization"
);
if
(
val
)
return
val
;
else
return
PQuser
(
pset
.
db
);
}
src/bin/psql/common.h
View file @
29a20145
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.2
8 2003/08/08 04:52:21 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.2
9 2003/09/03 22:05:09 petere
Exp $
*/
*/
#ifndef COMMON_H
#ifndef COMMON_H
#define COMMON_H
#define COMMON_H
...
@@ -37,6 +37,7 @@ extern PGresult *PSQLexec(const char *query, bool start_xact);
...
@@ -37,6 +37,7 @@ extern PGresult *PSQLexec(const char *query, bool start_xact);
extern
bool
SendQuery
(
const
char
*
query
);
extern
bool
SendQuery
(
const
char
*
query
);
extern
bool
is_superuser
(
void
);
extern
bool
is_superuser
(
void
);
extern
const
char
*
session_username
(
void
);
/* Parse a numeric character code from the string pointed at by *buf, e.g.
/* Parse a numeric character code from the string pointed at by *buf, e.g.
* one written as 0x0c (hexadecimal) or 015 (octal); advance *buf to the last
* one written as 0x0c (hexadecimal) or 015 (octal); advance *buf to the last
...
...
src/bin/psql/prompt.c
View file @
29a20145
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.2
8 2003/08/04 23:59:40 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.2
9 2003/09/03 22:05:09 petere
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "prompt.h"
#include "prompt.h"
...
@@ -160,7 +160,7 @@ get_prompt(promptStatus_t status)
...
@@ -160,7 +160,7 @@ get_prompt(promptStatus_t status)
/* DB server user name */
/* DB server user name */
case
'n'
:
case
'n'
:
if
(
pset
.
db
)
if
(
pset
.
db
)
strncpy
(
buf
,
PQuser
(
pset
.
db
),
MAX_PROMPT_SIZE
);
strncpy
(
buf
,
session_username
(
),
MAX_PROMPT_SIZE
);
break
;
break
;
case
'0'
:
case
'0'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment