From 88bd709b5041f1215ac7644408b2b540a3b7b582 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Thu, 12 Apr 2012 14:33:29 +0300 Subject: [PATCH] Provide get_role_oid() on older Postgres --- src/cluster.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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. -- 2.39.5