OSDN Git Service

メモリの割り当てをpallocからSPI_pallocに修正した。
authorRyohei OKADA <okada.ryohei@metrosystems.co.jp>
Mon, 10 Jun 2013 10:15:34 +0000 (19:15 +0900)
committerRyohei OKADA <okada.ryohei@metrosystems.co.jp>
Mon, 10 Jun 2013 10:15:34 +0000 (19:15 +0900)
SPI_connectによって作成されたコンテキスト内で、pallocでメモリを割り当てても
SPI_finishで接続が切断された時に解放され使用することができなくなってしまう。
SPI_pallocだと上位のコンテキスト内にメモリを割り当ててくれる。

pg_hint_plan.c

index f8992e4..e6f2127 100644 (file)
@@ -1376,9 +1376,8 @@ get_hints_from_table(const char *client_query, const char *client_application)
 
                hints = pstrdup(SPI_getvalue(SPI_tuptable->vals[0],
                                                                           SPI_tuptable->tupdesc, 1));
-
                len = strlen(hints);
-               buf = palloc(len + 1);
+               buf = SPI_palloc(len + 1);
                memcpy(buf, hints, len);
                buf[len] = '\0';
                hints = buf;
@@ -2135,7 +2134,7 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
         * XXX: use something instead of debug_query_string?
         */
        hints = get_hints_from_table(query, application_name);
-       elog(LOG,
+       elog(DEBUG1,
                 "pg_hint_plan: get_hints_from_table [%s][%s]=>[%s]",
                 query, application_name,
                 hints ? hints : "(none)");