PostgreSQL Source Code  git master
attmap.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * attmap.h
4  * Definitions for PostgreSQL attribute mappings
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/attmap.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef ATTMAP_H
15 #define ATTMAP_H
16 
17 #include "access/attnum.h"
18 #include "access/tupdesc.h"
19 
20 /*
21  * Attribute mapping structure
22  *
23  * This maps attribute numbers between a pair of relations, designated
24  * 'input' and 'output' (most typically inheritance parent and child
25  * relations), whose common columns may have different attribute numbers.
26  * Such difference may arise due to the columns being ordered differently
27  * in the two relations or the two relations having dropped columns at
28  * different positions.
29  *
30  * 'maplen' is set to the number of attributes of the 'output' relation,
31  * taking into account any of its dropped attributes, with the corresponding
32  * elements of the 'attnums' array set to 0.
33  */
34 typedef struct AttrMap
35 {
37  int maplen;
39 
40 extern AttrMap *make_attrmap(int maplen);
41 extern void free_attrmap(AttrMap *map);
42 
43 /* Conversion routines to build mappings */
45  TupleDesc outdesc,
46  bool missing_ok);
48  TupleDesc outdesc,
49  bool missing_ok);
51  TupleDesc outdesc,
52  const char *msg);
53 
54 #endif /* ATTMAP_H */
struct AttrMap AttrMap
void free_attrmap(AttrMap *map)
Definition: attmap.c:56
AttrMap * make_attrmap(int maplen)
Definition: attmap.c:40
AttrMap * build_attrmap_by_position(TupleDesc indesc, TupleDesc outdesc, const char *msg)
Definition: attmap.c:75
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
Definition: attmap.c:263
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
Definition: attmap.c:177
int16 AttrNumber
Definition: attnum.h:21
Definition: attmap.h:35
int maplen
Definition: attmap.h:37
AttrNumber * attnums
Definition: attmap.h:36