Skip to content

Commit 6488275

Browse files
committed
In developer's FAQ, update list API, from Tom Lane.
1 parent 1b57f0e commit 6488275

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

doc/FAQ_DEV

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Developer's Frequently Asked Questions (FAQ) for PostgreSQL
33

4-
Last updated: Sat May 5 00:09:15 EDT 2007
4+
Last updated: Sat May 5 06:20:41 EDT 2007
55

66
Current maintainer: Bruce Momjian (bruce@momjian.us)
77

@@ -698,20 +698,21 @@ typedef struct nameData
698698
Here are some of the List manipulation commands:
699699

700700
lfirst(i), lfirst_int(i), lfirst_oid(i)
701-
return the data (a point, integer and OID respectively) at list
702-
element i.
701+
return the data (a pointer, integer or OID respectively) of
702+
list cell i.
703703

704704
lnext(i)
705-
return the next list element after i.
705+
return the next list cell after i.
706706

707707
foreach(i, list)
708-
loop through list, assigning each list element to i. It is
709-
important to note that i is a List *, not the data in the List
710-
element. You need to use lfirst(i) to get at the data. Here is
711-
a typical code snippet that loops through a List containing Var
712-
*'s and processes each one:
708+
loop through list, assigning each list cell to i. It is
709+
important to note that i is a ListCell *, not the data in the
710+
List element. You need to use lfirst(i) to get at the data.
711+
Here is a typical code snippet that loops through a List
712+
containing Var *'s and processes each one:
713713

714-
List *list;
714+
715+
List *list;
715716
ListCell *i;
716717

717718
foreach(i, list)
@@ -726,20 +727,20 @@ typedef struct nameData
726727
if list is NIL.
727728

728729
lappend(list, node)
729-
add node to the end of list. This is more expensive that lcons.
730+
add node to the end of list.
730731

731-
nconc(list1, list2)
732-
Concat list2 on to the end of list1.
732+
list_concat(list1, list2)
733+
Concatenate list2 on to the end of list1.
733734

734-
length(list)
735+
list_length(list)
735736
return the length of the list.
736737

737-
nth(i, list)
738-
return the i'th element in list.
738+
list_nth(list, i)
739+
return the i'th element in list, counting from zero.
739740

740-
lconsi, ...
741-
There are integer versions of these: lconsi, lappendi, etc.
742-
Also versions for OID lists: lconso, lappendo, etc.
741+
lcons_int, ...
742+
There are integer versions of these: lcons_int, lappend_int,
743+
etc. Also versions for OID lists: lcons_oid, lappend_oid, etc.
743744

744745
You can print nodes easily inside gdb. First, to disable output
745746
truncation when you use the gdb print command:
@@ -758,7 +759,7 @@ typedef struct nameData
758759

759760
2.4) I just added a field to a structure. What else should I do?
760761

761-
The structures passing around from the parser, rewrite, optimizer, and
762+
The structures passed around in the parser, rewriter, optimizer, and
762763
executor require quite a bit of support. Most structures have support
763764
routines in src/backend/nodes used to create, copy, read, and output
764765
those structures (in particular, the files copyfuncs.c and

doc/src/FAQ/FAQ_DEV.html

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<H1>Developer's Frequently Asked Questions (FAQ) for
1414
PostgreSQL</H1>
1515

16-
<P>Last updated: Sat May 5 00:09:15 EDT 2007</P>
16+
<P>Last updated: Sat May 5 06:20:41 EDT 2007</P>
1717

1818
<P>Current maintainer: Bruce Momjian (<A href=
1919
"mailto:bruce@momjian.us">bruce@momjian.us</A>)<BR>
@@ -863,24 +863,25 @@ <H3 id="item2.3">2.3) Why do we use <I>Node</I> and
863863
<DL>
864864
<DT>lfirst(i), lfirst_int(i), lfirst_oid(i)</DT>
865865

866-
<DD>return the data (a point, integer and OID respectively) at
867-
list element <I>i.</I></DD>
866+
<DD>return the data (a pointer, integer or OID respectively) of
867+
list cell <I>i.</I></DD>
868868

869869
<DT>lnext(i)</DT>
870870

871-
<DD>return the next list element after <I>i.</I></DD>
871+
<DD>return the next list cell after <I>i.</I></DD>
872872

873873
<DT>foreach(i, list)</DT>
874874

875875
<DD>
876-
loop through <I>list,</I> assigning each list element to
877-
<I>i.</I> It is important to note that <I>i</I> is a List *,
876+
loop through <I>list,</I> assigning each list cell to
877+
<I>i.</I> It is important to note that <I>i</I> is a ListCell *,
878878
not the data in the <I>List</I> element. You need to use
879879
<I>lfirst(i)</I> to get at the data. Here is a typical code
880880
snippet that loops through a List containing <I>Var *'s</I>
881881
and processes each one:
882882
<PRE>
883-
<CODE> List *list;
883+
<CODE>
884+
List *list;
884885
ListCell *i;
885886

886887
foreach(i, list)
@@ -900,26 +901,26 @@ <H3 id="item2.3">2.3) Why do we use <I>Node</I> and
900901

901902
<DT>lappend(list, node)</DT>
902903

903-
<DD>add <I>node</I> to the end of <I>list.</I> This is more
904-
expensive that lcons.</DD>
904+
<DD>add <I>node</I> to the end of <I>list.</I></DD>
905905

906-
<DT>nconc(list1, list2)</DT>
906+
<DT>list_concat(list1, list2)</DT>
907907

908-
<DD>Concat <I>list2</I> on to the end of <I>list1.</I></DD>
908+
<DD>Concatenate <I>list2</I> on to the end of <I>list1.</I></DD>
909909

910-
<DT>length(list)</DT>
910+
<DT>list_length(list)</DT>
911911

912912
<DD>return the length of the <I>list.</I></DD>
913913

914-
<DT>nth(i, list)</DT>
914+
<DT>list_nth(list, i)</DT>
915915

916-
<DD>return the <I>i</I>'th element in <I>list.</I></DD>
916+
<DD>return the <I>i</I>'th element in <I>list,</I>
917+
counting from zero.</DD>
917918

918-
<DT>lconsi, ...</DT>
919+
<DT>lcons_int, ...</DT>
919920

920-
<DD>There are integer versions of these: <I>lconsi,
921-
lappendi</I>, etc. Also versions for OID lists: <I>lconso,
922-
lappendo</I>, etc.</DD>
921+
<DD>There are integer versions of these: <I>lcons_int,
922+
lappend_int</I>, etc. Also versions for OID lists: <I>lcons_oid,
923+
lappend_oid</I>, etc.</DD>
923924
</DL>
924925
</BLOCKQUOTE>
925926
You can print nodes easily inside <I>gdb.</I> First, to disable
@@ -944,7 +945,7 @@ <H3 id="item2.3">2.3) Why do we use <I>Node</I> and
944945
<H3 id="item2.4">2.4) I just added a field to a structure.
945946
What else should I do?</H3>
946947

947-
<P>The structures passing around from the parser, rewrite,
948+
<P>The structures passed around in the parser, rewriter,
948949
optimizer, and executor require quite a bit of support. Most
949950
structures have support routines in <I>src/backend/nodes</I> used
950951
to create, copy, read, and output those structures (in particular,

0 commit comments

Comments
 (0)