PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
list.c File Reference
#include "postgres.h"
#include "nodes/pg_list.h"
Include dependency graph for list.c:

Go to the source code of this file.

Macros

#define IsPointerList(l)   ((l) == NIL || IsA((l), List))
 
#define IsIntegerList(l)   ((l) == NIL || IsA((l), IntList))
 
#define IsOidList(l)   ((l) == NIL || IsA((l), OidList))
 
#define check_list_invariants(l)
 

Functions

static Listnew_list (NodeTag type)
 
static void new_head_cell (List *list)
 
static void new_tail_cell (List *list)
 
Listlappend (List *list, void *datum)
 
Listlappend_int (List *list, int datum)
 
Listlappend_oid (List *list, Oid datum)
 
static ListCelladd_new_cell (List *list, ListCell *prev_cell)
 
ListCelllappend_cell (List *list, ListCell *prev, void *datum)
 
ListCelllappend_cell_int (List *list, ListCell *prev, int datum)
 
ListCelllappend_cell_oid (List *list, ListCell *prev, Oid datum)
 
Listlcons (void *datum, List *list)
 
Listlcons_int (int datum, List *list)
 
Listlcons_oid (Oid datum, List *list)
 
Listlist_concat (List *list1, List *list2)
 
Listlist_truncate (List *list, int new_size)
 
ListCelllist_nth_cell (const List *list, int n)
 
void * list_nth (const List *list, int n)
 
int list_nth_int (const List *list, int n)
 
Oid list_nth_oid (const List *list, int n)
 
bool list_member (const List *list, const void *datum)
 
bool list_member_ptr (const List *list, const void *datum)
 
bool list_member_int (const List *list, int datum)
 
bool list_member_oid (const List *list, Oid datum)
 
Listlist_delete_cell (List *list, ListCell *cell, ListCell *prev)
 
Listlist_delete (List *list, void *datum)
 
Listlist_delete_ptr (List *list, void *datum)
 
Listlist_delete_int (List *list, int datum)
 
Listlist_delete_oid (List *list, Oid datum)
 
Listlist_delete_first (List *list)
 
Listlist_union (const List *list1, const List *list2)
 
Listlist_union_ptr (const List *list1, const List *list2)
 
Listlist_union_int (const List *list1, const List *list2)
 
Listlist_union_oid (const List *list1, const List *list2)
 
Listlist_intersection (const List *list1, const List *list2)
 
Listlist_intersection_int (const List *list1, const List *list2)
 
Listlist_difference (const List *list1, const List *list2)
 
Listlist_difference_ptr (const List *list1, const List *list2)
 
Listlist_difference_int (const List *list1, const List *list2)
 
Listlist_difference_oid (const List *list1, const List *list2)
 
Listlist_append_unique (List *list, void *datum)
 
Listlist_append_unique_ptr (List *list, void *datum)
 
Listlist_append_unique_int (List *list, int datum)
 
Listlist_append_unique_oid (List *list, Oid datum)
 
Listlist_concat_unique (List *list1, List *list2)
 
Listlist_concat_unique_ptr (List *list1, List *list2)
 
Listlist_concat_unique_int (List *list1, List *list2)
 
Listlist_concat_unique_oid (List *list1, List *list2)
 
static void list_free_private (List *list, bool deep)
 
void list_free (List *list)
 
void list_free_deep (List *list)
 
Listlist_copy (const List *oldlist)
 
Listlist_copy_tail (const List *oldlist, int nskip)
 
int length (const List *list)
 

Macro Definition Documentation

#define IsIntegerList (   l)    ((l) == NIL || IsA((l), IntList))
#define IsOidList (   l)    ((l) == NIL || IsA((l), OidList))

Function Documentation

static ListCell* add_new_cell ( List list,
ListCell prev_cell 
)
static

Definition at line 185 of file list.c.

References List::length, ListCell::next, palloc(), and List::tail.

Referenced by lappend_cell(), lappend_cell_int(), and lappend_cell_oid().

186 {
187  ListCell *new_cell;
188 
189  new_cell = (ListCell *) palloc(sizeof(*new_cell));
190  /* new_cell->data is left undefined! */
191  new_cell->next = prev_cell->next;
192  prev_cell->next = new_cell;
193 
194  if (list->tail == prev_cell)
195  list->tail = new_cell;
196 
197  list->length++;
198 
199  return new_cell;
200 }
ListCell * next
Definition: pg_list.h:61
int length
Definition: pg_list.h:48
void * palloc(Size size)
Definition: mcxt.c:849
ListCell * tail
Definition: pg_list.h:50
List* lappend ( List list,
void *  datum 
)

Definition at line 128 of file list.c.

References Assert, check_list_invariants, IsPointerList, lfirst, sort-test::list, new_list(), new_tail_cell(), NIL, T_List, and List::tail.

Referenced by _SPI_make_plan_non_temp(), _SPI_prepare_oneshot_plan(), _SPI_prepare_plan(), _SPI_save_plan(), accumulate_append_subpath(), AcquireRewriteLocks(), add_column_to_pathtarget(), add_dummy_return(), add_eq_member(), add_join_clause_to_rels(), add_join_rel(), add_paths_to_append_rel(), add_placeholders_to_base_rels(), add_placeholders_to_joinrel(), add_rte_to_flat_rtable(), add_security_quals(), add_to_flat_tlist(), add_unique_group_var(), add_vars_to_targetlist(), add_with_check_options(), addArc(), addFamilyMember(), addKey(), addKeyToQueue(), addRangeTableEntry(), addRangeTableEntryForCTE(), addRangeTableEntryForENR(), addRangeTableEntryForFunction(), addRangeTableEntryForJoin(), addRangeTableEntryForRelation(), addRangeTableEntryForSubquery(), addRangeTableEntryForTableFunc(), addRangeTableEntryForValues(), AddRelationNewConstraints(), addRTEtoQuery(), addTargetToGroupList(), addTargetToSortList(), adjust_inherited_tlist(), AlterPublicationTables(), AlterTableMoveAll(), AlterTSDictionary(), analyzeCTETargetList(), applyLockingClause(), ApplyRetrieveRule(), assign_param_for_placeholdervar(), assign_param_for_var(), Async_Notify(), ATAddCheckConstraint(), ATAddForeignKeyConstraint(), ATExecAddColumn(), ATExecAlterColumnType(), ATExecAttachPartition(), ATGetQueueEntry(), ATPostAlterTypeParse(), ATPrepAlterColumnType(), ATPrepCmd(), btcostestimate(), build_aggregate_finalfn_expr(), build_aggregate_transfn_expr(), build_coercion_expression(), build_empty_join_rel(), build_index_pathkeys(), build_index_paths(), build_index_tlist(), build_join_rel(), build_joinrel_tlist(), build_path_tlist(), build_physical_tlist(), build_subplan(), BuildEventTriggerCache(), buildRelationAliases(), cached_scansel(), calc_joinrel_size_estimate(), check_index_predicates(), check_selective_binary_conversion(), check_sql_fn_retval(), checkInsertTargets(), checkSharedDependencies(), checkWellFormedRecursionWalker(), choose_bitmap_and(), ChooseIndexColumnNames(), classifyConditions(), coerce_record_to_complex(), compute_common_attribute(), compute_semi_anti_join_factors(), compute_semijoin_info(), ComputeIndexAttrs(), ComputePartitionAttrs(), consider_groupingsets_paths(), consider_new_or_clause(), convert_ANY_sublink_to_join(), convert_EXISTS_to_ANY(), convert_subquery_pathkeys(), ConvertTriggerToFK(), create_append_plan(), create_bitmap_scan_plan(), create_bitmap_subplan(), create_ctas_nodata(), create_customscan_plan(), create_grouping_paths(), create_groupingsets_plan(), create_index_paths(), create_indexscan_plan(), create_join_clause(), create_merge_append_plan(), create_modifytable_plan(), create_nestloop_path(), create_nestloop_plan(), create_unique_plan(), database_to_xmlschema_internal(), deconstruct_indexquals(), deconstruct_recurse(), DefineRelation(), DefineSequence(), DefineTSDictionary(), DefineView(), DefineVirtualRelation(), deparseParam(), deparseVar(), deserialize_deflist(), determineRecursiveColTypes(), distribute_qual_to_rels(), distribute_restrictinfo_to_rels(), do_pg_start_backup(), DoCopy(), estimate_multivariate_ndistinct(), eval_const_expressions_mutator(), EvalPlanQualStart(), EventTriggerAlterTableEnd(), EventTriggerCollectAlterDefPrivs(), EventTriggerCollectAlterOpFam(), EventTriggerCollectAlterTableSubcmd(), EventTriggerCollectAlterTSConfig(), EventTriggerCollectCreateOpClass(), EventTriggerCollectGrant(), EventTriggerCollectSimpleCommand(), Exec_ListenCommit(), ExecAllocTableSlot(), ExecEvalXmlExpr(), ExecGetTriggerResultRel(), ExecInitAgg(), ExecInitAlternativeSubPlan(), ExecInitExprList(), ExecInitExprRec(), ExecInitHashJoin(), ExecInitLockRows(), ExecInitModifyTable(), ExecInitNode(), ExecInitSubPlan(), ExecPrepareExprList(), ExecSerializePlan(), ExecuteGrantStmt(), ExecuteTruncate(), expand_grouping_sets(), expand_groupingset_node(), expand_indexqual_conditions(), expand_inherited_rtentry(), expand_targetlist(), expandRelAttrs(), ExpandRowReference(), expandRTE(), expandTupleDesc(), ExplainNode(), ExportSnapshot(), expression_tree_mutator(), extract_actual_clauses(), extract_actual_join_clauses(), extract_lateral_references(), extract_nonindex_conditions(), extract_or_clause(), extract_rollup_sets(), extractRemainingColumns(), fetch_statentries_for_relation(), fetch_table_list(), fetch_upper_rel(), file_fdw_validator(), fill_hba_line(), find_duplicate_ors(), find_hash_columns(), find_list_position(), find_mergeclauses_for_pathkeys(), find_minmax_aggs_walker(), find_placeholder_info(), find_window_functions_walker(), findTargetlistEntrySQL99(), fireRIRrules(), fireRules(), fix_indexorderby_references(), fix_indexqual_references(), flatten_grouping_sets(), flatten_join_alias_vars_mutator(), flatten_join_using_qual(), flatten_simple_union_all(), foreign_grouping_ok(), foreign_join_ok(), format_operator_parts(), format_procedure_parts(), func_get_detail(), generate_append_tlist(), generate_bitmap_or_paths(), generate_implied_equalities_for_column(), generate_join_implied_equalities_broken(), generate_join_implied_equalities_normal(), generate_setop_tlist(), generate_subquery_params(), generate_subquery_vars(), generateClonedIndexStmt(), generateSerialExtraStmts(), get_actual_clauses(), get_appendrel_parampathinfo(), get_baserel_parampathinfo(), get_column_info_for_window(), get_database_list(), get_eclass_for_sort_expr(), get_ext_ver_info(), get_ext_ver_list(), get_file_fdw_attribute_options(), get_foreign_key_join_selectivity(), get_func_expr(), get_index_paths(), get_insert_query_def(), get_join_index_paths(), get_joinrel_parampathinfo(), get_op_btree_interpretation(), get_policies_for_relation(), get_qual_for_list(), get_qual_for_range(), get_relation_constraints(), get_relation_foreign_keys(), get_required_extension(), get_sortgrouplist_exprs(), get_subscription_list(), get_switched_clauses(), get_tlist_exprs(), get_update_query_targetlist_def(), get_useful_ecs_for_relation(), get_useful_pathkeys_for_relation(), get_windowfunc_expr(), getObjectIdentityParts(), getState(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), gistFindPath(), gistfixsplit(), gistplacetopage(), hash_inner_and_outer(), heap_truncate(), identify_opfamily_groups(), index_check_primary_key(), infer_arbiter_indexes(), inheritance_planner(), init_execution_state(), init_sql_fcache(), InitPlan(), innerrel_is_unique(), interpret_function_parameter_list(), intorel_startup(), is_innerrel_unique_for(), join_is_removable(), list_append_unique(), list_append_unique_ptr(), list_concat_unique(), list_concat_unique_ptr(), list_difference(), list_difference_ptr(), list_intersection(), list_union(), list_union_ptr(), load_hba(), load_ident(), LoadPublications(), make_canonical_pathkey(), make_copy_attnamelist(), make_group_input_target(), make_inh_translation_list(), make_inner_pathkeys_for_merge(), make_modifytable(), make_partial_grouping_target(), make_pathkeys_for_sortclauses(), make_pathtarget_from_tlist(), make_rel_from_joinlist(), make_row_comparison_op(), make_setop_translation_list(), make_sort_input_target(), make_sub_restrictinfos(), make_tlist_from_pathtarget(), make_window_input_target(), makeDependencyGraphWalker(), match_foreign_keys_to_quals(), match_join_clauses_to_index(), match_pathkeys_to_index(), matchLocks(), merge_clump(), MergeAttributes(), negate_clause(), network_prefix_quals(), next_field_expand(), nodeRead(), OpenTableList(), order_qual_clauses(), parse_hba_line(), parseCheckAggregates(), ParseFuncOrColumn(), perform_base_backup(), pg_get_object_address(), pg_logical_slot_get_changes_guts(), pg_plan_queries(), postgresAddForeignUpdateTargets(), postgresGetForeignPaths(), postgresGetForeignPlan(), postgresImportForeignSchema(), prefix_quals(), prep_domain_constraints(), prepare_sort_from_pathkeys(), preprocess_groupclause(), preprocess_grouping_sets(), preprocess_rowmarks(), preprocess_targetlist(), process_duplicate_ors(), process_equivalence(), process_pipe_input(), process_sublinks_mutator(), process_subquery_nestloop_params(), process_syncing_tables_for_apply(), ProcessStartupPacket(), pull_ands(), pull_ors(), pull_up_simple_values(), pull_up_sublinks_jointree_recurse(), pull_up_sublinks_qual_recurse(), pull_up_subqueries_cleanup(), pull_up_union_leaf_queries(), pull_var_clause_walker(), pull_vars_walker(), push_ancestor_plan(), QueryRewrite(), queue_listen(), range_table_mutator(), read_tablespace_map(), RebuildConstraintComment(), record_plan_function_dependency(), reduce_outer_joins_pass1(), register_ENR(), register_label_provider(), relation_excluded_by_constraints(), relation_has_unique_index_for(), RelationBuildPartitionDesc(), RelationCacheInvalidate(), RelationGetFKeyList(), RelationGetPartitionDispatchInfo(), remap_to_groupclause_idx(), RememberFsyncRequest(), remove_rel_from_joinlist(), remove_useless_groupby_columns(), RemoveInheritance(), reorder_function_arguments(), replace_nestloop_params_mutator(), replace_outer_agg(), replace_outer_grouping(), resetSpGistScanOpaque(), resolve_unique_index_expr(), RewriteQuery(), rewriteTargetListIU(), rewriteTargetListUD(), rewriteTargetView(), rewriteValuesRTE(), schema_to_xmlschema_internal(), SearchCatCacheList(), select_active_windows(), select_mergejoin_clauses(), select_outer_pathkeys_for_merge(), sepgsql_set_client_label(), sequence_options(), set_append_rel_pathlist(), set_append_rel_size(), set_cheapest(), set_deparse_for_query(), set_dummy_tlist_references(), set_plan_references(), set_plan_refs(), set_rtable_names(), set_simple_column_names(), set_subquery_pathlist(), set_upper_references(), set_using_names(), show_grouping_set_keys(), show_modifytable_info(), show_plan_tlist(), show_sort_group_keys(), show_tablesample(), simplify_and_arguments(), simplify_or_arguments(), sort_policies_by_name(), split_pathtarget_at_srfs(), split_pathtarget_walker(), SplitDirectoriesString(), SplitIdentifierString(), SS_make_initplan_from_plan(), SS_process_ctes(), StandbyAcquireAccessExclusiveLock(), stringToQualifiedNameList(), subquery_planner(), textarray_to_stringlist(), textarray_to_strvaluelist(), textToQualifiedNameList(), TidExprListCreate(), tokenize_file(), tokenize_inc_file(), transformAExprIn(), transformAggregateCall(), transformAlterTableStmt(), transformArrayExpr(), transformArraySubscripts(), transformAssignmentIndirection(), transformBoolExpr(), transformCaseExpr(), transformCoalesceExpr(), transformColumnDefinition(), transformCreateSchemaStmt(), transformCreateStmt(), transformDistinctClause(), transformDistinctOnClause(), transformExpressionList(), transformFKConstraints(), transformFkeyGetPrimaryKey(), transformFromClause(), transformFromClauseItem(), transformFuncCall(), transformGenericOptions(), transformGroupClause(), transformGroupClauseExpr(), transformGroupingFunc(), transformGroupingSet(), transformIndexConstraint(), transformIndexConstraints(), transformIndirection(), transformInsertRow(), transformInsertStmt(), transformJoinUsingClause(), transformMinMaxExpr(), transformMultiAssignRef(), transformOfType(), transformOnConflictClause(), transformPartitionBound(), transformPartitionSpec(), transformRangeFunction(), transformRangeTableFunc(), transformRangeTableSample(), transformRowExpr(), transformRuleStmt(), transformSetOperationStmt(), transformSetOperationTree(), transformSubLink(), transformTableConstraint(), transformTableLikeClause(), transformTargetList(), transformValuesClause(), transformWindowDefinitions(), transformWindowFuncCall(), transformWithClause(), transformXmlExpr(), untransformRelOptions(), UpdateLogicalMappings(), WaitForLockersMultiple(), and xmlelement().

129 {
130  Assert(IsPointerList(list));
131 
132  if (list == NIL)
133  list = new_list(T_List);
134  else
135  new_tail_cell(list);
136 
137  lfirst(list->tail) = datum;
138  check_list_invariants(list);
139  return list;
140 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
static void new_tail_cell(List *list)
Definition: list.c:108
#define IsPointerList(l)
Definition: list.c:25
Definition: nodes.h:291
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
tuple list
Definition: sort-test.py:11
ListCell * tail
Definition: pg_list.h:50
ListCell* lappend_cell ( List list,
ListCell prev,
void *  datum 
)

Definition at line 209 of file list.c.

References add_new_cell(), Assert, check_list_invariants, IsPointerList, and lfirst.

Referenced by add_partial_path(), add_path(), and merge_clump().

210 {
211  ListCell *new_cell;
212 
213  Assert(IsPointerList(list));
214 
215  new_cell = add_new_cell(list, prev);
216  lfirst(new_cell) = datum;
217  check_list_invariants(list);
218  return new_cell;
219 }
static ListCell * add_new_cell(List *list, ListCell *prev_cell)
Definition: list.c:185
#define check_list_invariants(l)
Definition: list.c:54
#define IsPointerList(l)
Definition: list.c:25
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
ListCell* lappend_cell_int ( List list,
ListCell prev,
int  datum 
)

Definition at line 222 of file list.c.

References add_new_cell(), Assert, check_list_invariants, IsIntegerList, and lfirst_int.

223 {
224  ListCell *new_cell;
225 
226  Assert(IsIntegerList(list));
227 
228  new_cell = add_new_cell(list, prev);
229  lfirst_int(new_cell) = datum;
230  check_list_invariants(list);
231  return new_cell;
232 }
static ListCell * add_new_cell(List *list, ListCell *prev_cell)
Definition: list.c:185
#define check_list_invariants(l)
Definition: list.c:54
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
#define Assert(condition)
Definition: c.h:675
ListCell* lappend_cell_oid ( List list,
ListCell prev,
Oid  datum 
)

Definition at line 235 of file list.c.

References add_new_cell(), Assert, check_list_invariants, IsOidList, and lfirst_oid.

Referenced by insert_ordered_oid(), and insert_ordered_unique_oid().

236 {
237  ListCell *new_cell;
238 
239  Assert(IsOidList(list));
240 
241  new_cell = add_new_cell(list, prev);
242  lfirst_oid(new_cell) = datum;
243  check_list_invariants(list);
244  return new_cell;
245 }
static ListCell * add_new_cell(List *list, ListCell *prev_cell)
Definition: list.c:185
#define check_list_invariants(l)
Definition: list.c:54
#define IsOidList(l)
Definition: list.c:27
#define Assert(condition)
Definition: c.h:675
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* lappend_int ( List list,
int  datum 
)

Definition at line 146 of file list.c.

References Assert, check_list_invariants, IsIntegerList, lfirst_int, sort-test::list, new_list(), new_tail_cell(), NIL, T_IntList, and List::tail.

Referenced by addRangeTableEntryForENR(), addRangeTableEntryForFunction(), adjust_rowcompare_for_index(), analyzeCTETargetList(), ATRewriteTable(), build_index_paths(), build_subplan(), check_ungrouped_columns_walker(), checkInsertTargets(), convert_EXISTS_to_ANY(), CopyGetAttnums(), deparseAnalyzeSql(), deparseExplicitTargetList(), deparseTargetList(), ExecInitArrayRef(), ExecInitExprRec(), ExecInitQual(), expand_indexqual_conditions(), expand_inherited_rtentry(), fetch_statentries_for_relation(), finalize_grouping_exprs_walker(), find_all_inheritors(), find_compatible_peragg(), fix_expr_common(), generate_subquery_params(), inheritance_planner(), list_append_unique_int(), list_concat_unique_int(), list_difference_int(), list_intersection_int(), list_union_int(), match_pathkeys_to_index(), nodeRead(), postgresPlanDirectModify(), postgresPlanForeignModify(), rel_is_distinct_for(), remap_to_groupclause_idx(), reorder_grouping_sets(), rewriteTargetListIU(), set_plan_refs(), split_pathtarget_at_srfs(), SS_process_ctes(), SyncRepGetSyncStandbysPriority(), SyncRepGetSyncStandbysQuorum(), transformDistinctOnClause(), transformGroupClauseList(), transformRangeTableFunc(), transformSetOperationTree(), transformValuesClause(), and translate_sub_tlist().

147 {
148  Assert(IsIntegerList(list));
149 
150  if (list == NIL)
151  list = new_list(T_IntList);
152  else
153  new_tail_cell(list);
154 
155  lfirst_int(list->tail) = datum;
156  check_list_invariants(list);
157  return list;
158 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
static void new_tail_cell(List *list)
Definition: list.c:108
#define Assert(condition)
Definition: c.h:675
tuple list
Definition: sort-test.py:11
ListCell * tail
Definition: pg_list.h:50
List* lappend_oid ( List list,
Oid  datum 
)

Definition at line 164 of file list.c.

References Assert, check_list_invariants, IsOidList, lfirst_oid, sort-test::list, new_list(), new_tail_cell(), NIL, T_OidList, and List::tail.

Referenced by add_rte_to_flat_rtable(), addRangeTableEntryForENR(), addRangeTableEntryForFunction(), adjust_rowcompare_for_index(), AfterTriggerSetState(), AlterTableMoveAll(), analyzeCTETargetList(), ApplyExtensionUpdates(), assign_collations_walker(), ATExecAlterColumnType(), binary_upgrade_create_empty_extension(), check_functional_grouping(), CommuteRowCompareExpr(), compute_semijoin_info(), convert_EXISTS_to_ANY(), create_indexscan_plan(), CreateExtensionInternal(), CreateFunction(), do_autovacuum(), EventTriggerCommonSetup(), ExecAlterDefaultPrivilegesStmt(), ExecInitHashJoin(), ExecInsertIndexTuples(), ExecuteGrantStmt(), ExecuteTruncate(), extract_query_dependencies_walker(), ExtractExtensionList(), find_all_inheritors(), find_inheritance_children(), find_typed_table_dependencies(), fix_expr_common(), get_mergejoin_opfamilies(), get_rel_oids(), GetAllTablesPublicationRelations(), GetAllTablesPublications(), getOwnedSequences(), GetPublicationRelations(), GetRelationPublications(), getRelationsInNamespace(), heap_truncate_check_FKs(), infer_arbiter_indexes(), list_append_unique_oid(), list_concat_unique_oid(), list_difference_oid(), list_union_oid(), make_row_comparison_op(), MergeAttributes(), nodeRead(), objectNamesToOids(), objectsInSchemaToOids(), oid_array_to_list(), OpenTableList(), pgstat_recv_inquiry(), PreCommit_on_commit_actions(), query_to_oid_list(), recomputeNamespacePath(), reindex_relation(), ReindexMultipleTables(), rel_is_distinct_for(), RelationBuildPartitionDesc(), RelationGetPartitionDispatchInfo(), remove_useless_groupby_columns(), roleSpecsToIds(), transformAggregateCall(), transformRangeTableFunc(), transformSetOperationTree(), transformValuesClause(), and typeInheritsFrom().

165 {
166  Assert(IsOidList(list));
167 
168  if (list == NIL)
169  list = new_list(T_OidList);
170  else
171  new_tail_cell(list);
172 
173  lfirst_oid(list->tail) = datum;
174  check_list_invariants(list);
175  return list;
176 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
static void new_tail_cell(List *list)
Definition: list.c:108
#define IsOidList(l)
Definition: list.c:27
#define Assert(condition)
Definition: c.h:675
tuple list
Definition: sort-test.py:11
#define lfirst_oid(lc)
Definition: pg_list.h:108
ListCell * tail
Definition: pg_list.h:50
List* lcons ( void *  datum,
List list 
)

Definition at line 259 of file list.c.

References Assert, check_list_invariants, List::head, IsPointerList, lfirst, sort-test::list, new_head_cell(), new_list(), NIL, and T_List.

Referenced by add_partial_path(), add_path(), assign_record_type_typmod(), ATExecAlterColumnType(), AtSubStart_Notify(), build_minmax_path(), checkWellFormedRecursionWalker(), consider_groupingsets_paths(), CreateExprContext(), CreateLockFile(), estimate_num_groups(), ExecInitExprRec(), ExecInitModifyTable(), ExplainNode(), extract_rollup_sets(), find_expr_references_walker(), find_update_path(), generateSerialExtraStmts(), get_join_index_paths(), get_name_for_var_field(), get_object_address_rv(), get_query_def(), get_relation_info(), get_relation_statistics(), get_rels_with_domain(), get_tables_to_cluster(), gistEmptyAllBuffers(), gistFindPath(), gistfinishsplit(), gistGetNodeBuffer(), gistPushItupToNodeBuffer(), load_domaintype_info(), makeDependencyGraphWalker(), merge_clump(), parseCheckAggregates(), pg_get_object_address(), PLy_subtransaction_enter(), PrepareClientEncoding(), push_child_plan(), pushOperator(), PushOverrideSearchPath(), pushStop(), pushValue_internal(), readTimeLineHistory(), register_on_commit_action(), RelationBuildRowSecurity(), RelationCacheInvalidate(), reorder_grouping_sets(), RewriteQuery(), rewriteTargetView(), sepgsql_avc_compute(), set_cheapest(), show_agg_keys(), show_group_keys(), sort_inner_and_outer(), spgWalk(), transformCaseExpr(), transformCreateStmt(), and UpdateRangeTableOfViewParse().

260 {
261  Assert(IsPointerList(list));
262 
263  if (list == NIL)
264  list = new_list(T_List);
265  else
266  new_head_cell(list);
267 
268  lfirst(list->head) = datum;
269  check_list_invariants(list);
270  return list;
271 }
#define NIL
Definition: pg_list.h:69
static void new_head_cell(List *list)
Definition: list.c:89
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
#define IsPointerList(l)
Definition: list.c:25
Definition: nodes.h:291
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
tuple list
Definition: sort-test.py:11
ListCell * head
Definition: pg_list.h:49
List* lcons_int ( int  datum,
List list 
)

Definition at line 277 of file list.c.

References Assert, check_list_invariants, List::head, IsIntegerList, lfirst_int, sort-test::list, new_head_cell(), new_list(), NIL, and T_IntList.

Referenced by ExecInitAgg(), ExplainBeginOutput(), and ExplainOpenGroup().

278 {
279  Assert(IsIntegerList(list));
280 
281  if (list == NIL)
282  list = new_list(T_IntList);
283  else
284  new_head_cell(list);
285 
286  lfirst_int(list->head) = datum;
287  check_list_invariants(list);
288  return list;
289 }
#define NIL
Definition: pg_list.h:69
static void new_head_cell(List *list)
Definition: list.c:89
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
#define Assert(condition)
Definition: c.h:675
tuple list
Definition: sort-test.py:11
ListCell * head
Definition: pg_list.h:49
List* lcons_oid ( Oid  datum,
List list 
)

Definition at line 295 of file list.c.

References Assert, check_list_invariants, List::head, IsOidList, lfirst_oid, sort-test::list, new_head_cell(), new_list(), NIL, and T_OidList.

Referenced by ATExecAlterColumnType(), CheckAttributeType(), CreateSchemaCommand(), fireRIRrules(), inline_function(), insert_ordered_oid(), insert_ordered_unique_oid(), PushOverrideSearchPath(), recomputeNamespacePath(), ReindexMultipleTables(), and TryReuseForeignKey().

296 {
297  Assert(IsOidList(list));
298 
299  if (list == NIL)
300  list = new_list(T_OidList);
301  else
302  new_head_cell(list);
303 
304  lfirst_oid(list->head) = datum;
305  check_list_invariants(list);
306  return list;
307 }
#define NIL
Definition: pg_list.h:69
static void new_head_cell(List *list)
Definition: list.c:89
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
#define IsOidList(l)
Definition: list.c:27
#define Assert(condition)
Definition: c.h:675
tuple list
Definition: sort-test.py:11
ListCell * head
Definition: pg_list.h:49
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* list_append_unique ( List list,
void *  datum 
)

Definition at line 962 of file list.c.

References lappend(), sort-test::list, and list_member().

Referenced by add_security_quals(), and add_with_check_options().

963 {
964  if (list_member(list, datum))
965  return list;
966  else
967  return lappend(list, datum);
968 }
bool list_member(const List *list, const void *datum)
Definition: list.c:444
List * lappend(List *list, void *datum)
Definition: list.c:128
tuple list
Definition: sort-test.py:11
List* list_append_unique_int ( List list,
int  datum 
)

Definition at line 987 of file list.c.

References lappend_int(), sort-test::list, and list_member_int().

988 {
989  if (list_member_int(list, datum))
990  return list;
991  else
992  return lappend_int(list, datum);
993 }
bool list_member_int(const List *list, int datum)
Definition: list.c:485
List * lappend_int(List *list, int datum)
Definition: list.c:146
tuple list
Definition: sort-test.py:11
List* list_append_unique_oid ( List list,
Oid  datum 
)

Definition at line 999 of file list.c.

References lappend_oid(), sort-test::list, and list_member_oid().

Referenced by ATExecAlterConstraint(), btvalidate(), hashvalidate(), is_admin_of_role(), map_sql_typecoll_to_xmlschema_types(), roles_has_privs_of(), and roles_is_member_of().

1000 {
1001  if (list_member_oid(list, datum))
1002  return list;
1003  else
1004  return lappend_oid(list, datum);
1005 }
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
tuple list
Definition: sort-test.py:11
List* list_append_unique_ptr ( List list,
void *  datum 
)

Definition at line 975 of file list.c.

References lappend(), sort-test::list, and list_member_ptr().

Referenced by get_useful_ecs_for_relation(), match_clause_to_index(), postgresGetForeignPaths(), subbuild_joinrel_joinlist(), and subbuild_joinrel_restrictlist().

976 {
977  if (list_member_ptr(list, datum))
978  return list;
979  else
980  return lappend(list, datum);
981 }
List * lappend(List *list, void *datum)
Definition: list.c:128
bool list_member_ptr(const List *list, const void *datum)
Definition: list.c:465
tuple list
Definition: sort-test.py:11
List* list_concat ( List list1,
List list2 
)

Definition at line 321 of file list.c.

References Assert, check_list_invariants, elog, ERROR, List::head, List::length, ListCell::next, NIL, List::tail, and List::type.

Referenced by accumulate_append_subpath(), add_function_defaults(), add_predicate_to_quals(), addRangeTableEntryForJoin(), addRangeTableEntryForTableFunc(), ATExecAttachPartition(), ATPostAlterTypeParse(), AtSubCommit_Notify(), build_joinrel_restrictlist(), build_paths_for_OR(), check_index_predicates(), check_sql_fn_retval(), choose_bitmap_and(), consider_groupingsets_paths(), convert_EXISTS_sublink_to_join(), cost_index(), create_bitmap_subplan(), create_index_paths(), create_join_plan(), create_scan_plan(), deconstruct_recurse(), DefineRelation(), estimate_path_cost_size(), expand_groupingset_node(), expand_indexqual_conditions(), expand_inherited_rtentry(), ExpandAllTables(), expandRTE(), extract_or_clause(), extract_rollup_sets(), fileBeginForeignScan(), fileGetOptions(), find_forced_null_vars(), find_indexpath_quals(), find_mergeclauses_for_pathkeys(), find_nonnullable_vars_walker(), fireRIRrules(), flatten_grouping_sets(), fmgr_sql_validator(), foreign_grouping_ok(), foreign_join_ok(), generate_bitmap_or_paths(), generate_join_implied_equalities_for_ecs(), generate_join_implied_equalities_normal(), generate_partition_qual(), generate_union_path(), get_baserel_parampathinfo(), get_foreign_key_join_selectivity(), get_from_clause_item(), get_index_paths(), get_join_index_paths(), get_joinrel_parampathinfo(), get_parameterized_baserel_size(), get_rel_oids(), get_relation_constraints(), get_rels_with_domain(), gincostestimate(), inheritance_planner(), init_sql_fcache(), inline_set_returning_function(), make_pathkeys_for_window(), max_parallel_hazard_walker(), MergeAttributes(), objectsInSchemaToOids(), process_equivalence(), process_matched_tle(), process_sublinks_mutator(), pull_ands(), pull_ors(), pull_up_simple_subquery(), pull_up_simple_union_all(), recurse_union_children(), reduce_outer_joins_pass2(), reduce_unique_semijoins(), RewriteQuery(), rewriteRuleAction(), rewriteTargetListIU(), selectColorTrigrams(), set_plan_refs(), set_subqueryscan_references(), simplify_and_arguments(), simplify_or_arguments(), split_pathtarget_at_srfs(), split_pathtarget_walker(), SyncRepGetSyncStandbysPriority(), TidQualFromExpr(), transformAExprIn(), transformAlterTableStmt(), transformCreateSchemaStmt(), transformCreateStmt(), transformExpressionList(), transformFromClause(), transformFromClauseItem(), and transformTargetList().

322 {
323  if (list1 == NIL)
324  return list2;
325  if (list2 == NIL)
326  return list1;
327  if (list1 == list2)
328  elog(ERROR, "cannot list_concat() a list to itself");
329 
330  Assert(list1->type == list2->type);
331 
332  list1->length += list2->length;
333  list1->tail->next = list2->head;
334  list1->tail = list2->tail;
335 
336  check_list_invariants(list1);
337  return list1;
338 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
#define ERROR
Definition: elog.h:43
ListCell * next
Definition: pg_list.h:61
#define Assert(condition)
Definition: c.h:675
int length
Definition: pg_list.h:48
NodeTag type
Definition: pg_list.h:47
ListCell * head
Definition: pg_list.h:49
#define elog
Definition: elog.h:219
ListCell * tail
Definition: pg_list.h:50
List* list_concat_unique ( List list1,
List list2 
)

Definition at line 1018 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, and list_member().

Referenced by create_bitmap_subplan().

1019 {
1020  ListCell *cell;
1021 
1022  Assert(IsPointerList(list1));
1023  Assert(IsPointerList(list2));
1024 
1025  foreach(cell, list2)
1026  {
1027  if (!list_member(list1, lfirst(cell)))
1028  list1 = lappend(list1, lfirst(cell));
1029  }
1030 
1031  check_list_invariants(list1);
1032  return list1;
1033 }
#define check_list_invariants(l)
Definition: list.c:54
bool list_member(const List *list, const void *datum)
Definition: list.c:444
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
List* list_concat_unique_int ( List list1,
List list2 
)

Definition at line 1061 of file list.c.

References Assert, check_list_invariants, IsIntegerList, lappend_int(), lfirst_int, and list_member_int().

1062 {
1063  ListCell *cell;
1064 
1065  Assert(IsIntegerList(list1));
1066  Assert(IsIntegerList(list2));
1067 
1068  foreach(cell, list2)
1069  {
1070  if (!list_member_int(list1, lfirst_int(cell)))
1071  list1 = lappend_int(list1, lfirst_int(cell));
1072  }
1073 
1074  check_list_invariants(list1);
1075  return list1;
1076 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
bool list_member_int(const List *list, int datum)
Definition: list.c:485
List * lappend_int(List *list, int datum)
Definition: list.c:146
#define Assert(condition)
Definition: c.h:675
List* list_concat_unique_oid ( List list1,
List list2 
)

Definition at line 1082 of file list.c.

References Assert, check_list_invariants, IsOidList, lappend_oid(), lfirst_oid, and list_member_oid().

Referenced by GetRelationPublicationActions().

1083 {
1084  ListCell *cell;
1085 
1086  Assert(IsOidList(list1));
1087  Assert(IsOidList(list2));
1088 
1089  foreach(cell, list2)
1090  {
1091  if (!list_member_oid(list1, lfirst_oid(cell)))
1092  list1 = lappend_oid(list1, lfirst_oid(cell));
1093  }
1094 
1095  check_list_invariants(list1);
1096  return list1;
1097 }
#define check_list_invariants(l)
Definition: list.c:54
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
#define IsOidList(l)
Definition: list.c:27
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
#define Assert(condition)
Definition: c.h:675
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* list_concat_unique_ptr ( List list1,
List list2 
)

Definition at line 1040 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, and list_member_ptr().

1041 {
1042  ListCell *cell;
1043 
1044  Assert(IsPointerList(list1));
1045  Assert(IsPointerList(list2));
1046 
1047  foreach(cell, list2)
1048  {
1049  if (!list_member_ptr(list1, lfirst(cell)))
1050  list1 = lappend(list1, lfirst(cell));
1051  }
1052 
1053  check_list_invariants(list1);
1054  return list1;
1055 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
bool list_member_ptr(const List *list, const void *datum)
Definition: list.c:465
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
List* list_copy ( const List oldlist)

Definition at line 1160 of file list.c.

References check_list_invariants, ListCell::data, List::head, List::length, new_list(), ListCell::next, NIL, NULL, palloc(), List::tail, and List::type.

Referenced by accumulate_append_subpath(), add_function_defaults(), adjust_rowcompare_for_index(), arrayconst_startup_fn(), arrayexpr_startup_fn(), build_paths_for_OR(), build_subplan(), check_index_predicates(), choose_bitmap_and(), consider_groupingsets_paths(), copy_pathtarget(), copyObjectImpl(), CopyOverrideSearchPath(), create_append_path(), create_merge_append_path(), create_modifytable_path(), create_scan_plan(), does_not_exist_skipping(), estimate_path_cost_size(), EventTriggerCollectGrant(), expand_groupingset_node(), expression_tree_mutator(), extract_or_clause(), fetch_search_path(), find_indexpath_quals(), foreign_join_ok(), generate_bitmap_or_paths(), generate_mergejoin_paths(), get_eclass_for_sort_expr(), get_foreign_key_join_selectivity(), get_from_clause_item(), get_object_address_attrdef(), get_object_address_attribute(), get_object_address_opf_member(), get_object_address_relobject(), get_parameterized_baserel_size(), get_query_def(), get_required_extension(), get_switched_clauses(), get_useful_pathkeys_for_relation(), GetOverrideSearchPath(), init_sql_fcache(), list_difference(), list_difference_int(), list_difference_oid(), list_difference_ptr(), list_union(), list_union_int(), list_union_oid(), list_union_ptr(), make_pathkeys_for_window(), max_parallel_hazard_walker(), owningrel_does_not_exist_skipping(), process_matched_tle(), process_owned_by(), PushOverrideSearchPath(), recomputeNamespacePath(), RelationGetIndexList(), RelationGetStatExtList(), RelationSetIndexList(), remove_rel_from_query(), reorder_grouping_sets(), roles_has_privs_of(), roles_is_member_of(), select_outer_pathkeys_for_merge(), set_plan_refs(), set_using_names(), SetReindexPending(), simplify_and_arguments(), simplify_or_arguments(), sort_inner_and_outer(), transformWithClause(), and truncate_useless_pathkeys().

1161 {
1162  List *newlist;
1163  ListCell *newlist_prev;
1164  ListCell *oldlist_cur;
1165 
1166  if (oldlist == NIL)
1167  return NIL;
1168 
1169  newlist = new_list(oldlist->type);
1170  newlist->length = oldlist->length;
1171 
1172  /*
1173  * Copy over the data in the first cell; new_list() has already allocated
1174  * the head cell itself
1175  */
1176  newlist->head->data = oldlist->head->data;
1177 
1178  newlist_prev = newlist->head;
1179  oldlist_cur = oldlist->head->next;
1180  while (oldlist_cur)
1181  {
1182  ListCell *newlist_cur;
1183 
1184  newlist_cur = (ListCell *) palloc(sizeof(*newlist_cur));
1185  newlist_cur->data = oldlist_cur->data;
1186  newlist_prev->next = newlist_cur;
1187 
1188  newlist_prev = newlist_cur;
1189  oldlist_cur = oldlist_cur->next;
1190  }
1191 
1192  newlist_prev->next = NULL;
1193  newlist->tail = newlist_prev;
1194 
1195  check_list_invariants(newlist);
1196  return newlist;
1197 }
#define NIL
Definition: pg_list.h:69
union ListCell::@90 data
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
ListCell * next
Definition: pg_list.h:61
#define NULL
Definition: c.h:229
int length
Definition: pg_list.h:48
NodeTag type
Definition: pg_list.h:47
void * palloc(Size size)
Definition: mcxt.c:849
ListCell * head
Definition: pg_list.h:49
Definition: pg_list.h:45
ListCell * tail
Definition: pg_list.h:50
List* list_copy_tail ( const List oldlist,
int  nskip 
)

Definition at line 1203 of file list.c.

References check_list_invariants, ListCell::data, List::head, List::length, new_list(), ListCell::next, NIL, NULL, palloc(), List::tail, and List::type.

Referenced by addRangeTableEntryForJoin(), addRangeTableEntryForTableFunc(), does_not_exist_skipping(), expandRTE(), find_expr_references_walker(), get_name_for_var_field(), get_object_address_opcf(), inheritance_planner(), ParseFuncOrColumn(), and transformAggregateCall().

1204 {
1205  List *newlist;
1206  ListCell *newlist_prev;
1207  ListCell *oldlist_cur;
1208 
1209  if (nskip < 0)
1210  nskip = 0; /* would it be better to elog? */
1211 
1212  if (oldlist == NIL || nskip >= oldlist->length)
1213  return NIL;
1214 
1215  newlist = new_list(oldlist->type);
1216  newlist->length = oldlist->length - nskip;
1217 
1218  /*
1219  * Skip over the unwanted elements.
1220  */
1221  oldlist_cur = oldlist->head;
1222  while (nskip-- > 0)
1223  oldlist_cur = oldlist_cur->next;
1224 
1225  /*
1226  * Copy over the data in the first remaining cell; new_list() has already
1227  * allocated the head cell itself
1228  */
1229  newlist->head->data = oldlist_cur->data;
1230 
1231  newlist_prev = newlist->head;
1232  oldlist_cur = oldlist_cur->next;
1233  while (oldlist_cur)
1234  {
1235  ListCell *newlist_cur;
1236 
1237  newlist_cur = (ListCell *) palloc(sizeof(*newlist_cur));
1238  newlist_cur->data = oldlist_cur->data;
1239  newlist_prev->next = newlist_cur;
1240 
1241  newlist_prev = newlist_cur;
1242  oldlist_cur = oldlist_cur->next;
1243  }
1244 
1245  newlist_prev->next = NULL;
1246  newlist->tail = newlist_prev;
1247 
1248  check_list_invariants(newlist);
1249  return newlist;
1250 }
#define NIL
Definition: pg_list.h:69
union ListCell::@90 data
#define check_list_invariants(l)
Definition: list.c:54
static List * new_list(NodeTag type)
Definition: list.c:63
ListCell * next
Definition: pg_list.h:61
#define NULL
Definition: c.h:229
int length
Definition: pg_list.h:48
NodeTag type
Definition: pg_list.h:47
void * palloc(Size size)
Definition: mcxt.c:849
ListCell * head
Definition: pg_list.h:49
Definition: pg_list.h:45
ListCell * tail
Definition: pg_list.h:50
List* list_delete ( List list,
void *  datum 
)

Definition at line 567 of file list.c.

References Assert, check_list_invariants, equal(), IsPointerList, lfirst, sort-test::list, list_delete_cell(), and NULL.

Referenced by postgresGetForeignPlan(), and unregister_ENR().

568 {
569  ListCell *cell;
570  ListCell *prev;
571 
572  Assert(IsPointerList(list));
573  check_list_invariants(list);
574 
575  prev = NULL;
576  foreach(cell, list)
577  {
578  if (equal(lfirst(cell), datum))
579  return list_delete_cell(list, cell, prev);
580 
581  prev = cell;
582  }
583 
584  /* Didn't find a match: return the list unmodified */
585  return list;
586 }
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:2962
#define check_list_invariants(l)
Definition: list.c:54
#define IsPointerList(l)
Definition: list.c:25
List * list_delete_cell(List *list, ListCell *cell, ListCell *prev)
Definition: list.c:528
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
tuple list
Definition: sort-test.py:11
List* list_delete_cell ( List list,
ListCell cell,
ListCell prev 
)

Definition at line 528 of file list.c.

References Assert, check_list_invariants, List::head, List::length, sort-test::list, list_free(), list_head(), lnext, ListCell::next, NIL, NULL, pfree(), and List::tail.

Referenced by add_partial_path(), add_path(), addKey(), AlterTSDictionary(), AtEOSubXact_on_commit_actions(), AtEOXact_on_commit_actions(), choose_bitmap_and(), create_nestloop_plan(), Exec_UnlistenCommit(), fileGetOptions(), get_foreign_key_join_selectivity(), list_delete(), list_delete_first(), list_delete_int(), list_delete_oid(), list_delete_ptr(), merge_clump(), MergeAttributes(), reconsider_outer_join_clauses(), RememberFsyncRequest(), select_active_windows(), sepgsql_avc_reclaim(), sepgsql_subxact_callback(), SetClientEncoding(), StandbyReleaseAllLocks(), StandbyReleaseLocks(), StandbyReleaseOldLocks(), SyncRepGetSyncStandbysPriority(), and transformGenericOptions().

529 {
530  check_list_invariants(list);
531  Assert(prev != NULL ? lnext(prev) == cell : list_head(list) == cell);
532 
533  /*
534  * If we're about to delete the last node from the list, free the whole
535  * list instead and return NIL, which is the only valid representation of
536  * a zero-length list.
537  */
538  if (list->length == 1)
539  {
540  list_free(list);
541  return NIL;
542  }
543 
544  /*
545  * Otherwise, adjust the necessary list links, deallocate the particular
546  * node we have just removed, and return the list we were given.
547  */
548  list->length--;
549 
550  if (prev)
551  prev->next = cell->next;
552  else
553  list->head = cell->next;
554 
555  if (list->tail == cell)
556  list->tail = prev;
557 
558  pfree(cell);
559  return list;
560 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
void pfree(void *pointer)
Definition: mcxt.c:950
static ListCell * list_head(const List *l)
Definition: pg_list.h:77
#define lnext(lc)
Definition: pg_list.h:105
ListCell * next
Definition: pg_list.h:61
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
int length
Definition: pg_list.h:48
tuple list
Definition: sort-test.py:11
ListCell * head
Definition: pg_list.h:49
void list_free(List *list)
Definition: list.c:1133
ListCell * tail
Definition: pg_list.h:50
List* list_delete_first ( List list)

Definition at line 666 of file list.c.

References check_list_invariants, list_delete_cell(), list_head(), NIL, and NULL.

Referenced by add_function_defaults(), AtEOSubXact_Namespace(), AtEOXact_Namespace(), AtSubAbort_Notify(), AtSubCommit_Notify(), CheckAttributeType(), checkWellFormedRecursionWalker(), CreateExtensionInternal(), ExplainCloseGroup(), ExplainEndOutput(), ExplainNode(), fetch_search_path(), find_expr_references_walker(), fireRIRrules(), func_get_detail(), get_name_for_var_field(), GetOverrideSearchPath(), gistEmptyAllBuffers(), gistFindPath(), gistfinishsplit(), gistProcessEmptyingQueue(), inline_function(), makeDependencyGraphWalker(), mdpostckpt(), PLy_abort_open_subtransactions(), PLy_subtransaction_exit(), pop_child_plan(), PopOverrideSearchPath(), processState(), RewriteQuery(), select_active_windows(), show_agg_keys(), show_group_keys(), simplify_and_arguments(), simplify_or_arguments(), spgWalk(), transformGraph(), and transformWithClause().

667 {
668  check_list_invariants(list);
669 
670  if (list == NIL)
671  return NIL; /* would an error be better? */
672 
673  return list_delete_cell(list, list_head(list), NULL);
674 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
static ListCell * list_head(const List *l)
Definition: pg_list.h:77
List * list_delete_cell(List *list, ListCell *cell, ListCell *prev)
Definition: list.c:528
#define NULL
Definition: c.h:229
List* list_delete_int ( List list,
int  datum 
)

Definition at line 613 of file list.c.

References Assert, check_list_invariants, IsIntegerList, lfirst_int, sort-test::list, list_delete_cell(), and NULL.

Referenced by reorder_grouping_sets().

614 {
615  ListCell *cell;
616  ListCell *prev;
617 
618  Assert(IsIntegerList(list));
619  check_list_invariants(list);
620 
621  prev = NULL;
622  foreach(cell, list)
623  {
624  if (lfirst_int(cell) == datum)
625  return list_delete_cell(list, cell, prev);
626 
627  prev = cell;
628  }
629 
630  /* Didn't find a match: return the list unmodified */
631  return list;
632 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
List * list_delete_cell(List *list, ListCell *cell, ListCell *prev)
Definition: list.c:528
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
tuple list
Definition: sort-test.py:11
List* list_delete_oid ( List list,
Oid  datum 
)

Definition at line 636 of file list.c.

References Assert, check_list_invariants, IsOidList, lfirst_oid, sort-test::list, list_delete_cell(), and NULL.

Referenced by RemoveReindexPending().

637 {
638  ListCell *cell;
639  ListCell *prev;
640 
641  Assert(IsOidList(list));
642  check_list_invariants(list);
643 
644  prev = NULL;
645  foreach(cell, list)
646  {
647  if (lfirst_oid(cell) == datum)
648  return list_delete_cell(list, cell, prev);
649 
650  prev = cell;
651  }
652 
653  /* Didn't find a match: return the list unmodified */
654  return list;
655 }
#define check_list_invariants(l)
Definition: list.c:54
List * list_delete_cell(List *list, ListCell *cell, ListCell *prev)
Definition: list.c:528
#define IsOidList(l)
Definition: list.c:27
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
tuple list
Definition: sort-test.py:11
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* list_delete_ptr ( List list,
void *  datum 
)

Definition at line 590 of file list.c.

References Assert, check_list_invariants, IsPointerList, lfirst, sort-test::list, list_delete_cell(), and NULL.

Referenced by add_unique_group_var(), adjustJoinTreeList(), ConvertTriggerToFK(), FreeExprContext(), generateSerialExtraStmts(), ParseFuncOrColumn(), process_equivalence(), reconsider_full_join_clause(), reduce_unique_semijoins(), remove_join_clause_from_rels(), remove_rel_from_query(), remove_useless_joins(), rewriteTargetView(), sort_inner_and_outer(), and transformMultiAssignRef().

591 {
592  ListCell *cell;
593  ListCell *prev;
594 
595  Assert(IsPointerList(list));
596  check_list_invariants(list);
597 
598  prev = NULL;
599  foreach(cell, list)
600  {
601  if (lfirst(cell) == datum)
602  return list_delete_cell(list, cell, prev);
603 
604  prev = cell;
605  }
606 
607  /* Didn't find a match: return the list unmodified */
608  return list;
609 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsPointerList(l)
Definition: list.c:25
List * list_delete_cell(List *list, ListCell *cell, ListCell *prev)
Definition: list.c:528
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
tuple list
Definition: sort-test.py:11
List* list_difference ( const List list1,
const List list2 
)

Definition at line 858 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, list_copy(), list_member(), NIL, and result.

Referenced by create_hashjoin_plan(), create_mergejoin_plan(), create_tidscan_plan(), infer_arbiter_indexes(), and process_duplicate_ors().

859 {
860  const ListCell *cell;
861  List *result = NIL;
862 
863  Assert(IsPointerList(list1));
864  Assert(IsPointerList(list2));
865 
866  if (list2 == NIL)
867  return list_copy(list1);
868 
869  foreach(cell, list1)
870  {
871  if (!list_member(list2, lfirst(cell)))
872  result = lappend(result, lfirst(cell));
873  }
874 
875  check_list_invariants(result);
876  return result;
877 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
bool list_member(const List *list, const void *datum)
Definition: list.c:444
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
Definition: pg_list.h:45
List* list_difference_int ( const List list1,
const List list2 
)

Definition at line 909 of file list.c.

References Assert, check_list_invariants, IsIntegerList, lappend_int(), lfirst_int, list_copy(), list_member_int(), NIL, and result.

Referenced by reorder_grouping_sets().

910 {
911  const ListCell *cell;
912  List *result = NIL;
913 
914  Assert(IsIntegerList(list1));
915  Assert(IsIntegerList(list2));
916 
917  if (list2 == NIL)
918  return list_copy(list1);
919 
920  foreach(cell, list1)
921  {
922  if (!list_member_int(list2, lfirst_int(cell)))
923  result = lappend_int(result, lfirst_int(cell));
924  }
925 
926  check_list_invariants(result);
927  return result;
928 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
bool list_member_int(const List *list, int datum)
Definition: list.c:485
List * lappend_int(List *list, int datum)
Definition: list.c:146
#define Assert(condition)
Definition: c.h:675
Definition: pg_list.h:45
List* list_difference_oid ( const List list1,
const List list2 
)

Definition at line 934 of file list.c.

References Assert, check_list_invariants, IsOidList, lappend_oid(), lfirst_oid, list_copy(), list_member_oid(), NIL, and result.

935 {
936  const ListCell *cell;
937  List *result = NIL;
938 
939  Assert(IsOidList(list1));
940  Assert(IsOidList(list2));
941 
942  if (list2 == NIL)
943  return list_copy(list1);
944 
945  foreach(cell, list1)
946  {
947  if (!list_member_oid(list2, lfirst_oid(cell)))
948  result = lappend_oid(result, lfirst_oid(cell));
949  }
950 
951  check_list_invariants(result);
952  return result;
953 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
#define IsOidList(l)
Definition: list.c:27
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
#define Assert(condition)
Definition: c.h:675
Definition: pg_list.h:45
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* list_difference_ptr ( const List list1,
const List list2 
)

Definition at line 884 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, list_copy(), list_member_ptr(), NIL, and result.

Referenced by create_bitmap_scan_plan().

885 {
886  const ListCell *cell;
887  List *result = NIL;
888 
889  Assert(IsPointerList(list1));
890  Assert(IsPointerList(list2));
891 
892  if (list2 == NIL)
893  return list_copy(list1);
894 
895  foreach(cell, list1)
896  {
897  if (!list_member_ptr(list2, lfirst(cell)))
898  result = lappend(result, lfirst(cell));
899  }
900 
901  check_list_invariants(result);
902  return result;
903 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
bool list_member_ptr(const List *list, const void *datum)
Definition: list.c:465
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
Definition: pg_list.h:45
void list_free ( List list)

Definition at line 1133 of file list.c.

References list_free_private().

Referenced by AfterTriggerSetState(), AlterIndexNamespaces(), arrayconst_cleanup_fn(), arrayexpr_cleanup_fn(), AtEOSubXact_cleanup(), AtEOSubXact_Namespace(), AtEOXact_cleanup(), AtEOXact_Namespace(), ATExecChangeOwner(), ATExecDropNotNull(), ATExecSetTableSpace(), build_base_rel_tlists(), calc_joinrel_size_estimate(), calculate_indexes_size(), calculate_toast_table_size(), check_datestyle(), check_log_destination(), check_search_path(), check_temp_tablespaces(), check_wal_consistency_checking(), choose_bitmap_and(), compute_semi_anti_join_factors(), CopyFrom(), CopyFromInsertBatch(), CreateExtensionInternal(), current_schema(), current_schemas(), distribute_qual_to_rels(), EventTriggerDDLCommandEnd(), EventTriggerDDLCommandStart(), EventTriggerSQLDrop(), EventTriggerTableRewrite(), ExecInsert(), ExecOpenIndices(), ExecRefreshMatView(), ExecResetTupleTable(), ExecSimpleRelationDelete(), ExecSimpleRelationInsert(), ExecSimpleRelationUpdate(), ExecUpdate(), extract_lateral_references(), ExtractExtensionList(), find_all_inheritors(), find_compatible_peragg(), find_expr_references_walker(), find_hash_columns(), find_placeholders_in_expr(), fix_placeholder_input_needed_levels(), freeScanStack(), generate_base_implied_equalities_no_const(), get_rel_sync_entry(), get_relation_info(), get_relation_statistics(), infer_arbiter_indexes(), is_admin_of_role(), list_delete_cell(), make_group_input_target(), make_partial_grouping_target(), make_pathkeys_for_window(), make_sort_input_target(), make_window_input_target(), OpenTableList(), parse_hba_auth_opt(), pgstat_write_statsfiles(), plpgsql_extra_checks_check_hook(), pop_ancestor_plan(), PopOverrideSearchPath(), PostmasterMain(), prepare_sort_from_pathkeys(), PrepareTempTablespaces(), preprocess_targetlist(), qual_is_pushdown_safe(), recomputeNamespacePath(), refresh_by_match_merge(), RelationCacheInvalidate(), RelationDestroyRelation(), RelationGetIndexAttrBitmap(), RelationGetIndexList(), RelationGetOidIndex(), RelationGetPrimaryKeyIndex(), RelationGetReplicaIndex(), RelationGetStatExtList(), relationHasPrimaryKey(), RelationHasUnloggedIndex(), RelationSetIndexList(), reorder_grouping_sets(), roles_has_privs_of(), roles_is_member_of(), sepgsql_dml_privileges(), stringToQualifiedNameList(), SyncRepGetSyncRecPtr(), SyncRepGetSyncStandbysPriority(), textToQualifiedNameList(), TidQualFromExpr(), toast_open_indexes(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), transformValuesClause(), triggered_change_notification(), typeInheritsFrom(), vac_open_indexes(), and WaitForLockers().

1134 {
1135  list_free_private(list, false);
1136 }
static void list_free_private(List *list, bool deep)
Definition: list.c:1103
void list_free_deep ( List list)

Definition at line 1147 of file list.c.

References Assert, IsPointerList, and list_free_private().

Referenced by checkSharedDependencies(), Exec_UnlistenAllCommit(), FreeSubscription(), get_rel_sync_entry(), gistbufferinginserttuples(), load_libraries(), lookup_proof_cache(), PostmasterMain(), process_syncing_tables_for_apply(), RelationDestroyRelation(), RelationGetFKeyList(), rescanLatestTimeLine(), StartReplication(), WaitForLockersMultiple(), XLogReadDetermineTimeline(), and XLogSendPhysical().

1148 {
1149  /*
1150  * A "deep" free operation only makes sense on a list of pointers.
1151  */
1152  Assert(IsPointerList(list));
1153  list_free_private(list, true);
1154 }
#define IsPointerList(l)
Definition: list.c:25
#define Assert(condition)
Definition: c.h:675
static void list_free_private(List *list, bool deep)
Definition: list.c:1103
static void list_free_private ( List list,
bool  deep 
)
static

Definition at line 1103 of file list.c.

References check_list_invariants, lfirst, list_head(), lnext, NULL, and pfree().

Referenced by list_free(), and list_free_deep().

1104 {
1105  ListCell *cell;
1106 
1107  check_list_invariants(list);
1108 
1109  cell = list_head(list);
1110  while (cell != NULL)
1111  {
1112  ListCell *tmp = cell;
1113 
1114  cell = lnext(cell);
1115  if (deep)
1116  pfree(lfirst(tmp));
1117  pfree(tmp);
1118  }
1119 
1120  if (list)
1121  pfree(list);
1122 }
#define check_list_invariants(l)
Definition: list.c:54
void pfree(void *pointer)
Definition: mcxt.c:950
static ListCell * list_head(const List *l)
Definition: pg_list.h:77
#define lnext(lc)
Definition: pg_list.h:105
#define NULL
Definition: c.h:229
#define lfirst(lc)
Definition: pg_list.h:106
List* list_intersection ( const List list1,
const List list2 
)

Definition at line 800 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, list_member(), NIL, and result.

Referenced by find_nonnullable_vars_walker(), and reduce_outer_joins_pass2().

801 {
802  List *result;
803  const ListCell *cell;
804 
805  if (list1 == NIL || list2 == NIL)
806  return NIL;
807 
808  Assert(IsPointerList(list1));
809  Assert(IsPointerList(list2));
810 
811  result = NIL;
812  foreach(cell, list1)
813  {
814  if (list_member(list2, lfirst(cell)))
815  result = lappend(result, lfirst(cell));
816  }
817 
818  check_list_invariants(result);
819  return result;
820 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
return result
Definition: formatting.c:1633
bool list_member(const List *list, const void *datum)
Definition: list.c:444
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
Definition: pg_list.h:45
List* list_intersection_int ( const List list1,
const List list2 
)

Definition at line 826 of file list.c.

References Assert, check_list_invariants, IsIntegerList, lappend_int(), lfirst_int, list_member_int(), NIL, and result.

Referenced by parseCheckAggregates().

827 {
828  List *result;
829  const ListCell *cell;
830 
831  if (list1 == NIL || list2 == NIL)
832  return NIL;
833 
834  Assert(IsIntegerList(list1));
835  Assert(IsIntegerList(list2));
836 
837  result = NIL;
838  foreach(cell, list1)
839  {
840  if (list_member_int(list2, lfirst_int(cell)))
841  result = lappend_int(result, lfirst_int(cell));
842  }
843 
844  check_list_invariants(result);
845  return result;
846 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
return result
Definition: formatting.c:1633
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
bool list_member_int(const List *list, int datum)
Definition: list.c:485
List * lappend_int(List *list, int datum)
Definition: list.c:146
#define Assert(condition)
Definition: c.h:675
Definition: pg_list.h:45
bool list_member ( const List list,
const void *  datum 
)

Definition at line 444 of file list.c.

References Assert, check_list_invariants, equal(), IsPointerList, and lfirst.

Referenced by add_new_column_to_pathtarget(), build_minmax_path(), create_bitmap_scan_plan(), ec_member_matches_foreign(), find_window_functions_walker(), infer_arbiter_indexes(), list_append_unique(), list_concat_unique(), list_difference(), list_intersection(), list_union(), process_duplicate_ors(), split_pathtarget_at_srfs(), and split_pathtarget_walker().

445 {
446  const ListCell *cell;
447 
448  Assert(IsPointerList(list));
449  check_list_invariants(list);
450 
451  foreach(cell, list)
452  {
453  if (equal(lfirst(cell), datum))
454  return true;
455  }
456 
457  return false;
458 }
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:2962
#define check_list_invariants(l)
Definition: list.c:54
#define IsPointerList(l)
Definition: list.c:25
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
bool list_member_int ( const List list,
int  datum 
)

Definition at line 485 of file list.c.

References Assert, check_list_invariants, IsIntegerList, and lfirst_int.

Referenced by AcquireExecutorLocks(), BeginCopy(), BeginCopyFrom(), check_ungrouped_columns_walker(), CopyGetAttnums(), estimate_num_groups(), InitPlan(), list_append_unique_int(), list_concat_unique_int(), list_difference_int(), list_intersection_int(), list_union_int(), max_parallel_hazard_walker(), parseCheckAggregates(), pg_stat_get_wal_senders(), reorder_grouping_sets(), and transformDistinctOnClause().

486 {
487  const ListCell *cell;
488 
489  Assert(IsIntegerList(list));
490  check_list_invariants(list);
491 
492  foreach(cell, list)
493  {
494  if (lfirst_int(cell) == datum)
495  return true;
496  }
497 
498  return false;
499 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
#define Assert(condition)
Definition: c.h:675
bool list_member_oid ( const List list,
Oid  datum 
)

Definition at line 505 of file list.c.

References Assert, check_list_invariants, IsOidList, and lfirst_oid.

Referenced by AfterTriggerSaveEvent(), AlterTableMoveAll(), ATExecAddInherit(), ATExecAlterColumnType(), ATExecAttachPartition(), BeginCopy(), CheckAttributeType(), CollationIsVisible(), ConversionIsVisible(), ec_member_matches_indexcol(), ExecCheckIndexConstraints(), ExecInsertIndexTuples(), ExecuteTruncate(), fireRIRrules(), FunctionIsVisible(), get_rel_sync_entry(), get_transform_fromsql(), get_transform_tosql(), has_privs_of_role(), hashvalidate(), heap_truncate_check_FKs(), heap_truncate_find_FKs(), inline_function(), is_member_of_role(), is_member_of_role_nosuper(), list_append_unique_oid(), list_concat_unique_oid(), list_difference_oid(), list_union_oid(), lookup_shippable(), MergeAttributes(), OpclassIsVisible(), OpenTableList(), OperatorIsVisible(), OpfamilyIsVisible(), pgstat_db_requested(), pgstat_recv_inquiry(), PlanCacheRelCallback(), recomputeNamespacePath(), ReindexIsProcessingIndex(), relation_has_unique_index_for(), RelationIsVisible(), StatisticsObjIsVisible(), TSConfigIsVisible(), TSDictionaryIsVisible(), TSParserIsVisible(), TSTemplateIsVisible(), typeInheritsFrom(), and TypeIsVisible().

506 {
507  const ListCell *cell;
508 
509  Assert(IsOidList(list));
510  check_list_invariants(list);
511 
512  foreach(cell, list)
513  {
514  if (lfirst_oid(cell) == datum)
515  return true;
516  }
517 
518  return false;
519 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsOidList(l)
Definition: list.c:27
#define Assert(condition)
Definition: c.h:675
#define lfirst_oid(lc)
Definition: pg_list.h:108
bool list_member_ptr ( const List list,
const void *  datum 
)

Definition at line 465 of file list.c.

References Assert, check_list_invariants, IsPointerList, and lfirst.

Referenced by create_bitmap_scan_plan(), create_indexscan_plan(), extract_nonindex_conditions(), get_foreign_key_join_selectivity(), has_indexed_join_quals(), list_append_unique_ptr(), list_concat_unique_ptr(), list_difference_ptr(), list_union_ptr(), postgresGetForeignPlan(), preprocess_groupclause(), and remove_join_clause_from_rels().

466 {
467  const ListCell *cell;
468 
469  Assert(IsPointerList(list));
470  check_list_invariants(list);
471 
472  foreach(cell, list)
473  {
474  if (lfirst(cell) == datum)
475  return true;
476  }
477 
478  return false;
479 }
#define check_list_invariants(l)
Definition: list.c:54
#define IsPointerList(l)
Definition: list.c:25
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
void* list_nth ( const List list,
int  n 
)

Definition at line 410 of file list.c.

References Assert, IsPointerList, lfirst, and list_nth_cell().

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_tlist(), ATAddForeignKeyConstraint(), convert_subquery_pathkeys(), convert_testexpr_mutator(), errorMissingColumn(), eval_const_expressions_mutator(), ExecInitCteScan(), ExecInitModifyTable(), ExecInitSubPlan(), expandRecordVariable(), expandRTE(), ExplainTargetRel(), finalize_plan(), find_expr_references_walker(), find_hash_columns(), fix_param_node(), flatten_join_alias_vars_mutator(), get_call_expr_arg_stable(), get_call_expr_argtype(), get_name_for_var_field(), get_rtable_name(), get_rte_attribute_is_dropped(), get_rte_attribute_name(), get_rte_attribute_type(), get_variable(), gimme_tree(), infer_collation_opclass_match(), markRTEForSelectPriv(), markTargetListOrigin(), MergeAttributes(), pg_get_function_arg_default(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresBeginForeignScan(), postgresExplainDirectModify(), postgresExplainForeignModify(), postgresExplainForeignScan(), postgresPlanDirectModify(), postgresPlanForeignModify(), reorder_grouping_sets(), resolve_special_varno(), set_cte_pathlist(), set_join_column_names(), set_relation_column_names(), set_using_names(), show_modifytable_info(), substitute_actual_parameters_mutator(), substitute_actual_srf_parameters_mutator(), transformFromClauseItem(), transformInsertRow(), transformMultiAssignRef(), transformPartitionBound(), transformSetOperationStmt(), TypeGetTupleDesc(), WinGetFuncArgCurrent(), WinGetFuncArgInFrame(), and WinGetFuncArgInPartition().

411 {
412  Assert(IsPointerList(list));
413  return lfirst(list_nth_cell(list, n));
414 }
ListCell * list_nth_cell(const List *list, int n)
Definition: list.c:386
#define IsPointerList(l)
Definition: list.c:25
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
ListCell* list_nth_cell ( const List list,
int  n 
)

Definition at line 386 of file list.c.

References Assert, check_list_invariants, List::head, List::length, length(), ListCell::next, NIL, and List::tail.

Referenced by build_subplan(), list_nth(), list_nth_int(), list_nth_oid(), split_pathtarget_at_srfs(), and split_pathtarget_walker().

387 {
388  ListCell *match;
389 
390  Assert(list != NIL);
391  Assert(n >= 0);
392  Assert(n < list->length);
393  check_list_invariants(list);
394 
395  /* Does the caller actually mean to fetch the tail? */
396  if (n == list->length - 1)
397  return list->tail;
398 
399  for (match = list->head; n-- > 0; match = match->next)
400  ;
401 
402  return match;
403 }
#define NIL
Definition: pg_list.h:69
int length(const List *list)
Definition: list.c:1271
#define check_list_invariants(l)
Definition: list.c:54
ListCell * next
Definition: pg_list.h:61
#define Assert(condition)
Definition: c.h:675
int length
Definition: pg_list.h:48
ListCell * head
Definition: pg_list.h:49
ListCell * tail
Definition: pg_list.h:50
int list_nth_int ( const List list,
int  n 
)

Definition at line 421 of file list.c.

References Assert, IsIntegerList, lfirst_int, and list_nth_cell().

Referenced by create_ctescan_plan(), get_rte_attribute_type(), and set_cte_pathlist().

422 {
423  Assert(IsIntegerList(list));
424  return lfirst_int(list_nth_cell(list, n));
425 }
ListCell * list_nth_cell(const List *list, int n)
Definition: list.c:386
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
#define Assert(condition)
Definition: c.h:675
Oid list_nth_oid ( const List list,
int  n 
)

Definition at line 432 of file list.c.

References Assert, IsOidList, lfirst_oid, and list_nth_cell().

Referenced by get_rte_attribute_is_dropped(), and get_rte_attribute_type().

433 {
434  Assert(IsOidList(list));
435  return lfirst_oid(list_nth_cell(list, n));
436 }
ListCell * list_nth_cell(const List *list, int n)
Definition: list.c:386
#define IsOidList(l)
Definition: list.c:27
#define Assert(condition)
Definition: c.h:675
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* list_truncate ( List list,
int  new_size 
)

Definition at line 350 of file list.c.

References Assert, check_list_invariants, List::length, sort-test::list, list_length(), ListCell::next, NIL, NULL, and List::tail.

Referenced by adjust_rowcompare_for_index(), does_not_exist_skipping(), ExpandIndirectionStar(), expandRTE(), generate_mergejoin_paths(), geqo_eval(), get_object_address_attrdef(), get_object_address_attribute(), get_object_address_opf_member(), get_object_address_relobject(), owningrel_does_not_exist_skipping(), ParseFuncOrColumn(), process_owned_by(), transformAggregateCall(), transformFromClauseItem(), transformSetOperationStmt(), and truncate_useless_pathkeys().

351 {
352  ListCell *cell;
353  int n;
354 
355  if (new_size <= 0)
356  return NIL; /* truncate to zero length */
357 
358  /* If asked to effectively extend the list, do nothing */
359  if (new_size >= list_length(list))
360  return list;
361 
362  n = 1;
363  foreach(cell, list)
364  {
365  if (n == new_size)
366  {
367  cell->next = NULL;
368  list->tail = cell;
369  list->length = new_size;
370  check_list_invariants(list);
371  return list;
372  }
373  n++;
374  }
375 
376  /* keep the compiler quiet; never reached */
377  Assert(false);
378  return list;
379 }
#define NIL
Definition: pg_list.h:69
#define check_list_invariants(l)
Definition: list.c:54
ListCell * next
Definition: pg_list.h:61
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
static int list_length(const List *l)
Definition: pg_list.h:89
int length
Definition: pg_list.h:48
tuple list
Definition: sort-test.py:11
ListCell * tail
Definition: pg_list.h:50
List* list_union ( const List list1,
const List list2 
)

Definition at line 697 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, list_copy(), list_member(), and result.

Referenced by AddRelationNewConstraints(), and process_duplicate_ors().

698 {
699  List *result;
700  const ListCell *cell;
701 
702  Assert(IsPointerList(list1));
703  Assert(IsPointerList(list2));
704 
705  result = list_copy(list1);
706  foreach(cell, list2)
707  {
708  if (!list_member(result, lfirst(cell)))
709  result = lappend(result, lfirst(cell));
710  }
711 
712  check_list_invariants(result);
713  return result;
714 }
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
bool list_member(const List *list, const void *datum)
Definition: list.c:444
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
Definition: pg_list.h:45
List* list_union_int ( const List list1,
const List list2 
)

Definition at line 744 of file list.c.

References Assert, check_list_invariants, IsIntegerList, lappend_int(), lfirst_int, list_copy(), list_member_int(), and result.

Referenced by expand_grouping_sets().

745 {
746  List *result;
747  const ListCell *cell;
748 
749  Assert(IsIntegerList(list1));
750  Assert(IsIntegerList(list2));
751 
752  result = list_copy(list1);
753  foreach(cell, list2)
754  {
755  if (!list_member_int(result, lfirst_int(cell)))
756  result = lappend_int(result, lfirst_int(cell));
757  }
758 
759  check_list_invariants(result);
760  return result;
761 }
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
#define IsIntegerList(l)
Definition: list.c:26
#define lfirst_int(lc)
Definition: pg_list.h:107
bool list_member_int(const List *list, int datum)
Definition: list.c:485
List * lappend_int(List *list, int datum)
Definition: list.c:146
#define Assert(condition)
Definition: c.h:675
Definition: pg_list.h:45
List* list_union_oid ( const List list1,
const List list2 
)

Definition at line 767 of file list.c.

References Assert, check_list_invariants, IsOidList, lappend_oid(), lfirst_oid, list_copy(), list_member_oid(), and result.

768 {
769  List *result;
770  const ListCell *cell;
771 
772  Assert(IsOidList(list1));
773  Assert(IsOidList(list2));
774 
775  result = list_copy(list1);
776  foreach(cell, list2)
777  {
778  if (!list_member_oid(result, lfirst_oid(cell)))
779  result = lappend_oid(result, lfirst_oid(cell));
780  }
781 
782  check_list_invariants(result);
783  return result;
784 }
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
#define IsOidList(l)
Definition: list.c:27
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
#define Assert(condition)
Definition: c.h:675
Definition: pg_list.h:45
#define lfirst_oid(lc)
Definition: pg_list.h:108
List* list_union_ptr ( const List list1,
const List list2 
)

Definition at line 721 of file list.c.

References Assert, check_list_invariants, IsPointerList, lappend(), lfirst, list_copy(), list_member_ptr(), and result.

722 {
723  List *result;
724  const ListCell *cell;
725 
726  Assert(IsPointerList(list1));
727  Assert(IsPointerList(list2));
728 
729  result = list_copy(list1);
730  foreach(cell, list2)
731  {
732  if (!list_member_ptr(result, lfirst(cell)))
733  result = lappend(result, lfirst(cell));
734  }
735 
736  check_list_invariants(result);
737  return result;
738 }
#define check_list_invariants(l)
Definition: list.c:54
List * list_copy(const List *oldlist)
Definition: list.c:1160
return result
Definition: formatting.c:1633
#define IsPointerList(l)
Definition: list.c:25
List * lappend(List *list, void *datum)
Definition: list.c:128
bool list_member_ptr(const List *list, const void *datum)
Definition: list.c:465
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
Definition: pg_list.h:45
static void new_head_cell ( List list)
static

Definition at line 89 of file list.c.

References List::head, List::length, ListCell::next, and palloc().

Referenced by lcons(), lcons_int(), and lcons_oid().

90 {
91  ListCell *new_head;
92 
93  new_head = (ListCell *) palloc(sizeof(*new_head));
94  new_head->next = list->head;
95 
96  list->head = new_head;
97  list->length++;
98 }
ListCell * next
Definition: pg_list.h:61
int length
Definition: pg_list.h:48
void * palloc(Size size)
Definition: mcxt.c:849
ListCell * head
Definition: pg_list.h:49
static List* new_list ( NodeTag  type)
static

Definition at line 63 of file list.c.

References List::head, List::length, ListCell::next, NULL, palloc(), List::tail, and List::type.

Referenced by lappend(), lappend_int(), lappend_oid(), lcons(), lcons_int(), lcons_oid(), list_copy(), list_copy_tail(), pg_parse_query(), and pg_rewrite_query().

64 {
65  List *new_list;
66  ListCell *new_head;
67 
68  new_head = (ListCell *) palloc(sizeof(*new_head));
69  new_head->next = NULL;
70  /* new_head->data is left undefined! */
71 
72  new_list = (List *) palloc(sizeof(*new_list));
73  new_list->type = type;
74  new_list->length = 1;
75  new_list->head = new_head;
76  new_list->tail = new_head;
77 
78  return new_list;
79 }
static List * new_list(NodeTag type)
Definition: list.c:63
ListCell * next
Definition: pg_list.h:61
#define NULL
Definition: c.h:229
int length
Definition: pg_list.h:48
NodeTag type
Definition: pg_list.h:47
void * palloc(Size size)
Definition: mcxt.c:849
ListCell * head
Definition: pg_list.h:49
Definition: pg_list.h:45
ListCell * tail
Definition: pg_list.h:50
static void new_tail_cell ( List list)
static

Definition at line 108 of file list.c.

References List::length, ListCell::next, NULL, palloc(), and List::tail.

Referenced by lappend(), lappend_int(), and lappend_oid().

109 {
110  ListCell *new_tail;
111 
112  new_tail = (ListCell *) palloc(sizeof(*new_tail));
113  new_tail->next = NULL;
114 
115  list->tail->next = new_tail;
116  list->tail = new_tail;
117  list->length++;
118 }
ListCell * next
Definition: pg_list.h:61
#define NULL
Definition: c.h:229
int length
Definition: pg_list.h:48
void * palloc(Size size)
Definition: mcxt.c:849
ListCell * tail
Definition: pg_list.h:50