1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Implement differentiation between CURRENT_USER and SESSION_USER as per SQL.

There is still no effective difference but it will kick in once setuid
functions exist (not included here).  Make old getpgusername() alias for
current_user.
This commit is contained in:
Peter Eisentraut
2000-09-19 18:18:04 +00:00
parent e9c3f0255f
commit 457ac0331c
12 changed files with 166 additions and 65 deletions

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.29 2000/08/03 16:34:22 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.30 2000/09/19 18:17:56 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,13 +136,6 @@ namege(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) >= 0);
}
/* SQL-function interface to GetPgUserName() */
Datum
getpgusername(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(DirectFunctionCall1(namein,
CStringGetDatum(GetPgUserName())));
}
/* (see char.c for comparison/operation routines) */
@@ -218,6 +211,21 @@ namestrcmp(Name name, const char *str)
return strncmp(NameStr(*name), str, NAMEDATALEN);
}
/* SQL-functions CURRENT_USER and SESSION_USER */
Datum
current_user(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(DirectFunctionCall1(namein, CStringGetDatum(GetUserName(GetUserId()))));
}
Datum
session_user(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(DirectFunctionCall1(namein, CStringGetDatum(GetUserName(GetSessionUserId()))));
}
/*****************************************************************************
* PRIVATE ROUTINES *
*****************************************************************************/