completely remove func=NULL calls of plproxy_error
authorMarko Kreen <markokr@gmail.com>
Tue, 18 Dec 2007 16:37:11 +0000 (16:37 +0000)
committerMarko Kreen <markokr@gmail.com>
Tue, 18 Dec 2007 16:37:11 +0000 (16:37 +0000)
src/cluster.c
src/main.c

index 0379611735b47348133d719b468f89c571b25f22..3cd892a54c14b3fde2b03d5f14aa4ef41d71b210 100644 (file)
@@ -92,35 +92,40 @@ plproxy_cluster_cache_init(void)
 static void
 plproxy_cluster_plan_init(void)
 {
-       void       *plan;
+       void       *tmp_ver_plan, *tmp_part_plan, *tmp_conf_plan;
        Oid                     types[] = {TEXTOID};
        static int      init_done = 0;
 
        if (init_done)
                return;
-       init_done = 1;
 
        /*
         * prepare plans for fetching configuration.
         */
 
-       plan = SPI_prepare(version_sql, 1, types);
-       if (plan == NULL)
-               plproxy_error(NULL, "VERSION_SQL: %s",
-                                         SPI_result_code_string(SPI_result));
-       version_plan = SPI_saveplan(plan);
-
-       plan = SPI_prepare(part_sql, 1, types);
-       if (plan == NULL)
-               plproxy_error(NULL, "PART_SQL: %s",
-                                         SPI_result_code_string(SPI_result));
-       partlist_plan = SPI_saveplan(plan);
-
-       plan = SPI_prepare(config_sql, 1, types);
-       if (plan == NULL)
-               plproxy_error(NULL, "CONFIG_SQL: %s",
-                                         SPI_result_code_string(SPI_result));
-       config_plan = SPI_saveplan(plan);
+       tmp_ver_plan = SPI_prepare(version_sql, 1, types);
+       if (tmp_ver_plan == NULL)
+               elog(ERROR, "PL/Proxy: plproxy.get_cluster_version() SQL fails: %s",
+                        SPI_result_code_string(SPI_result));
+
+       tmp_part_plan = SPI_prepare(part_sql, 1, types);
+       if (tmp_part_plan == NULL)
+               elog(ERROR, "PL/Proxy: plproxy.get_cluster_partitions() SQL fails: %s",
+                        SPI_result_code_string(SPI_result));
+
+       tmp_conf_plan = SPI_prepare(config_sql, 1, types);
+       if (tmp_conf_plan == NULL)
+               elog(ERROR, "PL/Proxy: plproxy.get_cluster_config() SQL fails: %s",
+                        SPI_result_code_string(SPI_result));
+
+       /*
+        * Store them only if all successful.
+        */
+       version_plan = SPI_saveplan(tmp_ver_plan);
+       partlist_plan = SPI_saveplan(tmp_part_plan);
+       config_plan = SPI_saveplan(tmp_conf_plan);
+
+       init_done = 1;
 }
 
 /*
index fdeb99c02df99e3af1147fb80ab3cd4768b837a1..0b92ee0442a1cf4f4817f4d0e8f2768ab30e9bf1 100644 (file)
@@ -75,11 +75,8 @@ plproxy_error(ProxyFunction *func, const char *fmt,...)
 
        plproxy_clean_results(func->cur_cluster);
 
-       if (func)
-               elog(ERROR, "PL/Proxy function %s(%d): %s",
-                        func->name, func->arg_count, msg);
-       else
-               elog(ERROR, "PL/Proxy error: %s", msg);
+       elog(ERROR, "PL/Proxy function %s(%d): %s",
+                func->name, func->arg_count, msg);
 }
 
 /*