On Fri, 24 Jan 2003, Olleg Samoylov wrote: > On 23 Jan 2003, Rod Taylor wrote:
> Nope. CURRENT_USER and SESSION_USER return username. Sometimes need uid, > it's key usesysid in table pg_shadow, for instance, for row based > permissions. Explain in example: > > create table role { > role smallinteger, -- analog group of users > name text > } > > create table permission { -- link role with pg_user > uid integer references pg_user(usesysid), > role smallint references role > } > > create table protected_table { > -- payload fields > access smallint references role, > author_of_last_changes integer references pg_user(usesysid) default > PG_SESSION_UID(), -- proposed function > time_of_last_changes timestamp not null default current_timestamp > } As a side note, the above table definitions are pretty invalid. Referencing system tables is not guaranteed to work, and referencing system views even less so. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster