diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-12-14 17:07:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-12-14 17:07:00 +0000 |
commit | b1ea82fee14c457a76ac65efca58155240dab950 (patch) | |
tree | 52f6faf303fab8f58942c636e5785014a4c30d43 /src/backend/commands/prepare.c | |
parent | 6acbe665f72b4e3c6757ba6977f3802960f4df00 (diff) |
Defend against crash while processing Describe Statement or Describe Portal
messages, when client attempts to execute these outside a transaction (start
one) or in a failed transaction (reject message, except for COMMIT/ROLLBACK
statements which we can handle). Per report from Francisco Figueiredo Jr.
Diffstat (limited to 'src/backend/commands/prepare.c')
-rw-r--r-- | src/backend/commands/prepare.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index babae5e1483..b301a75b276 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.23.4.2 2004/12/13 00:17:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.23.4.3 2005/12/14 17:06:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -443,6 +443,30 @@ FetchPreparedStatementResultDesc(PreparedStatement *stmt) } /* + * Given a prepared statement, determine whether it will return tuples. + * + * Note: this is used rather than just testing the result of + * FetchPreparedStatementResultDesc() because that routine can fail if + * invoked in an aborted transaction. This one is safe to use in any + * context. Be sure to keep the two routines in sync! + */ +bool +PreparedStatementReturnsTuples(PreparedStatement *stmt) +{ + switch (ChoosePortalStrategy(stmt->query_list)) + { + case PORTAL_ONE_SELECT: + case PORTAL_UTIL_SELECT: + return true; + + case PORTAL_MULTI_QUERY: + /* will not return tuples */ + break; + } + return false; +} + +/* * Implements the 'DEALLOCATE' utility statement: deletes the * specified plan from storage. */ |