diff options
author | Michael Paquier | 2012-10-05 01:40:15 +0000 |
---|---|---|
committer | Michael Paquier | 2012-10-05 01:40:15 +0000 |
commit | 5ccf23fc829af560f4ddb325e0a6f5eacfdfd10c (patch) | |
tree | 92d976513e17064f2b1ee4691f16cf74257a0347 | |
parent | 92ffb0f81c9f73f4b07b5e375f5541d92180576e (diff) |
Fix crash when COPY involves relation with no locator data
Patch and report from Nikhil Sontakke. I added a test case in xc_copy and
some comments.
-rw-r--r-- | src/backend/pgxc/copy/remotecopy.c | 9 | ||||
-rw-r--r-- | src/test/regress/input/xc_copy.source | 5 | ||||
-rw-r--r-- | src/test/regress/output/xc_copy.source | 5 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/backend/pgxc/copy/remotecopy.c b/src/backend/pgxc/copy/remotecopy.c index 9c8c3b0d82..23db6ecdd7 100644 --- a/src/backend/pgxc/copy/remotecopy.c +++ b/src/backend/pgxc/copy/remotecopy.c @@ -29,14 +29,16 @@ static void RemoteCopy_QuoteIdentifier(StringInfo query_buf, char *value); /* * RemoteCopy_GetRelationLoc - * Get relation node list based on COPY data involved + * Get relation node list based on COPY data involved. An empty list is + * returned to caller if relation involved has no locator information + * as it is the case of a system relation. */ void RemoteCopy_GetRelationLoc(RemoteCopyData *state, Relation rel, List *attnums) { - ExecNodes *exec_nodes = makeNode(ExecNodes); + ExecNodes *exec_nodes = NULL; /* * If target table does not exists on nodes (e.g. system table) @@ -52,6 +54,7 @@ RemoteCopy_GetRelationLoc(RemoteCopyData *state, * This case corresponds to a replicated table with COPY TO * */ + exec_nodes = makeNode(ExecNodes); if (!state->is_from && IsLocatorReplicated(state->rel_loc->locatorType)) exec_nodes->nodeList = GetPreferredReplicationNode(state->rel_loc->nodeList); @@ -63,7 +66,7 @@ RemoteCopy_GetRelationLoc(RemoteCopyData *state, } state->idx_dist_by_col = -1; - if (state->rel_loc->partAttrNum != 0) + if (state->rel_loc && state->rel_loc->partAttrNum != 0) { /* * Find the column used as key for data distribution. diff --git a/src/test/regress/input/xc_copy.source b/src/test/regress/input/xc_copy.source index d0e395c7f5..cf08efe74d 100644 --- a/src/test/regress/input/xc_copy.source +++ b/src/test/regress/input/xc_copy.source @@ -109,3 +109,8 @@ COPY "Xc_copy_2" FROM STDIN DELIMITER ','; \. COPY "Xc_copy_2" TO STDOUT; DROP TABLE "Xc_copy_2"; + +-- Table with no locator data +CREATE TABLE xc_copy_3 (c1 int) DISTRIBUTE BY HASH(c1); +COPY (SELECT pclocatortype,pcattnum,pchashalgorithm,pchashbuckets FROM pgxc_class WHERE pgxc_class.pcrelid = 'xc_copy_3'::regclass) TO stdout; +DROP TABLE xc_copy_3; diff --git a/src/test/regress/output/xc_copy.source b/src/test/regress/output/xc_copy.source index ddc5221d35..1defee54d2 100644 --- a/src/test/regress/output/xc_copy.source +++ b/src/test/regress/output/xc_copy.source @@ -108,3 +108,8 @@ COPY "Xc_copy_2" TO STDOUT; 1 2 3 4 DROP TABLE "Xc_copy_2"; +-- Table with no locator data +CREATE TABLE xc_copy_3 (c1 int) DISTRIBUTE BY HASH(c1); +COPY (SELECT pclocatortype,pcattnum,pchashalgorithm,pchashbuckets FROM pgxc_class WHERE pgxc_class.pcrelid = 'xc_copy_3'::regclass) TO stdout; +H 1 1 4096 +DROP TABLE xc_copy_3; |