Alvaro Herrera wrote: > Looking at patch 04, it seems to me that it would be better to have > the OpcInfo struct carry the typecache struct rather than the type OID, > so that we can avoid repeated typecache lookups in brin_deform_tuple;
Here's the patch. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
commit 53f9b1ac9a4b73eddcb7acc99aeacff34336f7ad Author: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Tue May 5 16:19:53 2015 -0300 use typcache rather than oid diff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfuncs.c index 1b15a7b..bd3191d 100644 --- a/contrib/pageinspect/brinfuncs.c +++ b/contrib/pageinspect/brinfuncs.c @@ -181,7 +181,7 @@ brin_page_items(PG_FUNCTION_ARGS) column->nstored = opcinfo->oi_nstored; for (i = 0; i < opcinfo->oi_nstored; i++) { - getTypeOutputInfo(opcinfo->oi_typids[i], &output, &isVarlena); + getTypeOutputInfo(opcinfo->oi_typcache[i]->type_id, &output, &isVarlena); fmgr_info(output, &column->outputFn[i]); } diff --git a/doc/src/sgml/brin.sgml b/doc/src/sgml/brin.sgml index 1ac282c..92dac7c 100644 --- a/doc/src/sgml/brin.sgml +++ b/doc/src/sgml/brin.sgml @@ -428,8 +428,8 @@ typedef struct BrinOpcInfo /* Opaque pointer for the opclass' private use */ void *oi_opaque; - /* Type IDs of the stored columns */ - Oid oi_typids[FLEXIBLE_ARRAY_MEMBER]; + /* Type cache entries of the stored columns */ + TypeCacheEntry *oi_typcache[FLEXIBLE_ARRAY_MEMBER]; } BrinOpcInfo; </programlisting> <structname>BrinOpcInfo</>.<structfield>oi_opaque</> can be used by the diff --git a/src/backend/access/brin/brin_minmax.c b/src/backend/access/brin/brin_minmax.c index 299d6f7..ce8652d 100644 --- a/src/backend/access/brin/brin_minmax.c +++ b/src/backend/access/brin/brin_minmax.c @@ -62,8 +62,8 @@ brin_minmax_opcinfo(PG_FUNCTION_ARGS) result->oi_nstored = 2; result->oi_opaque = (MinmaxOpaque *) MAXALIGN((char *) result + SizeofBrinOpcInfo(2)); - result->oi_typids[0] = typoid; - result->oi_typids[1] = typoid; + result->oi_typcache[0] = result->oi_typcache[1] = + lookup_type_cache(typoid, 0); PG_RETURN_POINTER(result); } diff --git a/src/backend/access/brin/brin_tuple.c b/src/backend/access/brin/brin_tuple.c index 08fa998..22ce74a 100644 --- a/src/backend/access/brin/brin_tuple.c +++ b/src/backend/access/brin/brin_tuple.c @@ -68,7 +68,7 @@ brtuple_disk_tupdesc(BrinDesc *brdesc) { for (j = 0; j < brdesc->bd_info[i]->oi_nstored; j++) TupleDescInitEntry(tupdesc, attno++, NULL, - brdesc->bd_info[i]->oi_typids[j], + brdesc->bd_info[i]->oi_typcache[j]->type_id, -1, 0); } @@ -444,8 +444,8 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple) for (i = 0; i < brdesc->bd_info[keyno]->oi_nstored; i++) dtup->bt_columns[keyno].bv_values[i] = datumCopy(values[valueno++], - brdesc->bd_tupdesc->attrs[keyno]->attbyval, - brdesc->bd_tupdesc->attrs[keyno]->attlen); + brdesc->bd_info[keyno]->oi_typcache[i]->typbyval, + brdesc->bd_info[keyno]->oi_typcache[i]->typlen); dtup->bt_columns[keyno].bv_hasnulls = hasnulls[keyno]; dtup->bt_columns[keyno].bv_allnulls = false; diff --git a/src/include/access/brin_internal.h b/src/include/access/brin_internal.h index 84eed61..1486d04 100644 --- a/src/include/access/brin_internal.h +++ b/src/include/access/brin_internal.h @@ -16,6 +16,7 @@ #include "storage/bufpage.h" #include "storage/off.h" #include "utils/relcache.h" +#include "utils/typcache.h" /* @@ -32,13 +33,13 @@ typedef struct BrinOpcInfo /* Opaque pointer for the opclass' private use */ void *oi_opaque; - /* Type IDs of the stored columns */ - Oid oi_typids[FLEXIBLE_ARRAY_MEMBER]; + /* Type cache entries of the stored columns */ + TypeCacheEntry *oi_typcache[FLEXIBLE_ARRAY_MEMBER]; } BrinOpcInfo; /* the size of a BrinOpcInfo for the given number of columns */ #define SizeofBrinOpcInfo(ncols) \ - (offsetof(BrinOpcInfo, oi_typids) + sizeof(Oid) * ncols) + (offsetof(BrinOpcInfo, oi_typcache) + sizeof(TypeCacheEntry *) * ncols) typedef struct BrinDesc {
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers