Skip to content

Commit 774a975

Browse files
committed
Make naming of tupdesc related structs more consistent with the rest of PG.
We usually don't change the name of structs between the struct name itself and the name of the typedef. Additionally, structs that are usually used via a typedef that hides being a pointer, are commonly suffixed Data. Change tupdesc code to follow those convention. This is triggered by a future patch that intends to forward declare TupleDescData in another header - keeping with the naming scheme makes that easier to understand. Author: Andres Freund Discussion: https://postgr.es/m/[email protected]
1 parent e451dd5 commit 774a975

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

src/backend/access/common/tupdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ CreateTemplateTupleDesc(int natts)
6363
* could be less due to trailing padding, although with the current
6464
* definition of pg_attribute there probably isn't any padding.
6565
*/
66-
desc = (TupleDesc) palloc(offsetof(struct tupleDesc, attrs) +
66+
desc = (TupleDesc) palloc(offsetof(struct TupleDescData, attrs) +
6767
natts * sizeof(FormData_pg_attribute));
6868

6969
/*

src/backend/jit/llvm/llvmjit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ LLVMTypeRef StructItemPointerData;
6363
LLVMTypeRef StructBlockId;
6464
LLVMTypeRef StructFormPgAttribute;
6565
LLVMTypeRef StructTupleConstr;
66-
LLVMTypeRef StructtupleDesc;
66+
LLVMTypeRef StructTupleDescData;
6767
LLVMTypeRef StructTupleTableSlot;
6868
LLVMTypeRef StructHeapTupleTableSlot;
6969
LLVMTypeRef StructMinimalTupleTableSlot;
@@ -816,7 +816,7 @@ llvm_create_types(void)
816816
StructHeapTupleTableSlot = load_type(mod, "StructHeapTupleTableSlot");
817817
StructMinimalTupleTableSlot = load_type(mod, "StructMinimalTupleTableSlot");
818818
StructHeapTupleData = load_type(mod, "StructHeapTupleData");
819-
StructtupleDesc = load_type(mod, "StructtupleDesc");
819+
StructTupleDescData = load_type(mod, "StructTupleDescData");
820820
StructAggState = load_type(mod, "StructAggState");
821821
StructAggStatePerGroupData = load_type(mod, "StructAggStatePerGroupData");
822822
StructAggStatePerTransData = load_type(mod, "StructAggStatePerTransData");

src/backend/jit/llvm/llvmjit_types.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ MemoryContextData StructMemoryContextData;
6161
TupleTableSlot StructTupleTableSlot;
6262
HeapTupleTableSlot StructHeapTupleTableSlot;
6363
MinimalTupleTableSlot StructMinimalTupleTableSlot;
64-
struct tupleDesc StructtupleDesc;
64+
TupleDescData StructTupleDescData;
6565

6666

6767
/*

src/include/access/tupdesc.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#include "nodes/pg_list.h"
2020

2121

22-
typedef struct attrDefault
22+
typedef struct AttrDefault
2323
{
2424
AttrNumber adnum;
2525
char *adbin; /* nodeToString representation of expr */
2626
} AttrDefault;
2727

28-
typedef struct constrCheck
28+
typedef struct ConstrCheck
2929
{
3030
char *ccname;
3131
char *ccbin; /* nodeToString representation of expr */
@@ -34,11 +34,11 @@ typedef struct constrCheck
3434
} ConstrCheck;
3535

3636
/* This structure contains constraints of a tuple */
37-
typedef struct tupleConstr
37+
typedef struct TupleConstr
3838
{
3939
AttrDefault *defval; /* array */
4040
ConstrCheck *check; /* array */
41-
struct attrMissing *missing; /* missing attributes values, NULL if none */
41+
struct AttrMissing *missing; /* missing attributes values, NULL if none */
4242
uint16 num_defval;
4343
uint16 num_check;
4444
bool has_not_null;
@@ -75,7 +75,7 @@ typedef struct tupleConstr
7575
* field of such a descriptor to -1, while reference-counted descriptors
7676
* always have tdrefcount >= 0.
7777
*/
78-
typedef struct tupleDesc
78+
typedef struct TupleDescData
7979
{
8080
int natts; /* number of attributes in the tuple */
8181
Oid tdtypeid; /* composite type ID for tuple type */
@@ -84,7 +84,8 @@ typedef struct tupleDesc
8484
TupleConstr *constr; /* constraints, or NULL if none */
8585
/* attrs[N] is the description of Attribute Number N+1 */
8686
FormData_pg_attribute attrs[FLEXIBLE_ARRAY_MEMBER];
87-
} *TupleDesc;
87+
} TupleDescData;
88+
typedef struct TupleDescData *TupleDesc;
8889

8990
/* Accessor for the i'th attribute of tupdesc. */
9091
#define TupleDescAttr(tupdesc, i) (&(tupdesc)->attrs[(i)])
@@ -98,7 +99,7 @@ extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
9899
extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
99100

100101
#define TupleDescSize(src) \
101-
(offsetof(struct tupleDesc, attrs) + \
102+
(offsetof(struct TupleDescData, attrs) + \
102103
(src)->natts * sizeof(FormData_pg_attribute))
103104

104105
extern void TupleDescCopy(TupleDesc dst, TupleDesc src);

src/include/access/tupdesc_details.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Structure used to represent value to be used when the attribute is not
2020
* present at all in a tuple, i.e. when the column was created after the tuple
2121
*/
22-
typedef struct attrMissing
22+
typedef struct AttrMissing
2323
{
2424
bool am_present; /* true if non-NULL missing value exists */
2525
Datum am_value; /* value when attribute is missing */

src/include/jit/llvmjit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern LLVMTypeRef TypePGFunction;
6262
extern LLVMTypeRef TypeSizeT;
6363
extern LLVMTypeRef TypeStorageBool;
6464

65-
extern LLVMTypeRef StructtupleDesc;
65+
extern LLVMTypeRef StructTupleDescData;
6666
extern LLVMTypeRef StructHeapTupleData;
6767
extern LLVMTypeRef StructTupleTableSlot;
6868
extern LLVMTypeRef StructHeapTupleTableSlot;

0 commit comments

Comments
 (0)