• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision788cf4b133728f7a4c1e521ba135a7cd9fb777aa (tree)
Time2020-02-17 13:45:33
AuthorKyotaro Horiguchi <horikyota.ntt@gmai...>
CommiterKyotaro Horiguchi

Log Message

Give correct query location to generate_normalized_query.

There was a thinko about query_loc of generate_normalized_query which
causes a crash. For example a query is following a sequence of
semicolons (by \; in psql input) longer than the length after the last
placeholder to the end of the query, the function causes assertion
failure. Anyway prepared statements lose that value so we just pass 0
as the query_loc for consistent behavior.

Change Summary

Incremental Difference

--- a/expected/ut-T.out
+++ b/expected/ut-T.out
@@ -127,5 +127,12 @@ error hint:
127127 (2 rows)
128128
129129 DEALLOCATE p1;
130+-- Check proper calling to generate_normalized_query
131+\;\;SELECT 1,2;
132+ ?column? | ?column?
133+----------+----------
134+ 1 | 2
135+(1 row)
136+
130137 SET pg_hint_plan.enable_hint_table to off;
131138 DELETE FROM hint_plan.hints;
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -2873,9 +2873,7 @@ get_current_hint_string(ParseState *pstate, Query *query)
28732873 */
28742874 query_len = strlen(query_str) + 1;
28752875 normalized_query =
2876- generate_normalized_query(&jstate, query_str,
2877- query->stmt_location,
2878- &query_len,
2876+ generate_normalized_query(&jstate, query_str, 0, &query_len,
28792877 GetDatabaseEncoding());
28802878
28812879 /*
--- a/sql/ut-T.sql
+++ b/sql/ut-T.sql
@@ -41,5 +41,9 @@ EXPLAIN CREATE TABLE ct1 AS EXECUTE p1;
4141
4242 DEALLOCATE p1;
4343
44+-- Check proper calling to generate_normalized_query
45+\;\;SELECT 1,2;
46+
4447 SET pg_hint_plan.enable_hint_table to off;
4548 DELETE FROM hint_plan.hints;
49+
Show on old repository browser