-> Index Scan using t2_pkey on t2
(4 rows)
+/*+SeqScan() */ SELECT 1;
+INFO: pg_hint_plan: hint syntax error at or near " "
+DETAIL: SeqScan hint requires a relation.
+LOG: pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+SeqScan()
+
+ ?column?
+----------
+ 1
+(1 row)
+
/*+SeqScan(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
INFO: pg_hint_plan: hint syntax error at or near ""
Index Cond: (id = t1.id)
(5 rows)
+/*+ NestLoop() */ SELECT 1;
+INFO: pg_hint_plan: hint syntax error at or near " "
+DETAIL: NestLoop hint requires at least two relations.
+LOG: pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop()
+
+ ?column?
+----------
+ 1
+(1 row)
+
+/*+ NestLoop(x) */ SELECT 1;
+INFO: pg_hint_plan: hint syntax error at or near " "
+DETAIL: NestLoop hint requires at least two relations.
+LOG: pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop(x)
+
+ ?column?
+----------
+ 1
+(1 row)
+
/*+HashJoin(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
LOG: pg_hint_plan:
-- Explain result includes "Planning time" if COSTS is enabled, but
-- this test needs it enabled for get rows count. So do tests via psql
-- and grep -v the mutable line.
+-- Parse error check
+/*+ Rows() */ SELECT 1;
+INFO: pg_hint_plan: hint syntax error at or near " "
+DETAIL: Rows hint needs at least one relation followed by one correction term.
+LOG: pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Rows()
+
+ ?column?
+----------
+ 1
+(1 row)
+
+/*+ Rows(x) */ SELECT 1;
+INFO: pg_hint_plan: hint syntax error at or near " "
+DETAIL: Rows hint needs at least one relation followed by one correction term.
+LOG: pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Rows()
+
+ ?column?
+----------
+ 1
+(1 row)
+
-- value types
\o results/pg_hint_plan.tmpout
EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
quote_value(buf, hint->relnames[i]);
}
}
- appendStringInfo(buf, " %s", hint->rows_str);
+ if (hint->rows_str != NULL)
+ appendStringInfo(buf, " %s", hint->rows_str);
appendStringInfoString(buf, ")");
if (!nolf)
appendStringInfoChar(buf, '\n');
List *name_list = NIL;
char *rows_str;
char *end_ptr;
+ ListCell *l;
+ int i = 0;
if ((str = parse_parentheses(str, &name_list, hint_keyword)) == NULL)
return NULL;
/* Last element must be rows specification */
hint->nrels = list_length(name_list) - 1;
- if (hint->nrels > 0)
+ if (hint->nrels < 1)
{
- ListCell *l;
- int i = 0;
+ hint_ereport(str,
+ ("%s hint needs at least one relation followed by one correction term.",
+ hint->base.keyword));
+ hint->base.state = HINT_STATE_ERROR;
- /*
- * Transform relation names from list to array to sort them with qsort
- * after.
- */
- hint->relnames = palloc(sizeof(char *) * hint->nrels);
- foreach (l, name_list)
- {
- if (hint->nrels <= i)
- break;
- hint->relnames[i] = lfirst(l);
- i++;
- }
+ return str;
+ }
+
+
+ /*
+ * Transform relation names from list to array to sort them with qsort
+ * after.
+ */
+ hint->relnames = palloc(sizeof(char *) * hint->nrels);
+ foreach (l, name_list)
+ {
+ if (hint->nrels <= i)
+ break;
+ hint->relnames[i] = lfirst(l);
+ i++;
}
/* Retieve rows estimation */
/*+Set(work_mem TO "1MB")*/
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
+/*+SeqScan() */ SELECT 1;
/*+SeqScan(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
/*+SeqScan(t1)*/
/*+NoTidScan(t1)*/
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)';
+/*+ NestLoop() */ SELECT 1;
+/*+ NestLoop(x) */ SELECT 1;
/*+HashJoin(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
/*+NestLoop(t1 t2)*/
-- this test needs it enabled for get rows count. So do tests via psql
-- and grep -v the mutable line.
+-- Parse error check
+/*+ Rows() */ SELECT 1;
+/*+ Rows(x) */ SELECT 1;
+
-- value types
\o results/pg_hint_plan.tmpout
EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);