summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbbas2011-09-05 15:46:19 +0000
committerAbbas2011-09-05 15:46:19 +0000
commit1d2801f818da73e0c73be4db281ab96beb628c9d (patch)
tree97a9ccc5ae6039ffcbd87a2abec04a3de7f09997
parent76fb1e06d9eef7d0cdb9870b720c8eec10b38865 (diff)
In case of tables created with round robin distribution the function get_plan_nodes_insert was trying to use an un-initialized local variable named constant.
Added a test case and changed the expected output too
-rw-r--r--src/backend/pgxc/plan/planner.c8
-rw-r--r--src/test/regress/expected/xc_distkey.out12
-rw-r--r--src/test/regress/sql/xc_distkey.sql7
3 files changed, 23 insertions, 4 deletions
diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c
index 12a993cb72..2515e3fd77 100644
--- a/src/backend/pgxc/plan/planner.c
+++ b/src/backend/pgxc/plan/planner.c
@@ -531,7 +531,7 @@ get_plan_nodes_insert(PlannerInfo *root, RemoteQuery *step)
Query *query = root->parse;
RangeTblEntry *rte;
RelationLocInfo *rel_loc_info;
- Const *constant;
+ Const *constant = NULL;
ListCell *lc;
Expr *eval_expr = NULL;
@@ -707,8 +707,10 @@ get_plan_nodes_insert(PlannerInfo *root, RemoteQuery *step)
}
}
- /* single call handles both replicated and partitioned types */
- step->exec_nodes = GetRelationNodes(rel_loc_info, constant->constvalue, constant->consttype, RELATION_ACCESS_INSERT);
+ if (constant == NULL)
+ step->exec_nodes = GetRelationNodes(rel_loc_info, 0, InvalidOid, RELATION_ACCESS_INSERT);
+ else
+ step->exec_nodes = GetRelationNodes(rel_loc_info, constant->constvalue, constant->consttype, RELATION_ACCESS_INSERT);
if (eval_expr)
pfree(eval_expr);
diff --git a/src/test/regress/expected/xc_distkey.out b/src/test/regress/expected/xc_distkey.out
index e05fe7eb89..461f779e2b 100644
--- a/src/test/regress/expected/xc_distkey.out
+++ b/src/test/regress/expected/xc_distkey.out
@@ -103,8 +103,8 @@ insert into vc_tab values(NULL);
select * from vc_tab order by a;
a
----------------------------
- A quick brown fox
abcdefghijklmnopqrstuvwxyz
+ A quick brown fox
(3 rows)
@@ -616,3 +616,13 @@ select * from tstz_tab_h where a = 'Jun 23, 2001 23:59:59.99 PST';
Sun Jun 24 00:59:59.99 2001 PDT
(1 row)
+create table my_rr_tab(a integer, b varchar(100)) distribute by round robin;
+insert into my_rr_tab values(1 , 'One');
+insert into my_rr_tab values(2, 'Two');
+select * from my_rr_tab order by a;
+ a | b
+---+-----
+ 1 | One
+ 2 | Two
+(2 rows)
+
diff --git a/src/test/regress/sql/xc_distkey.sql b/src/test/regress/sql/xc_distkey.sql
index 8650718d32..b57502d26f 100644
--- a/src/test/regress/sql/xc_distkey.sql
+++ b/src/test/regress/sql/xc_distkey.sql
@@ -243,3 +243,10 @@ select * from tstz_tab_h order by a;
select * from tstz_tab_h where a = 'May 10, 2011 00:01:02.03 PST';
select * from tstz_tab_h where a = 'Jun 23, 2001 23:59:59.99 PST';
+
+create table my_rr_tab(a integer, b varchar(100)) distribute by round robin;
+insert into my_rr_tab values(1 , 'One');
+insert into my_rr_tab values(2, 'Two');
+
+select * from my_rr_tab order by a;
+