• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revisionde7600e460d1f773cb6e4a8ff1b1a96668b84307 (tree)
Time2020-02-17 13:43:13
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
@@ -2868,9 +2868,7 @@ get_current_hint_string(ParseState *pstate, Query *query)
28682868 */
28692869 query_len = strlen(query_str) + 1;
28702870 normalized_query =
2871- generate_normalized_query(&jstate, query_str,
2872- query->stmt_location,
2873- &query_len,
2871+ generate_normalized_query(&jstate, query_str, 0, &query_len,
28742872 GetDatabaseEncoding());
28752873
28762874 /*
--- 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