summaryrefslogtreecommitdiff
path: root/src/pl/tcl/pltcl.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-08-20 11:19:07 -0700
committerAndres Freund <andres@anarazel.de>2017-08-20 11:19:07 -0700
commit2cd70845240087da205695baedab6412342d1dbe (patch)
tree20a3b6a2231dae248218ac54983c7a854328265f /src/pl/tcl/pltcl.c
parentb1c2d76a2fcef812af0be3343082414d401909c8 (diff)
Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n).
This is a mechanical change in preparation for a later commit that will change the layout of TupleDesc. Introducing a macro to abstract the details of where attributes are stored will allow us to change that in separate step and revise it in future. Author: Thomas Munro, editorialized by Andres Freund Reviewed-By: Andres Freund Discussion: https://postgr.es/m/CAEepm=0ZtQ-SpsgCyzzYpsXS6e=kZWqk3g5Ygn3MDV7A8dabUA@mail.gmail.com
Diffstat (limited to 'src/pl/tcl/pltcl.c')
-rw-r--r--src/pl/tcl/pltcl.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index ed494e12108..09f87ec7916 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -1106,11 +1106,13 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
Tcl_ListObjAppendElement(NULL, tcl_trigtup, Tcl_NewObj());
for (i = 0; i < tupdesc->natts; i++)
{
- if (tupdesc->attrs[i]->attisdropped)
+ Form_pg_attribute att = TupleDescAttr(tupdesc, i);
+
+ if (att->attisdropped)
Tcl_ListObjAppendElement(NULL, tcl_trigtup, Tcl_NewObj());
else
Tcl_ListObjAppendElement(NULL, tcl_trigtup,
- Tcl_NewStringObj(utf_e2u(NameStr(tupdesc->attrs[i]->attname)), -1));
+ Tcl_NewStringObj(utf_e2u(NameStr(att->attname)), -1));
}
Tcl_ListObjAppendElement(NULL, tcl_cmd, tcl_trigtup);
@@ -2952,15 +2954,17 @@ pltcl_set_tuple_values(Tcl_Interp *interp, const char *arrayname,
for (i = 0; i < tupdesc->natts; i++)
{
+ Form_pg_attribute att = TupleDescAttr(tupdesc, i);
+
/* ignore dropped attributes */
- if (tupdesc->attrs[i]->attisdropped)
+ if (att->attisdropped)
continue;
/************************************************************
* Get the attribute name
************************************************************/
UTF_BEGIN;
- attname = pstrdup(UTF_E2U(NameStr(tupdesc->attrs[i]->attname)));
+ attname = pstrdup(UTF_E2U(NameStr(att->attname)));
UTF_END;
/************************************************************
@@ -2978,8 +2982,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, const char *arrayname,
************************************************************/
if (!isnull)
{
- getTypeOutputInfo(tupdesc->attrs[i]->atttypid,
- &typoutput, &typisvarlena);
+ getTypeOutputInfo(att->atttypid, &typoutput, &typisvarlena);
outputstr = OidOutputFunctionCall(typoutput, attr);
UTF_BEGIN;
Tcl_SetVar2Ex(interp, *arrptr, *nameptr,
@@ -3013,14 +3016,16 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
for (i = 0; i < tupdesc->natts; i++)
{
+ Form_pg_attribute att = TupleDescAttr(tupdesc, i);
+
/* ignore dropped attributes */
- if (tupdesc->attrs[i]->attisdropped)
+ if (att->attisdropped)
continue;
/************************************************************
* Get the attribute name
************************************************************/
- attname = NameStr(tupdesc->attrs[i]->attname);
+ attname = NameStr(att->attname);
/************************************************************
* Get the attributes value
@@ -3037,7 +3042,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
************************************************************/
if (!isnull)
{
- getTypeOutputInfo(tupdesc->attrs[i]->atttypid,
+ getTypeOutputInfo(att->atttypid,
&typoutput, &typisvarlena);
outputstr = OidOutputFunctionCall(typoutput, attr);
UTF_BEGIN;