diff --git a/doc/src/sgml/ref/discard.sgml b/doc/src/sgml/ref/discard.sgml
index cca95f984e750eaff69ddfc272c46f87cf77c3e9..2392e5bf549ba3422d135ef59a6ac08a5bd99076 100644
--- a/doc/src/sgml/ref/discard.sgml
+++ b/doc/src/sgml/ref/discard.sgml
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/discard.sgml,v 1.3 2008/11/14 10:22:46 petere Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/discard.sgml,v 1.4 2008/11/26 01:21:07 tgl Exp $
 PostgreSQL documentation
 -->
 
@@ -80,6 +80,7 @@ RESET ALL;
 DEALLOCATE ALL;
 CLOSE ALL;
 UNLISTEN *;
+SELECT pg_advisory_unlock_all();
 DISCARD PLANS;
 DISCARD TEMP;
 </programlisting>
diff --git a/src/backend/commands/discard.c b/src/backend/commands/discard.c
index 65d910c3209ed751a2242ca5ee53606c41b5256a..e8a6ecb5d24081f4517e719c57f29439510c97ab 100644
--- a/src/backend/commands/discard.c
+++ b/src/backend/commands/discard.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/commands/discard.c,v 1.4 2008/01/01 19:45:49 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/discard.c,v 1.5 2008/11/26 01:21:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,6 +66,7 @@ DiscardAll(bool isTopLevel)
 	DropAllPreparedStatements();
 	PortalHashTableDeleteAll();
 	Async_UnlistenAll();
+	LockReleaseAll(USER_LOCKMETHOD, true);
 	ResetPlanCache();
 	ResetTempTableNamespace();
 }