From: Marko Kreen Date: Thu, 12 Apr 2012 11:33:29 +0000 (+0300) Subject: Provide get_role_oid() on older Postgres X-Git-Tag: plproxy_2_4~6 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=88bd709b5041f1215ac7644408b2b540a3b7b582;p=plproxy.git Provide get_role_oid() on older Postgres --- diff --git a/src/cluster.c b/src/cluster.c index fc59c36..ead16d5 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -963,6 +963,23 @@ get_userinfo(ProxyCluster *cluster, Oid user_oid) return userinfo; } +#if PG_VERSION_NUM < 90100 + +static Oid +get_role_oid(const char *rolname, bool missing_ok) +{ + Oid oid; + + oid = GetSysCacheOid1(AUTHNAME, CStringGetDatum(rolname)); + if (!OidIsValid(oid) && !missing_ok) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("role \"%s\" does not exist", rolname))); + return oid; +} + +#endif + /* * Refresh the cluster. */ @@ -971,7 +988,7 @@ refresh_cluster(ProxyFunction *func, ProxyCluster *cluster) { ConnUserInfo *uinfo; ProxyConfig *cf = &cluster->config; - Oid user_oid; + Oid user_oid = InvalidOid; /* * Decide which user to use for connections.