OSDN Git Service

Fix a bug of plan string inflation
authorKyotaro Horiguchi <horikyota.ntt@gmail.com>
Thu, 30 Jan 2020 07:42:09 +0000 (16:42 +0900)
committerKyotaro Horiguchi <horikyota.ntt@gmail.com>
Fri, 31 Jan 2020 01:47:35 +0000 (10:47 +0900)
pg_store_plans() gave the length of raw plan string to encoding
function. Queries on the pg_store_plans view gets ERROR when (a)
inflated string contained unprintable byte sequence after the raw
length, or (b) the inflation made a string shorter. Fixed it.

pg_store_plans.c

index be5871e..e15c1be 100644 (file)
@@ -1189,7 +1189,7 @@ pg_store_plans(PG_FUNCTION_ARGS)
                        
                        estr = (char *)
                                pg_do_encoding_conversion((unsigned char *) pstr,
-                                                                                 entry->plan_len,
+                                                                                 strlen(pstr),
                                                                                  entry->key.encoding,
                                                                                  GetDatabaseEncoding());
                        values[i++] = CStringGetTextDatum(estr);