Branch data Line data Source code
1 : : /*-------------------------------------------------------------------------
2 : : *
3 : : * pgpa_identifier.h
4 : : * create appropriate identifiers for range table entries
5 : : *
6 : : * Copyright (c) 2016-2025, PostgreSQL Global Development Group
7 : : *
8 : : * contrib/pg_plan_advice/pgpa_identifier.h
9 : : *
10 : : *-------------------------------------------------------------------------
11 : : */
12 : :
13 : : #ifndef PGPA_IDENTIFIER_H
14 : : #define PGPA_IDENTIFIER_H
15 : :
16 : : #include "nodes/pathnodes.h"
17 : : #include "nodes/plannodes.h"
18 : :
19 : : typedef struct pgpa_identifier
20 : : {
21 : : const char *alias_name;
22 : : int occurrence;
23 : : const char *partnsp;
24 : : const char *partrel;
25 : : const char *plan_name;
26 : : } pgpa_identifier;
27 : :
28 : : /* Convenience function for comparing possibly-NULL strings. */
29 : : static inline bool
30 : 61116 : strings_equal_or_both_null(const char *a, const char *b)
31 : : {
32 [ + + ]: 61116 : if (a == b)
33 : 60982 : return true;
34 [ + + + + ]: 134 : else if (a == NULL || b == NULL)
35 : 52 : return false;
36 : : else
37 : 82 : return strcmp(a, b) == 0;
38 : 61116 : }
39 : :
40 : : extern const char *pgpa_identifier_string(const pgpa_identifier *rid);
41 : : extern void pgpa_compute_identifier_by_rti(PlannerInfo *root, Index rti,
42 : : pgpa_identifier *rid);
43 : : extern int pgpa_compute_identifiers_by_relids(PlannerInfo *root,
44 : : Bitmapset *relids,
45 : : pgpa_identifier *rids);
46 : : extern pgpa_identifier *pgpa_create_identifiers_for_planned_stmt(PlannedStmt *pstmt);
47 : :
48 : : extern Index pgpa_compute_rti_from_identifier(int rtable_length,
49 : : pgpa_identifier *rt_identifiers,
50 : : pgpa_identifier *rid);
51 : :
52 : : #endif
|