mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
In developer's FAQ, update list API, from Tom Lane.
This commit is contained in:
41
doc/FAQ_DEV
41
doc/FAQ_DEV
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Developer's Frequently Asked Questions (FAQ) for PostgreSQL
|
Developer's Frequently Asked Questions (FAQ) for PostgreSQL
|
||||||
|
|
||||||
Last updated: Sat May 5 00:09:15 EDT 2007
|
Last updated: Sat May 5 06:20:41 EDT 2007
|
||||||
|
|
||||||
Current maintainer: Bruce Momjian (bruce@momjian.us)
|
Current maintainer: Bruce Momjian (bruce@momjian.us)
|
||||||
|
|
||||||
@ -698,20 +698,21 @@ typedef struct nameData
|
|||||||
Here are some of the List manipulation commands:
|
Here are some of the List manipulation commands:
|
||||||
|
|
||||||
lfirst(i), lfirst_int(i), lfirst_oid(i)
|
lfirst(i), lfirst_int(i), lfirst_oid(i)
|
||||||
return the data (a point, integer and OID respectively) at list
|
return the data (a pointer, integer or OID respectively) of
|
||||||
element i.
|
list cell i.
|
||||||
|
|
||||||
lnext(i)
|
lnext(i)
|
||||||
return the next list element after i.
|
return the next list cell after i.
|
||||||
|
|
||||||
foreach(i, list)
|
foreach(i, list)
|
||||||
loop through list, assigning each list element to i. It is
|
loop through list, assigning each list cell to i. It is
|
||||||
important to note that i is a List *, not the data in the List
|
important to note that i is a ListCell *, not the data in the
|
||||||
element. You need to use lfirst(i) to get at the data. Here is
|
List element. You need to use lfirst(i) to get at the data.
|
||||||
a typical code snippet that loops through a List containing Var
|
Here is a typical code snippet that loops through a List
|
||||||
*'s and processes each one:
|
containing Var *'s and processes each one:
|
||||||
|
|
||||||
List *list;
|
|
||||||
|
List *list;
|
||||||
ListCell *i;
|
ListCell *i;
|
||||||
|
|
||||||
foreach(i, list)
|
foreach(i, list)
|
||||||
@ -726,20 +727,20 @@ typedef struct nameData
|
|||||||
if list is NIL.
|
if list is NIL.
|
||||||
|
|
||||||
lappend(list, node)
|
lappend(list, node)
|
||||||
add node to the end of list. This is more expensive that lcons.
|
add node to the end of list.
|
||||||
|
|
||||||
nconc(list1, list2)
|
list_concat(list1, list2)
|
||||||
Concat list2 on to the end of list1.
|
Concatenate list2 on to the end of list1.
|
||||||
|
|
||||||
length(list)
|
list_length(list)
|
||||||
return the length of the list.
|
return the length of the list.
|
||||||
|
|
||||||
nth(i, list)
|
list_nth(list, i)
|
||||||
return the i'th element in list.
|
return the i'th element in list, counting from zero.
|
||||||
|
|
||||||
lconsi, ...
|
lcons_int, ...
|
||||||
There are integer versions of these: lconsi, lappendi, etc.
|
There are integer versions of these: lcons_int, lappend_int,
|
||||||
Also versions for OID lists: lconso, lappendo, etc.
|
etc. Also versions for OID lists: lcons_oid, lappend_oid, etc.
|
||||||
|
|
||||||
You can print nodes easily inside gdb. First, to disable output
|
You can print nodes easily inside gdb. First, to disable output
|
||||||
truncation when you use the gdb print command:
|
truncation when you use the gdb print command:
|
||||||
@ -758,7 +759,7 @@ typedef struct nameData
|
|||||||
|
|
||||||
2.4) I just added a field to a structure. What else should I do?
|
2.4) I just added a field to a structure. What else should I do?
|
||||||
|
|
||||||
The structures passing around from the parser, rewrite, optimizer, and
|
The structures passed around in the parser, rewriter, optimizer, and
|
||||||
executor require quite a bit of support. Most structures have support
|
executor require quite a bit of support. Most structures have support
|
||||||
routines in src/backend/nodes used to create, copy, read, and output
|
routines in src/backend/nodes used to create, copy, read, and output
|
||||||
those structures (in particular, the files copyfuncs.c and
|
those structures (in particular, the files copyfuncs.c and
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<H1>Developer's Frequently Asked Questions (FAQ) for
|
<H1>Developer's Frequently Asked Questions (FAQ) for
|
||||||
PostgreSQL</H1>
|
PostgreSQL</H1>
|
||||||
|
|
||||||
<P>Last updated: Sat May 5 00:09:15 EDT 2007</P>
|
<P>Last updated: Sat May 5 06:20:41 EDT 2007</P>
|
||||||
|
|
||||||
<P>Current maintainer: Bruce Momjian (<A href=
|
<P>Current maintainer: Bruce Momjian (<A href=
|
||||||
"mailto:bruce@momjian.us">bruce@momjian.us</A>)<BR>
|
"mailto:bruce@momjian.us">bruce@momjian.us</A>)<BR>
|
||||||
@ -863,24 +863,25 @@
|
|||||||
<DL>
|
<DL>
|
||||||
<DT>lfirst(i), lfirst_int(i), lfirst_oid(i)</DT>
|
<DT>lfirst(i), lfirst_int(i), lfirst_oid(i)</DT>
|
||||||
|
|
||||||
<DD>return the data (a point, integer and OID respectively) at
|
<DD>return the data (a pointer, integer or OID respectively) of
|
||||||
list element <I>i.</I></DD>
|
list cell <I>i.</I></DD>
|
||||||
|
|
||||||
<DT>lnext(i)</DT>
|
<DT>lnext(i)</DT>
|
||||||
|
|
||||||
<DD>return the next list element after <I>i.</I></DD>
|
<DD>return the next list cell after <I>i.</I></DD>
|
||||||
|
|
||||||
<DT>foreach(i, list)</DT>
|
<DT>foreach(i, list)</DT>
|
||||||
|
|
||||||
<DD>
|
<DD>
|
||||||
loop through <I>list,</I> assigning each list element to
|
loop through <I>list,</I> assigning each list cell to
|
||||||
<I>i.</I> It is important to note that <I>i</I> is a List *,
|
<I>i.</I> It is important to note that <I>i</I> is a ListCell *,
|
||||||
not the data in the <I>List</I> element. You need to use
|
not the data in the <I>List</I> element. You need to use
|
||||||
<I>lfirst(i)</I> to get at the data. Here is a typical code
|
<I>lfirst(i)</I> to get at the data. Here is a typical code
|
||||||
snippet that loops through a List containing <I>Var *'s</I>
|
snippet that loops through a List containing <I>Var *'s</I>
|
||||||
and processes each one:
|
and processes each one:
|
||||||
<PRE>
|
<PRE>
|
||||||
<CODE> List *list;
|
<CODE>
|
||||||
|
List *list;
|
||||||
ListCell *i;
|
ListCell *i;
|
||||||
|
|
||||||
foreach(i, list)
|
foreach(i, list)
|
||||||
@ -900,26 +901,26 @@
|
|||||||
|
|
||||||
<DT>lappend(list, node)</DT>
|
<DT>lappend(list, node)</DT>
|
||||||
|
|
||||||
<DD>add <I>node</I> to the end of <I>list.</I> This is more
|
<DD>add <I>node</I> to the end of <I>list.</I></DD>
|
||||||
expensive that lcons.</DD>
|
|
||||||
|
|
||||||
<DT>nconc(list1, list2)</DT>
|
<DT>list_concat(list1, list2)</DT>
|
||||||
|
|
||||||
<DD>Concat <I>list2</I> on to the end of <I>list1.</I></DD>
|
<DD>Concatenate <I>list2</I> on to the end of <I>list1.</I></DD>
|
||||||
|
|
||||||
<DT>length(list)</DT>
|
<DT>list_length(list)</DT>
|
||||||
|
|
||||||
<DD>return the length of the <I>list.</I></DD>
|
<DD>return the length of the <I>list.</I></DD>
|
||||||
|
|
||||||
<DT>nth(i, list)</DT>
|
<DT>list_nth(list, i)</DT>
|
||||||
|
|
||||||
<DD>return the <I>i</I>'th element in <I>list.</I></DD>
|
<DD>return the <I>i</I>'th element in <I>list,</I>
|
||||||
|
counting from zero.</DD>
|
||||||
|
|
||||||
<DT>lconsi, ...</DT>
|
<DT>lcons_int, ...</DT>
|
||||||
|
|
||||||
<DD>There are integer versions of these: <I>lconsi,
|
<DD>There are integer versions of these: <I>lcons_int,
|
||||||
lappendi</I>, etc. Also versions for OID lists: <I>lconso,
|
lappend_int</I>, etc. Also versions for OID lists: <I>lcons_oid,
|
||||||
lappendo</I>, etc.</DD>
|
lappend_oid</I>, etc.</DD>
|
||||||
</DL>
|
</DL>
|
||||||
</BLOCKQUOTE>
|
</BLOCKQUOTE>
|
||||||
You can print nodes easily inside <I>gdb.</I> First, to disable
|
You can print nodes easily inside <I>gdb.</I> First, to disable
|
||||||
@ -944,7 +945,7 @@
|
|||||||
<H3 id="item2.4">2.4) I just added a field to a structure.
|
<H3 id="item2.4">2.4) I just added a field to a structure.
|
||||||
What else should I do?</H3>
|
What else should I do?</H3>
|
||||||
|
|
||||||
<P>The structures passing around from the parser, rewrite,
|
<P>The structures passed around in the parser, rewriter,
|
||||||
optimizer, and executor require quite a bit of support. Most
|
optimizer, and executor require quite a bit of support. Most
|
||||||
structures have support routines in <I>src/backend/nodes</I> used
|
structures have support routines in <I>src/backend/nodes</I> used
|
||||||
to create, copy, read, and output those structures (in particular,
|
to create, copy, read, and output those structures (in particular,
|
||||||
|
Reference in New Issue
Block a user