From 8fc4197f7d015ab87ffccdb40d7b4d35fe92097a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 10 Oct 2008 13:48:05 +0000 Subject: [PATCH] Fix omission of DiscardStmt in GetCommandLogLevel, per report from Hubert Depesz Lubaczewski. In HEAD, also move a couple of other cases to make the code ordering match up with ProcessUtility. --- src/backend/tcop/utility.c | 79 ++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index b867df5581..b1a0fe28ca 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.298 2008/09/01 20:42:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.299 2008/10/10 13:48:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -147,7 +147,8 @@ check_xact_readonly(Node *parsetree) /* * Note: Commands that need to do more complicated checking are handled - * elsewhere. + * elsewhere, in particular COPY and plannable statements do their + * own checking. */ switch (nodeTag(parsetree)) @@ -2015,10 +2016,6 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_ALL; break; - case T_CreateDomainStmt: - lev = LOGSTMT_DDL; - break; - case T_CreateSchemaStmt: lev = LOGSTMT_DDL; break; @@ -2054,6 +2051,33 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_ALL; break; + case T_PrepareStmt: + { + PrepareStmt *stmt = (PrepareStmt *) parsetree; + + /* Look through a PREPARE to the contained stmt */ + lev = GetCommandLogLevel(stmt->query); + } + break; + + case T_ExecuteStmt: + { + ExecuteStmt *stmt = (ExecuteStmt *) parsetree; + PreparedStatement *ps; + + /* Look through an EXECUTE to the referenced stmt */ + ps = FetchPreparedStatement(stmt->name, false); + if (ps) + lev = GetCommandLogLevel(ps->plansource->raw_parse_tree); + else + lev = LOGSTMT_ALL; + } + break; + + case T_DeallocateStmt: + lev = LOGSTMT_ALL; + break; + case T_RenameStmt: lev = LOGSTMT_DDL; break; @@ -2074,10 +2098,6 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_DDL; break; - case T_AlterFunctionStmt: - lev = LOGSTMT_DDL; - break; - case T_GrantStmt: lev = LOGSTMT_DDL; break; @@ -2106,6 +2126,10 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_DDL; break; + case T_AlterFunctionStmt: + lev = LOGSTMT_DDL; + break; + case T_IndexStmt: lev = LOGSTMT_DDL; break; @@ -2186,6 +2210,10 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_ALL; break; + case T_DiscardStmt: + lev = LOGSTMT_ALL; + break; + case T_CreateTrigStmt: lev = LOGSTMT_DDL; break; @@ -2202,6 +2230,10 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_DDL; break; + case T_CreateDomainStmt: + lev = LOGSTMT_DDL; + break; + case T_CreateRoleStmt: lev = LOGSTMT_DDL; break; @@ -2282,33 +2314,6 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_DDL; break; - case T_PrepareStmt: - { - PrepareStmt *stmt = (PrepareStmt *) parsetree; - - /* Look through a PREPARE to the contained stmt */ - lev = GetCommandLogLevel(stmt->query); - } - break; - - case T_ExecuteStmt: - { - ExecuteStmt *stmt = (ExecuteStmt *) parsetree; - PreparedStatement *ps; - - /* Look through an EXECUTE to the referenced stmt */ - ps = FetchPreparedStatement(stmt->name, false); - if (ps) - lev = GetCommandLogLevel(ps->plansource->raw_parse_tree); - else - lev = LOGSTMT_ALL; - } - break; - - case T_DeallocateStmt: - lev = LOGSTMT_ALL; - break; - /* already-planned queries */ case T_PlannedStmt: { -- 2.40.0