attmap.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*-------------------------------------------------------------------------
  2. *
  3. * attmap.h
  4. * Definitions for PostgreSQL attribute mappings
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, 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. #include "access/attnum.h"
  17. #include "access/tupdesc.h"
  18. /*
  19. * Attribute mapping structure
  20. *
  21. * This maps attribute numbers between a pair of relations, designated
  22. * 'input' and 'output' (most typically inheritance parent and child
  23. * relations), whose common columns may have different attribute numbers.
  24. * Such difference may arise due to the columns being ordered differently
  25. * in the two relations or the two relations having dropped columns at
  26. * different positions.
  27. *
  28. * 'maplen' is set to the number of attributes of the 'output' relation,
  29. * taking into account any of its dropped attributes, with the corresponding
  30. * elements of the 'attnums' array set to 0.
  31. */
  32. typedef struct AttrMap
  33. {
  34. AttrNumber *attnums;
  35. int maplen;
  36. } AttrMap;
  37. extern AttrMap *make_attrmap(int maplen);
  38. extern void free_attrmap(AttrMap *map);
  39. /* Conversion routines to build mappings */
  40. extern AttrMap *build_attrmap_by_name(TupleDesc indesc,
  41. TupleDesc outdesc);
  42. extern AttrMap *build_attrmap_by_name_if_req(TupleDesc indesc,
  43. TupleDesc outdesc);
  44. extern AttrMap *build_attrmap_by_position(TupleDesc indesc,
  45. TupleDesc outdesc,
  46. const char *msg);
  47. #endif /* ATTMAP_H */