PostgreSQL Source Code  git master
pg_list.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_list.h
4  * interface for PostgreSQL generic list package
5  *
6  * Once upon a time, parts of Postgres were written in Lisp and used real
7  * cons-cell lists for major data structures. When that code was rewritten
8  * in C, we initially had a faithful emulation of cons-cell lists, which
9  * unsurprisingly was a performance bottleneck. A couple of major rewrites
10  * later, these data structures are actually simple expansible arrays;
11  * but the "List" name and a lot of the notation survives.
12  *
13  * One important concession to the original implementation is that an empty
14  * list is always represented by a null pointer (preferentially written NIL).
15  * Non-empty lists have a header, which will not be relocated as long as the
16  * list remains non-empty, and an expansible data array.
17  *
18  * We support three types of lists:
19  *
20  * T_List: lists of pointers
21  * (in practice usually pointers to Nodes, but not always;
22  * declared as "void *" to minimize casting annoyances)
23  * T_IntList: lists of integers
24  * T_OidList: lists of Oids
25  *
26  * (At the moment, ints and Oids are the same size, but they may not
27  * always be so; try to be careful to maintain the distinction.)
28  *
29  *
30  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
31  * Portions Copyright (c) 1994, Regents of the University of California
32  *
33  * src/include/nodes/pg_list.h
34  *
35  *-------------------------------------------------------------------------
36  */
37 #ifndef PG_LIST_H
38 #define PG_LIST_H
39 
40 #include "nodes/nodes.h"
41 
42 
43 typedef union ListCell
44 {
45  void *ptr_value;
46  int int_value;
48 } ListCell;
49 
50 typedef struct List
51 {
52  NodeTag type; /* T_List, T_IntList, or T_OidList */
53  int length; /* number of elements currently present */
54  int max_length; /* allocated length of elements[] */
55  ListCell *elements; /* re-allocatable array of cells */
56  /* We may allocate some cells along with the List header: */
57  ListCell initial_elements[FLEXIBLE_ARRAY_MEMBER];
58  /* If elements == initial_elements, it's not a separate allocation */
59 } List;
60 
61 /*
62  * The *only* valid representation of an empty list is NIL; in other
63  * words, a non-NIL list is guaranteed to have length >= 1.
64  */
65 #define NIL ((List *) NULL)
66 
67 /*
68  * State structs for various looping macros below.
69  */
70 typedef struct ForEachState
71 {
72  const List *l; /* list we're looping through */
73  int i; /* current element index */
74 } ForEachState;
75 
76 typedef struct ForBothState
77 {
78  const List *l1; /* lists we're looping through */
79  const List *l2;
80  int i; /* common element index */
81 } ForBothState;
82 
83 typedef struct ForBothCellState
84 {
85  const List *l1; /* lists we're looping through */
86  const List *l2;
87  int i1; /* current element indexes */
88  int i2;
90 
91 typedef struct ForThreeState
92 {
93  const List *l1; /* lists we're looping through */
94  const List *l2;
95  const List *l3;
96  int i; /* common element index */
98 
99 typedef struct ForFourState
100 {
101  const List *l1; /* lists we're looping through */
102  const List *l2;
103  const List *l3;
104  const List *l4;
105  int i; /* common element index */
106 } ForFourState;
107 
108 typedef struct ForFiveState
109 {
110  const List *l1; /* lists we're looping through */
111  const List *l2;
112  const List *l3;
113  const List *l4;
114  const List *l5;
115  int i; /* common element index */
116 } ForFiveState;
117 
118 /*
119  * These routines are small enough, and used often enough, to justify being
120  * inline.
121  */
122 
123 /* Fetch address of list's first cell; NULL if empty list */
124 static inline ListCell *
125 list_head(const List *l)
126 {
127  return l ? &l->elements[0] : NULL;
128 }
129 
130 /* Fetch address of list's last cell; NULL if empty list */
131 static inline ListCell *
132 list_tail(const List *l)
133 {
134  return l ? &l->elements[l->length - 1] : NULL;
135 }
136 
137 /* Fetch address of list's second cell, if it has one, else NULL */
138 static inline ListCell *
140 {
141  if (l && l->length >= 2)
142  return &l->elements[1];
143  else
144  return NULL;
145 }
146 
147 /* Fetch list's length */
148 static inline int
149 list_length(const List *l)
150 {
151  return l ? l->length : 0;
152 }
153 
154 /*
155  * Macros to access the data values within List cells.
156  *
157  * Note that with the exception of the "xxx_node" macros, these are
158  * lvalues and can be assigned to.
159  *
160  * NB: There is an unfortunate legacy from a previous incarnation of
161  * the List API: the macro lfirst() was used to mean "the data in this
162  * cons cell". To avoid changing every usage of lfirst(), that meaning
163  * has been kept. As a result, lfirst() takes a ListCell and returns
164  * the data it contains; to get the data in the first cell of a
165  * List, use linitial(). Worse, lsecond() is more closely related to
166  * linitial() than lfirst(): given a List, lsecond() returns the data
167  * in the second list cell.
168  */
169 #define lfirst(lc) ((lc)->ptr_value)
170 #define lfirst_int(lc) ((lc)->int_value)
171 #define lfirst_oid(lc) ((lc)->oid_value)
172 #define lfirst_node(type,lc) castNode(type, lfirst(lc))
173 
174 #define linitial(l) lfirst(list_nth_cell(l, 0))
175 #define linitial_int(l) lfirst_int(list_nth_cell(l, 0))
176 #define linitial_oid(l) lfirst_oid(list_nth_cell(l, 0))
177 #define linitial_node(type,l) castNode(type, linitial(l))
178 
179 #define lsecond(l) lfirst(list_nth_cell(l, 1))
180 #define lsecond_int(l) lfirst_int(list_nth_cell(l, 1))
181 #define lsecond_oid(l) lfirst_oid(list_nth_cell(l, 1))
182 #define lsecond_node(type,l) castNode(type, lsecond(l))
183 
184 #define lthird(l) lfirst(list_nth_cell(l, 2))
185 #define lthird_int(l) lfirst_int(list_nth_cell(l, 2))
186 #define lthird_oid(l) lfirst_oid(list_nth_cell(l, 2))
187 #define lthird_node(type,l) castNode(type, lthird(l))
188 
189 #define lfourth(l) lfirst(list_nth_cell(l, 3))
190 #define lfourth_int(l) lfirst_int(list_nth_cell(l, 3))
191 #define lfourth_oid(l) lfirst_oid(list_nth_cell(l, 3))
192 #define lfourth_node(type,l) castNode(type, lfourth(l))
193 
194 #define llast(l) lfirst(list_last_cell(l))
195 #define llast_int(l) lfirst_int(list_last_cell(l))
196 #define llast_oid(l) lfirst_oid(list_last_cell(l))
197 #define llast_node(type,l) castNode(type, llast(l))
198 
199 /*
200  * Convenience macros for building fixed-length lists
201  */
202 #define list_make_ptr_cell(v) ((ListCell) {.ptr_value = (v)})
203 #define list_make_int_cell(v) ((ListCell) {.int_value = (v)})
204 #define list_make_oid_cell(v) ((ListCell) {.oid_value = (v)})
205 
206 #define list_make1(x1) \
207  list_make1_impl(T_List, list_make_ptr_cell(x1))
208 #define list_make2(x1,x2) \
209  list_make2_impl(T_List, list_make_ptr_cell(x1), list_make_ptr_cell(x2))
210 #define list_make3(x1,x2,x3) \
211  list_make3_impl(T_List, list_make_ptr_cell(x1), list_make_ptr_cell(x2), \
212  list_make_ptr_cell(x3))
213 #define list_make4(x1,x2,x3,x4) \
214  list_make4_impl(T_List, list_make_ptr_cell(x1), list_make_ptr_cell(x2), \
215  list_make_ptr_cell(x3), list_make_ptr_cell(x4))
216 
217 #define list_make1_int(x1) \
218  list_make1_impl(T_IntList, list_make_int_cell(x1))
219 #define list_make2_int(x1,x2) \
220  list_make2_impl(T_IntList, list_make_int_cell(x1), list_make_int_cell(x2))
221 #define list_make3_int(x1,x2,x3) \
222  list_make3_impl(T_IntList, list_make_int_cell(x1), list_make_int_cell(x2), \
223  list_make_int_cell(x3))
224 #define list_make4_int(x1,x2,x3,x4) \
225  list_make4_impl(T_IntList, list_make_int_cell(x1), list_make_int_cell(x2), \
226  list_make_int_cell(x3), list_make_int_cell(x4))
227 
228 #define list_make1_oid(x1) \
229  list_make1_impl(T_OidList, list_make_oid_cell(x1))
230 #define list_make2_oid(x1,x2) \
231  list_make2_impl(T_OidList, list_make_oid_cell(x1), list_make_oid_cell(x2))
232 #define list_make3_oid(x1,x2,x3) \
233  list_make3_impl(T_OidList, list_make_oid_cell(x1), list_make_oid_cell(x2), \
234  list_make_oid_cell(x3))
235 #define list_make4_oid(x1,x2,x3,x4) \
236  list_make4_impl(T_OidList, list_make_oid_cell(x1), list_make_oid_cell(x2), \
237  list_make_oid_cell(x3), list_make_oid_cell(x4))
238 
239 /*
240  * Locate the n'th cell (counting from 0) of the list.
241  * It is an assertion failure if there is no such cell.
242  */
243 static inline ListCell *
244 list_nth_cell(const List *list, int n)
245 {
246  Assert(list != NIL);
247  Assert(n >= 0 && n < list->length);
248  return &list->elements[n];
249 }
250 
251 /*
252  * Return the last cell in a non-NIL List.
253  */
254 static inline ListCell *
256 {
257  Assert(list != NIL);
258  return &list->elements[list->length - 1];
259 }
260 
261 /*
262  * Return the pointer value contained in the n'th element of the
263  * specified list. (List elements begin at 0.)
264  */
265 static inline void *
266 list_nth(const List *list, int n)
267 {
268  Assert(IsA(list, List));
269  return lfirst(list_nth_cell(list, n));
270 }
271 
272 /*
273  * Return the integer value contained in the n'th element of the
274  * specified list.
275  */
276 static inline int
277 list_nth_int(const List *list, int n)
278 {
279  Assert(IsA(list, IntList));
280  return lfirst_int(list_nth_cell(list, n));
281 }
282 
283 /*
284  * Return the OID value contained in the n'th element of the specified
285  * list.
286  */
287 static inline Oid
288 list_nth_oid(const List *list, int n)
289 {
290  Assert(IsA(list, OidList));
291  return lfirst_oid(list_nth_cell(list, n));
292 }
293 
294 #define list_nth_node(type,list,n) castNode(type, list_nth(list, n))
295 
296 /*
297  * Get the given ListCell's index (from 0) in the given List.
298  */
299 static inline int
300 list_cell_number(const List *l, const ListCell *c)
301 {
302  Assert(c >= &l->elements[0] && c < &l->elements[l->length]);
303  return c - l->elements;
304 }
305 
306 /*
307  * Get the address of the next cell after "c" within list "l", or NULL if none.
308  */
309 static inline ListCell *
310 lnext(const List *l, const ListCell *c)
311 {
312  Assert(c >= &l->elements[0] && c < &l->elements[l->length]);
313  c++;
314  if (c < &l->elements[l->length])
315  return (ListCell *) c;
316  else
317  return NULL;
318 }
319 
320 /*
321  * foreach -
322  * a convenience macro for looping through a list
323  *
324  * "cell" must be the name of a "ListCell *" variable; it's made to point
325  * to each List element in turn. "cell" will be NULL after normal exit from
326  * the loop, but an early "break" will leave it pointing at the current
327  * List element.
328  *
329  * Beware of changing the List object while the loop is iterating.
330  * The current semantics are that we examine successive list indices in
331  * each iteration, so that insertion or deletion of list elements could
332  * cause elements to be re-visited or skipped unexpectedly. Previous
333  * implementations of foreach() behaved differently. However, it's safe
334  * to append elements to the List (or in general, insert them after the
335  * current element); such new elements are guaranteed to be visited.
336  * Also, the current element of the List can be deleted, if you use
337  * foreach_delete_current() to do so. BUT: either of these actions will
338  * invalidate the "cell" pointer for the remainder of the current iteration.
339  */
340 #define foreach(cell, lst) \
341  for (ForEachState cell##__state = {(lst), 0}; \
342  (cell##__state.l != NIL && \
343  cell##__state.i < cell##__state.l->length) ? \
344  (cell = &cell##__state.l->elements[cell##__state.i], true) : \
345  (cell = NULL, false); \
346  cell##__state.i++)
347 
348 /*
349  * foreach_delete_current -
350  * delete the current list element from the List associated with a
351  * surrounding foreach() loop, returning the new List pointer.
352  *
353  * This is equivalent to list_delete_cell(), but it also adjusts the foreach
354  * loop's state so that no list elements will be missed. Do not delete
355  * elements from an active foreach loop's list in any other way!
356  */
357 #define foreach_delete_current(lst, cell) \
358  (cell##__state.i--, \
359  (List *) (cell##__state.l = list_delete_cell(lst, cell)))
360 
361 /*
362  * foreach_current_index -
363  * get the zero-based list index of a surrounding foreach() loop's
364  * current element; pass the name of the "ListCell *" iterator variable.
365  *
366  * Beware of using this after foreach_delete_current(); the value will be
367  * out of sync for the rest of the current loop iteration. Anyway, since
368  * you just deleted the current element, the value is pretty meaningless.
369  */
370 #define foreach_current_index(cell) (cell##__state.i)
371 
372 /*
373  * for_each_from -
374  * Like foreach(), but start from the N'th (zero-based) list element,
375  * not necessarily the first one.
376  *
377  * It's okay for N to exceed the list length, but not for it to be negative.
378  *
379  * The caveats for foreach() apply equally here.
380  */
381 #define for_each_from(cell, lst, N) \
382  for (ForEachState cell##__state = for_each_from_setup(lst, N); \
383  (cell##__state.l != NIL && \
384  cell##__state.i < cell##__state.l->length) ? \
385  (cell = &cell##__state.l->elements[cell##__state.i], true) : \
386  (cell = NULL, false); \
387  cell##__state.i++)
388 
389 static inline ForEachState
390 for_each_from_setup(const List *lst, int N)
391 {
392  ForEachState r = {lst, N};
393 
394  Assert(N >= 0);
395  return r;
396 }
397 
398 /*
399  * for_each_cell -
400  * a convenience macro which loops through a list starting from a
401  * specified cell
402  *
403  * The caveats for foreach() apply equally here.
404  */
405 #define for_each_cell(cell, lst, initcell) \
406  for (ForEachState cell##__state = for_each_cell_setup(lst, initcell); \
407  (cell##__state.l != NIL && \
408  cell##__state.i < cell##__state.l->length) ? \
409  (cell = &cell##__state.l->elements[cell##__state.i], true) : \
410  (cell = NULL, false); \
411  cell##__state.i++)
412 
413 static inline ForEachState
414 for_each_cell_setup(const List *lst, const ListCell *initcell)
415 {
416  ForEachState r = {lst,
417  initcell ? list_cell_number(lst, initcell) : list_length(lst)};
418 
419  return r;
420 }
421 
422 /*
423  * forboth -
424  * a convenience macro for advancing through two linked lists
425  * simultaneously. This macro loops through both lists at the same
426  * time, stopping when either list runs out of elements. Depending
427  * on the requirements of the call site, it may also be wise to
428  * assert that the lengths of the two lists are equal. (But, if they
429  * are not, some callers rely on the ending cell values being separately
430  * NULL or non-NULL as defined here; don't try to optimize that.)
431  *
432  * The caveats for foreach() apply equally here.
433  */
434 #define forboth(cell1, list1, cell2, list2) \
435  for (ForBothState cell1##__state = {(list1), (list2), 0}; \
436  multi_for_advance_cell(cell1, cell1##__state, l1, i), \
437  multi_for_advance_cell(cell2, cell1##__state, l2, i), \
438  (cell1 != NULL && cell2 != NULL); \
439  cell1##__state.i++)
440 
441 #define multi_for_advance_cell(cell, state, l, i) \
442  (cell = (state.l != NIL && state.i < state.l->length) ? \
443  &state.l->elements[state.i] : NULL)
444 
445 /*
446  * for_both_cell -
447  * a convenience macro which loops through two lists starting from the
448  * specified cells of each. This macro loops through both lists at the same
449  * time, stopping when either list runs out of elements. Depending on the
450  * requirements of the call site, it may also be wise to assert that the
451  * lengths of the two lists are equal, and initcell1 and initcell2 are at
452  * the same position in the respective lists.
453  *
454  * The caveats for foreach() apply equally here.
455  */
456 #define for_both_cell(cell1, list1, initcell1, cell2, list2, initcell2) \
457  for (ForBothCellState cell1##__state = \
458  for_both_cell_setup(list1, initcell1, list2, initcell2); \
459  multi_for_advance_cell(cell1, cell1##__state, l1, i1), \
460  multi_for_advance_cell(cell2, cell1##__state, l2, i2), \
461  (cell1 != NULL && cell2 != NULL); \
462  cell1##__state.i1++, cell1##__state.i2++)
463 
464 static inline ForBothCellState
465 for_both_cell_setup(const List *list1, const ListCell *initcell1,
466  const List *list2, const ListCell *initcell2)
467 {
468  ForBothCellState r = {list1, list2,
469  initcell1 ? list_cell_number(list1, initcell1) : list_length(list1),
470  initcell2 ? list_cell_number(list2, initcell2) : list_length(list2)};
471 
472  return r;
473 }
474 
475 /*
476  * forthree -
477  * the same for three lists
478  */
479 #define forthree(cell1, list1, cell2, list2, cell3, list3) \
480  for (ForThreeState cell1##__state = {(list1), (list2), (list3), 0}; \
481  multi_for_advance_cell(cell1, cell1##__state, l1, i), \
482  multi_for_advance_cell(cell2, cell1##__state, l2, i), \
483  multi_for_advance_cell(cell3, cell1##__state, l3, i), \
484  (cell1 != NULL && cell2 != NULL && cell3 != NULL); \
485  cell1##__state.i++)
486 
487 /*
488  * forfour -
489  * the same for four lists
490  */
491 #define forfour(cell1, list1, cell2, list2, cell3, list3, cell4, list4) \
492  for (ForFourState cell1##__state = {(list1), (list2), (list3), (list4), 0}; \
493  multi_for_advance_cell(cell1, cell1##__state, l1, i), \
494  multi_for_advance_cell(cell2, cell1##__state, l2, i), \
495  multi_for_advance_cell(cell3, cell1##__state, l3, i), \
496  multi_for_advance_cell(cell4, cell1##__state, l4, i), \
497  (cell1 != NULL && cell2 != NULL && cell3 != NULL && cell4 != NULL); \
498  cell1##__state.i++)
499 
500 /*
501  * forfive -
502  * the same for five lists
503  */
504 #define forfive(cell1, list1, cell2, list2, cell3, list3, cell4, list4, cell5, list5) \
505  for (ForFiveState cell1##__state = {(list1), (list2), (list3), (list4), (list5), 0}; \
506  multi_for_advance_cell(cell1, cell1##__state, l1, i), \
507  multi_for_advance_cell(cell2, cell1##__state, l2, i), \
508  multi_for_advance_cell(cell3, cell1##__state, l3, i), \
509  multi_for_advance_cell(cell4, cell1##__state, l4, i), \
510  multi_for_advance_cell(cell5, cell1##__state, l5, i), \
511  (cell1 != NULL && cell2 != NULL && cell3 != NULL && \
512  cell4 != NULL && cell5 != NULL); \
513  cell1##__state.i++)
514 
515 /* Functions in src/backend/nodes/list.c */
516 
517 extern List *list_make1_impl(NodeTag t, ListCell datum1);
518 extern List *list_make2_impl(NodeTag t, ListCell datum1, ListCell datum2);
519 extern List *list_make3_impl(NodeTag t, ListCell datum1, ListCell datum2,
520  ListCell datum3);
521 extern List *list_make4_impl(NodeTag t, ListCell datum1, ListCell datum2,
522  ListCell datum3, ListCell datum4);
523 
524 extern List *lappend(List *list, void *datum);
525 extern List *lappend_int(List *list, int datum);
526 extern List *lappend_oid(List *list, Oid datum);
527 
528 extern List *list_insert_nth(List *list, int pos, void *datum);
529 extern List *list_insert_nth_int(List *list, int pos, int datum);
530 extern List *list_insert_nth_oid(List *list, int pos, Oid datum);
531 
532 extern List *lcons(void *datum, List *list);
533 extern List *lcons_int(int datum, List *list);
534 extern List *lcons_oid(Oid datum, List *list);
535 
536 extern List *list_concat(List *list1, const List *list2);
537 extern List *list_concat_copy(const List *list1, const List *list2);
538 
539 extern List *list_truncate(List *list, int new_size);
540 
541 extern bool list_member(const List *list, const void *datum);
542 extern bool list_member_ptr(const List *list, const void *datum);
543 extern bool list_member_int(const List *list, int datum);
544 extern bool list_member_oid(const List *list, Oid datum);
545 
546 extern List *list_delete(List *list, void *datum);
547 extern List *list_delete_ptr(List *list, void *datum);
548 extern List *list_delete_int(List *list, int datum);
549 extern List *list_delete_oid(List *list, Oid datum);
550 extern List *list_delete_first(List *list);
551 extern List *list_delete_last(List *list);
552 extern List *list_delete_nth_cell(List *list, int n);
553 extern List *list_delete_cell(List *list, ListCell *cell);
554 
555 extern List *list_union(const List *list1, const List *list2);
556 extern List *list_union_ptr(const List *list1, const List *list2);
557 extern List *list_union_int(const List *list1, const List *list2);
558 extern List *list_union_oid(const List *list1, const List *list2);
559 
560 extern List *list_intersection(const List *list1, const List *list2);
561 extern List *list_intersection_int(const List *list1, const List *list2);
562 
563 /* currently, there's no need for list_intersection_ptr etc */
564 
565 extern List *list_difference(const List *list1, const List *list2);
566 extern List *list_difference_ptr(const List *list1, const List *list2);
567 extern List *list_difference_int(const List *list1, const List *list2);
568 extern List *list_difference_oid(const List *list1, const List *list2);
569 
570 extern List *list_append_unique(List *list, void *datum);
571 extern List *list_append_unique_ptr(List *list, void *datum);
572 extern List *list_append_unique_int(List *list, int datum);
573 extern List *list_append_unique_oid(List *list, Oid datum);
574 
575 extern List *list_concat_unique(List *list1, const List *list2);
576 extern List *list_concat_unique_ptr(List *list1, const List *list2);
577 extern List *list_concat_unique_int(List *list1, const List *list2);
578 extern List *list_concat_unique_oid(List *list1, const List *list2);
579 
580 extern void list_deduplicate_oid(List *list);
581 
582 extern void list_free(List *list);
583 extern void list_free_deep(List *list);
584 
585 extern List *list_copy(const List *list);
586 extern List *list_copy_tail(const List *list, int nskip);
587 extern List *list_copy_deep(const List *oldlist);
588 
589 typedef int (*list_sort_comparator) (const ListCell *a, const ListCell *b);
591 
592 extern int list_oid_cmp(const ListCell *p1, const ListCell *p2);
593 
594 #endif /* PG_LIST_H */
bool list_member_int(const List *list, int datum)
Definition: list.c:654
#define NIL
Definition: pg_list.h:65
static int list_cell_number(const List *l, const ListCell *c)
Definition: pg_list.h:300
List * list_concat_unique_int(List *list1, const List *list2)
Definition: list.c:1280
#define IsA(nodeptr, _type_)
Definition: nodes.h:579
List * list_insert_nth_oid(List *list, int pos, Oid datum)
Definition: list.c:428
static ListCell * lnext(const List *l, const ListCell *c)
Definition: pg_list.h:310
static ListCell * list_nth_cell(const List *list, int n)
Definition: pg_list.h:244
const List * l2
Definition: pg_list.h:102
List * list_difference_ptr(const List *list1, const List *list2)
Definition: list.c:1102
List * list_make4_impl(NodeTag t, ListCell datum1, ListCell datum2, ListCell datum3, ListCell datum4)
Definition: list.c:267
List * list_union(const List *list1, const List *list2)
Definition: list.c:915
List * list_make3_impl(NodeTag t, ListCell datum1, ListCell datum2, ListCell datum3)
Definition: list.c:254
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:284
List * lcons_oid(Oid datum, List *list)
Definition: list.c:489
const List * l2
Definition: pg_list.h:86
const List * l1
Definition: pg_list.h:85
List * list_truncate(List *list, int new_size)
Definition: list.c:585
unsigned int Oid
Definition: postgres_ext.h:31
List * list_delete_first(List *list)
Definition: list.c:860
NodeTag
Definition: nodes.h:26
static ListCell * list_last_cell(const List *list)
Definition: pg_list.h:255
void list_deduplicate_oid(List *list)
Definition: list.c:1325
const List * l3
Definition: pg_list.h:103
List * lappend(List *list, void *datum)
Definition: list.c:321
static int list_nth_int(const List *list, int n)
Definition: pg_list.h:277
List * list_copy(const List *list)
Definition: list.c:1403
List * list_union_ptr(const List *list1, const List *list2)
Definition: list.c:939
List * list_union_oid(const List *list1, const List *list2)
Definition: list.c:985
static Oid list_nth_oid(const List *list, int n)
Definition: pg_list.h:288
int int_value
Definition: pg_list.h:46
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
List * list_delete_int(List *list, int datum)
Definition: list.c:815
List * list_delete_cell(List *list, ListCell *cell)
Definition: list.c:767
List * lcons(void *datum, List *list)
Definition: list.c:453
static ForBothCellState for_both_cell_setup(const List *list1, const ListCell *initcell1, const List *list2, const ListCell *initcell2)
Definition: pg_list.h:465
#define lfirst_int(lc)
Definition: pg_list.h:170
void list_free(List *list)
Definition: list.c:1376
static void * list_nth(const List *list, int n)
Definition: pg_list.h:266
const List * l3
Definition: pg_list.h:112
List * list_union_int(const List *list1, const List *list2)
Definition: list.c:962
List * list_concat_unique_ptr(List *list1, const List *list2)
Definition: list.c:1259
static ForEachState for_each_cell_setup(const List *lst, const ListCell *initcell)
Definition: pg_list.h:414
char * c
static ListCell * list_second_cell(const List *l)
Definition: pg_list.h:139
void list_free_deep(List *list)
Definition: list.c:1390
const List * l4
Definition: pg_list.h:104
struct ForFiveState ForFiveState
List * list_intersection_int(const List *list1, const List *list2)
Definition: list.c:1044
const List * l2
Definition: pg_list.h:79
static ListCell * list_head(const List *l)
Definition: pg_list.h:125
struct ForThreeState ForThreeState
const List * l3
Definition: pg_list.h:95
const List * l4
Definition: pg_list.h:113
List * list_make2_impl(NodeTag t, ListCell datum1, ListCell datum2)
Definition: list.c:243
const List * l2
Definition: pg_list.h:111
List * list_difference(const List *list1, const List *list2)
Definition: list.c:1076
List * list_append_unique_int(List *list, int datum)
Definition: list.c:1205
List * list_delete_nth_cell(List *list, int n)
Definition: list.c:696
List * lappend_oid(List *list, Oid datum)
Definition: list.c:357
const List * l1
Definition: pg_list.h:78
List * list_delete(List *list, void *datum)
Definition: list.c:777
List * list_delete_oid(List *list, Oid datum)
Definition: list.c:834
union ListCell ListCell
bool list_member(const List *list, const void *datum)
Definition: list.c:613
int(* list_sort_comparator)(const ListCell *a, const ListCell *b)
Definition: pg_list.h:589
const List * l1
Definition: pg_list.h:110
int max_length
Definition: pg_list.h:54
List * list_delete_ptr(List *list, void *datum)
Definition: list.c:796
ListCell * elements
Definition: pg_list.h:55
int list_oid_cmp(const ListCell *p1, const ListCell *p2)
Definition: list.c:1498
List * list_copy_tail(const List *list, int nskip)
Definition: list.c:1422
List * list_concat_unique_oid(List *list1, const List *list2)
Definition: list.c:1301
List * list_make1_impl(NodeTag t, ListCell datum1)
Definition: list.c:233
#define Assert(condition)
Definition: c.h:746
#define lfirst(lc)
Definition: pg_list.h:169
List * list_copy_deep(const List *oldlist)
Definition: list.c:1448
bool list_member_ptr(const List *list, const void *datum)
Definition: list.c:634
List * lappend_int(List *list, int datum)
Definition: list.c:339
const List * l2
Definition: pg_list.h:94
const List * l5
Definition: pg_list.h:114
static int list_length(const List *l)
Definition: pg_list.h:149
struct ForFourState ForFourState
List * list_append_unique_oid(List *list, Oid datum)
Definition: list.c:1217
List * list_insert_nth_int(List *list, int pos, int datum)
Definition: list.c:414
int length
Definition: pg_list.h:53
void * ptr_value
Definition: pg_list.h:45
List * list_difference_int(const List *list1, const List *list2)
Definition: list.c:1127
Oid oid_value
Definition: pg_list.h:47
const List * l1
Definition: pg_list.h:101
List * list_concat_unique(List *list1, const List *list2)
Definition: list.c:1237
List * list_concat_copy(const List *list1, const List *list2)
Definition: list.c:552
NodeTag type
Definition: pg_list.h:52
List * list_append_unique_ptr(List *list, void *datum)
Definition: list.c:1193
struct ForBothState ForBothState
struct ForEachState ForEachState
List * list_delete_last(List *list)
Definition: list.c:877
static ListCell * list_tail(const List *l)
Definition: pg_list.h:132
struct List List
const List * l1
Definition: pg_list.h:93
struct ForBothCellState ForBothCellState
void list_sort(List *list, list_sort_comparator cmp)
Definition: list.c:1481
List * list_intersection(const List *list1, const List *list2)
Definition: list.c:1018
Definition: pg_list.h:50
List * lcons_int(int datum, List *list)
Definition: list.c:471
const List * l
Definition: pg_list.h:72
#define lfirst_oid(lc)
Definition: pg_list.h:171
List * list_concat(List *list1, const List *list2)
Definition: list.c:515
static int cmp(const chr *x, const chr *y, size_t len)
Definition: regc_locale.c:742
List * list_difference_oid(const List *list1, const List *list2)
Definition: list.c:1152
List * list_insert_nth(List *list, int pos, void *datum)
Definition: list.c:400
static ForEachState for_each_from_setup(const List *lst, int N)
Definition: pg_list.h:390
List * list_append_unique(List *list, void *datum)
Definition: list.c:1180