Fix core dump and mishandling of temp tables.
authorTatsuo Ishii <ishii@postgresql.org>
Wed, 16 Aug 2017 04:40:46 +0000 (13:40 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Wed, 16 Aug 2017 04:40:46 +0000 (13:40 +0900)
Fix two issues:

1) Protect pool_remove_sent_message() and pool_get_sent_message()
   against null parameters.

2) Fix bug while determining if the created table is temporary or not.

src/context/pool_session_context.c
src/protocol/pool_proto_modules.c

index c651fcdea87e36c575568634a7e73a4200ddedc0..2e93985a681886b86245f2b08472577706228612 100644 (file)
@@ -346,6 +346,9 @@ bool pool_remove_sent_message(char kind, const char *name)
        int i;
        POOL_SENT_MESSAGE_LIST *msglist;
 
+       if (kind == 0 || name == NULL)
+               return false;
+
        msglist = &pool_get_session_context(false)->message_list;
 
        for (i = 0; i < msglist->size; i++)
@@ -574,6 +577,9 @@ POOL_SENT_MESSAGE *pool_get_sent_message(char kind, const char *name, POOL_SENT_
 
        msglist = &pool_get_session_context(false)->message_list;
 
+       if (kind == 0 || name == NULL)
+               return NULL;
+
        for (i = 0; i < msglist->size; i++)
        {
                if (msglist->sent_messages[i]->kind == kind &&
index aaf75fccf7c161afd918437f958622611f6f513e..d029556465f3dc48816bea4fac6c6dfb2b90227c 100644 (file)
@@ -3726,7 +3726,7 @@ void pool_at_command_success(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *ba
                if (IsA(node, CreateStmt))
                {
                        CreateStmt *create_table_stmt = (CreateStmt *)node;
-                       if (create_table_stmt->relation->relpersistence)
+                       if (create_table_stmt->relation->relpersistence == 't')
                                discard_temp_table_relcache();
                }
        }