From 7d6d641ef187cd12f2c7ee0ea207e82c5a4a05d2 Mon Sep 17 00:00:00 2001 From: pylSER Date: Tue, 3 Aug 2021 11:10:03 +0800 Subject: [PATCH] fix list error rt_fetch starts with index 1 instead of 0 --- pg_extension/bao_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg_extension/bao_util.h b/pg_extension/bao_util.h index 1368909c..7d019a8d 100755 --- a/pg_extension/bao_util.h +++ b/pg_extension/bao_util.h @@ -76,7 +76,7 @@ static bool should_bao_optimize(Query* parse) { if (parse->commandType != CMD_SELECT) return false; // Iterate over all the relations in this query. - for (int i = 0; i < list_length(parse->rtable); i++) { + for (int i = 1; i <= list_length(parse->rtable); i++) { relid = rt_fetch(i, parse->rtable)->relid; // A relid of zero seems to have a special meaning, and it causes // get_rel_namespace or get_namespace_name to crash. Relid of zero