MCPcopy Create free account
hub / github.com/apache/cloudberry / CatCacheCopyKeys

Function CatCacheCopyKeys

src/backend/utils/cache/catcache.c:2002–2037  ·  view source on GitHub ↗

* Helper routine that copies the keys in the srckeys array into the dstkeys * one, guaranteeing that the datums are fully allocated in the current memory * context. */

Source from the content-addressed store, hash-verified

2000 * context.
2001 */
2002static void
2003CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, int *attnos,
2004 Datum *srckeys, Datum *dstkeys)
2005{
2006 int i;
2007
2008 /*
2009 * XXX: memory and lookup performance could possibly be improved by
2010 * storing all keys in one allocation.
2011 */
2012
2013 for (i = 0; i < nkeys; i++)
2014 {
2015 int attnum = attnos[i];
2016 Form_pg_attribute att = TupleDescAttr(tupdesc, attnum - 1);
2017 Datum src = srckeys[i];
2018 NameData srcname;
2019
2020 /*
2021 * Must be careful in case the caller passed a C string where a NAME
2022 * is wanted: convert the given argument to a correctly padded NAME.
2023 * Otherwise the memcpy() done by datumCopy() could fall off the end
2024 * of memory.
2025 */
2026 if (att->atttypid == NAMEOID)
2027 {
2028 namestrcpy(&srcname, DatumGetCString(src));
2029 src = NameGetDatum(&srcname);
2030 }
2031
2032 dstkeys[i] = datumCopy(src,
2033 att->attbyval,
2034 att->attlen);
2035 }
2036
2037}
2038
2039/*
2040 * PrepareToInvalidateCacheTuple()

Callers 2

SearchCatCacheListFunction · 0.85
CatalogCacheCreateEntryFunction · 0.85

Calls 4

namestrcpyFunction · 0.85
DatumGetCStringFunction · 0.85
NameGetDatumFunction · 0.85
datumCopyFunction · 0.85

Tested by

no test coverage detected