Create PostgreSQL version cache as early as possible.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 9 Aug 2019 05:50:56 +0000 (14:50 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 9 Aug 2019 05:50:56 +0000 (14:50 +0900)
Since once error query is issued, the query to create version cache
(SELECT version()) is ignored and it leads to failure in creating
version cache. Fix is, to create version cache after query context is
created and before user query is sent in SimpleQuery() and Parse().

src/protocol/pool_proto_modules.c

index bc253806062b418e07bb04c9906cfa75c696c058..fb779486da5ea0b809075d211a726586c93bce02 100644 (file)
@@ -298,6 +298,13 @@ SimpleQuery(POOL_CONNECTION * frontend,
                 */
                pool_start_query(query_context, contents, len, node);
 
+               /*
+                * Create PostgreSQL version cache.  Since the provided query might
+                * cause a syntax error, we want to issue "SELECT version()" which is
+                * called inside Pgversion() here.
+                */
+               Pgversion(backend);
+
                /*
                 * If the query is DROP DATABASE, after executing it, cache files
                 * directory must be discarded. So we have to get the DB's oid before
@@ -1097,6 +1104,13 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend,
                 */
                pool_start_query(query_context, pstrdup(stmt), strlen(stmt) + 1, node);
 
+               /*
+                * Create PostgreSQL version cache.  Since the provided query might
+                * cause a syntax error, we want to issue "SELECT version()" which is
+                * called inside Pgversion() here.
+                */
+               Pgversion(backend);
+
                msg = pool_create_sent_message('P', len, contents, 0, name, query_context);
 
                session_context->uncompleted_message = msg;