Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Add syscache for babelfish_authid_user_ext catalog #214

Open
wants to merge 1 commit into
base: BABEL_3_X_DEV__PG_15_X
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/backend/utils/cache/catcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "common/hashfn.h"
#include "miscadmin.h"
#include "port/pg_bitutils.h"
#include "parser/parser.h"
#ifdef CATCACHE_STATS
#include "storage/ipc.h" /* for on_proc_exit */
#endif
Expand All @@ -39,6 +40,7 @@
#include "utils/rel.h"
#include "utils/resowner_private.h"
#include "utils/syscache.h"
#include "utils/lsyscache.h"


/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
Expand Down Expand Up @@ -255,6 +257,34 @@ GetCCHashEqFuncs(Oid keytype, CCHashFN *hashfunc, RegProcedure *eqfunc, CCFastEq
*eqfunc = F_OIDVECTOREQ;
break;
default:
if (sql_dialect == SQL_DIALECT_TSQL)
{
HeapTuple tp;
Form_pg_type typtuple;
char *typname = NULL;
char *nspname = NULL;
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keytype));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for type %u", keytype);
typtuple = (Form_pg_type) GETSTRUCT(tp);
typname = NameStr(typtuple->typname);

nspname = get_namespace_name(typtuple->typnamespace);
if (!nspname)
elog(ERROR, "cache lookup failed for namespace %u",
typtuple->typnamespace);

ReleaseSysCache(tp);
elog(LOG, "%s.%s",nspname, typname);

if (strcmp(nspname, "sys") == 0 && strcmp(typname, "nvarchar") == 0)
{
*hashfunc = texthashfast;
*fasteqfunc = texteqfast;
*eqfunc = F_TEXTEQ;
break;
}
}
elog(FATAL, "type %u not supported as catcache key", keytype);
*hashfunc = NULL; /* keep compiler quiet */

Expand Down
5 changes: 3 additions & 2 deletions src/include/utils/syscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ enum SysCacheIdentifier
*/
SYSDATABASEOID,
SYSDATABASENAME,
PROCNSPSIGNATURE
PROCNSPSIGNATURE,
TSQLUSERMAP

#define SysCacheNoExtensionSize (USERMAPPINGUSERSERVER+ 1)
#define SysCacheSize (PROCNSPSIGNATURE + 1)
#define SysCacheSize (TSQLUSERMAP + 1)
};

/*
Expand Down