1 /*-------------------------------------------------------------------------
2  *
3  * tupconvert.h
4  *	  Tuple conversion support.
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/tupconvert.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef TUPCONVERT_H
15 #define TUPCONVERT_H
16 
17 #include "access/htup.h"
18 #include "access/tupdesc.h"
19 #include "executor/tuptable.h"
20 #include "nodes/bitmapset.h"
21 
22 
23 typedef struct TupleConversionMap
24 {
25 	TupleDesc	indesc;			/* tupdesc for source rowtype */
26 	TupleDesc	outdesc;		/* tupdesc for result rowtype */
27 	AttrNumber *attrMap;		/* indexes of input fields, or 0 for null */
28 	Datum	   *invalues;		/* workspace for deconstructing source */
29 	bool	   *inisnull;
30 	Datum	   *outvalues;		/* workspace for constructing result */
31 	bool	   *outisnull;
32 } TupleConversionMap;
33 
34 
35 extern TupleConversionMap *convert_tuples_by_position(TupleDesc indesc,
36 													  TupleDesc outdesc,
37 													  const char *msg);
38 
39 extern TupleConversionMap *convert_tuples_by_name(TupleDesc indesc,
40 												  TupleDesc outdesc,
41 												  const char *msg);
42 
43 extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
44 											  TupleDesc outdesc,
45 											  const char *msg);
46 extern AttrNumber *convert_tuples_by_name_map_if_req(TupleDesc indesc,
47 													 TupleDesc outdesc,
48 													 const char *msg);
49 
50 extern HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map);
51 extern TupleTableSlot *execute_attr_map_slot(AttrNumber *attrMap,
52 											 TupleTableSlot *in_slot, TupleTableSlot *out_slot);
53 extern Bitmapset *execute_attr_map_cols(Bitmapset *inbitmap, TupleConversionMap *map);
54 
55 extern void free_conversion_map(TupleConversionMap *map);
56 
57 #endif							/* TUPCONVERT_H */
58