Merge Revision 1.59.
authorToshihiro Kitagawa <kitagawa at sraoss.co.jp>
Wed, 21 Jul 2010 07:08:07 +0000 (07:08 +0000)
committerToshihiro Kitagawa <kitagawa at sraoss.co.jp>
Wed, 21 Jul 2010 07:08:07 +0000 (07:08 +0000)
pool_proto_modules.c

index db725383f3da5a210fc617bc945d51fb3322e187..8ce8497c786441e9b840f1249d0c9ff97e33a5f1 100644 (file)
@@ -1921,16 +1921,36 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend,
                        break;
 
                case 'F':       /* FunctionCall */
-                       if (MAJOR(backend) == PROTO_MAJOR_V3)
+                       if (MASTER_SLAVE)
                        {
-                               status = FunctionCall3(frontend, backend, len, contents);
-                               break;
+                               /*
+                                * Send to primary/master node only.
+                                * For this we treat function call as if INSERT.
+                                */
+                               POOL_QUERY_CONTEXT *query_context;
+                               char *query = "INSERT INTO foo VALUES(1)";
+                               Node *node;
+                               List *parse_tree_list;
+
+                               /* Create query context */
+                               query_context = pool_init_query_context();
+                               if (!query_context)
+                               {
+                                       pool_error("ProcessFrontendResponse: pool_init_query_context failed");
+                                       return POOL_END;
+                               }
+                               parse_tree_list = raw_parser(query);
+                               node = (Node *) lfirst(list_head(parse_tree_list));
+                               pool_start_query(query_context, query, node);
+                               pool_where_to_send(query_context, query_context->original_query,
+                                                                  query_context->parse_tree);
                        }
+
+                       if (MAJOR(backend) == PROTO_MAJOR_V3)
+                               status = FunctionCall3(frontend, backend, len, contents);
                        else
-                       {
                                status = FunctionCall(frontend, backend);
-                               break;
-                       }
+                       break;
 
                case 'c':       /* CopyDone */
                case 'd':       /* CopyData */