/* ---------------------------------------------------------------- * caql_getattname() * * The equivalent of SearchSysCacheCopyAttName - * caql_getfirst(pCtx, * "SELECT * FROM pg_attribute * WHERE attrelid = :relid * AND attname = :attname * AND attisdropped is false" * ); * * That is, find the existing ("undropped") attribute and return * a copy. * NOTE: need to be careful if this pCtx is used for update... * ---------------------------------------------------------------- */ HeapTuple caql_getattname(cqContext *pCtx, Oid relid, const char *attname) { HeapTuple tup; tup = SearchSysCacheCopyAttName(relid, attname); if (pCtx) { /* treat as ATTNAME cache lookup */ pCtx->cq_usesyscache = true; pCtx->cq_cacheId = ATTNAME; pCtx->cq_NumKeys = 2; /* NOTE: no valid relation for subsequent INSERT/UPDATE/DELETE *unless* an external relation is supplied */ if (!pCtx->cq_externrel) { pCtx->cq_externrel = true; /* pretend we have external relation */ pCtx->cq_heap_rel = InvalidRelation; } if (!pCtx->cq_setidxOK) pCtx->cq_useidxOK = true; pCtx->cq_lasttup = tup; } return (tup); }
/* ---------------------------------------------------------------- * caql_getattname() * * The equivalent of SearchSysCacheCopyAttName - * caql_getfirst(pCtx, * "SELECT * FROM pg_attribute * WHERE attrelid = :relid * AND attname = :attname * AND attisdropped is false" * ); * * That is, find the existing ("undropped") attribute and return * a copy. * NOTE: need to be careful if this pCtx is used for update... * ---------------------------------------------------------------- */ HeapTuple caql_getattname(cqContext *pCtx, Oid relid, const char *attname) { HeapTuple tup; disable_attribute_check(relid); tup = SearchSysCacheCopyAttName(relid, attname); if (pCtx) { /* treat as ATTNAME cache lookup */ pCtx->cq_usesyscache = true; pCtx->cq_cacheId = ATTNAME; pCtx->cq_NumKeys = 2; /* NOTE: no valid relation for subsequent INSERT/UPDATE/DELETE *unless* an external relation is supplied */ if (!pCtx->cq_externrel) { pCtx->cq_externrel = true; /* pretend we have external relation */ pCtx->cq_heap_rel = InvalidRelation; } if (!pCtx->cq_setidxOK) pCtx->cq_useidxOK = true; /* for caql_update_current(), etc */ if (pCtx->cq_setpklock) caql_iud_switch(pCtx, 0, tup, NULL, false /* Wait */); pCtx->cq_lasttup = tup; } return tup; }