|
14 | 14 | alink="#0000ff"> |
15 | 15 | <H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1> |
16 | 16 |
|
17 | | -<P>Last updated:Fri Apr 26 23:03:46 EDT 2002</P> |
| 17 | +<P>Last updated:Mon Jun 10 15:47:38 EDT 2002</P> |
18 | 18 |
|
19 | 19 | <P>Current maintainer: Bruce Momjian (<Ahref= |
20 | 20 | "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR> |
@@ -138,7 +138,9 @@ <H2 align="center">Operational Questions</H2> |
138 | 138 | <Ahref="#4.24">4.24</A>) How do I perform queries using multiple |
139 | 139 | databases?<BR> |
140 | 140 | <Ahref="#4.25">4.25</A>) How do I return multiple rows or columns |
141 | | - from a function?<BR> |
| 141 | + from a function?<BR> |
| 142 | +<Ahref="#4.26">4.26</A>) Why can't I reliably create/drop |
| 143 | + temporary tables in PL/PgSQL functions?<BR> |
142 | 144 |
|
143 | 145 |
|
144 | 146 | <H2align="center">Extending PostgreSQL</H2> |
@@ -742,7 +744,7 @@ <H4><A name="3.7">3.7</A>) What debugging features are |
742 | 744 | <P>You can also compile with profiling to see what functions are |
743 | 745 | taking execution time. The backend profile files will be deposited |
744 | 746 | in the<I>pgsql/data/base/dbname</I> directory. The client profile |
745 | | - file will be put in the client's current directory.Linux requires |
| 747 | + file will be put in the client's current directory. Linux requires |
746 | 748 | a compile with<I>-DLINUX_PROFILE</I> for proper profiling.</P> |
747 | 749 |
|
748 | 750 | <H4><Aname="3.8">3.8</A>) Why do I get<I>"Sorry, too many |
@@ -900,9 +902,9 @@ <H4><A name="4.7">4.7</A>) How do I find out what tables, indexes, |
900 | 902 | databases, and users are defined?</H4> |
901 | 903 |
|
902 | 904 | <P><I>psql</I> has a variety of backslash commands to show such |
903 | | - information. Use \? to see them.There are also system tables |
904 | | - beginning with<i>pg_</i> that describe these too.Also,<i>psql |
905 | | - -l</i> will list all databases.</P> |
| 905 | + information. Use \? to see them. There are also system tables |
| 906 | + beginning with<I>pg_</I> that describe these too. Also,<I>psql |
| 907 | + -l</I> will list all databases.</P> |
906 | 908 |
|
907 | 909 | <P>Also try the file<I>pgsql/src/tutorial/syscat.source</I>. It |
908 | 910 | illustrates many of the<SMALL>SELECT</SMALL>s needed to get |
@@ -1307,16 +1309,25 @@ <H4><A name="4.24">4.24</A>) How do I perform queries using |
1307 | 1309 | different databases and merge the information that way.</P> |
1308 | 1310 | <HR> |
1309 | 1311 |
|
1310 | | -<H4><Aname="4.25">4.25</A>) How do I return multiple rows or columns |
1311 | | - from a function?</H4> |
| 1312 | +<H4><Aname="4.25">4.25</A>) How do I return multiple rows or |
| 1313 | + columns from a function?</H4> |
| 1314 | + |
| 1315 | +<P>You can return result sets from PL/pgSQL functions using |
| 1316 | +<I>refcursors</I>. See<Ahref= |
| 1317 | + "http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html"> |
| 1318 | + http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html,</A> |
| 1319 | + section 23.7.3.3.</P> |
| 1320 | + |
| 1321 | +<H4><Ahref="#4.26">4.26</A>) Why can't I reliably create/drop |
| 1322 | + temporary tables in PL/PgSQL functions?</H4> |
| 1323 | + PL/PgSQL caches function contents, and an unfortunate side effect |
| 1324 | + is that if a PL/PgSQL function accesses a temporary table, and that |
| 1325 | + table is later dropped and recreated, and the function called |
| 1326 | + again, the function will fail because the cached function contents |
| 1327 | + still point to the old temporary table. The solution is to use |
| 1328 | +<SMALL>EXECUTE</SMALL> for temporary table access in PL/PgSQL. This |
| 1329 | + will cause the query to be reparsed every time. |
1312 | 1330 |
|
1313 | | -<P>You can return result sets from PL/pgSQL functions using |
1314 | | -<i>refcursors</i>. See<a |
1315 | | -href="http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html"> |
1316 | | - http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html,</a> |
1317 | | - section 23.7.3.3.</P> |
1318 | | - |
1319 | | - |
1320 | 1331 | <H2align="center">Extending PostgreSQL</H2> |
1321 | 1332 |
|
1322 | 1333 | <H4><Aname="5.1">5.1</A>) I wrote a user-defined function. When I |
|