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
21
22typedef struct TupleConversionMap
23{
24 TupleDesc indesc; /* tupdesc for source rowtype */
25 TupleDesc outdesc; /* tupdesc for result rowtype */
26 AttrNumber *attrMap; /* indexes of input fields, or 0 for null */
27 Datum *invalues; /* workspace for deconstructing source */
28 bool *inisnull;
29 Datum *outvalues; /* workspace for constructing result */
30 bool *outisnull;
31} TupleConversionMap;
32
33
34extern TupleConversionMap *convert_tuples_by_position(TupleDesc indesc,
35 TupleDesc outdesc,
36 const char *msg);
37
38extern TupleConversionMap *convert_tuples_by_name(TupleDesc indesc,
39 TupleDesc outdesc,
40 const char *msg);
41
42extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
43 TupleDesc outdesc,
44 const char *msg);
45extern AttrNumber *convert_tuples_by_name_map_if_req(TupleDesc indesc,
46 TupleDesc outdesc,
47 const char *msg);
48
49extern HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map);
50extern TupleTableSlot *execute_attr_map_slot(AttrNumber *attrMap,
51 TupleTableSlot *in_slot, TupleTableSlot *out_slot);
52
53extern void free_conversion_map(TupleConversionMap *map);
54
55#endif /* TUPCONVERT_H */
56