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-2020, 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;
38 } AttrMap;
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);
47  TupleDesc outdesc);
49  TupleDesc outdesc,
50  const char *msg);
51 
52 #endif /* ATTMAP_H */
AttrMap * make_attrmap(int maplen)
Definition: attmap.c:41
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc)
Definition: attmap.c:174
int maplen
Definition: attmap.h:37
Definition: attmap.h:34
AttrMap * build_attrmap_by_position(TupleDesc indesc, TupleDesc outdesc, const char *msg)
Definition: attmap.c:76
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc)
Definition: attmap.c:259
AttrNumber * attnums
Definition: attmap.h:36
struct AttrMap AttrMap
void free_attrmap(AttrMap *map)
Definition: attmap.c:57
int16 AttrNumber
Definition: attnum.h:21