greenplum-db/plcontainer

PL/Container crashed when convert R data.frame to text[]

HaozhouWang opened this issue · 2 comments

Function:

 create or replace function test_dta() returns text[] as
$$
# container:  plc_r_shared
as.data.frame(array(1:10,c(2,5)))
$$ language plcontainer;

Output:

select test_dta();
ERROR:  plcontainer: Error receiving data from the client. Maybe retry later. (plcontainer.c:336)
CONTEXT:  PLContainer function "test_dta"

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

The root cause of this issue is that when RClient returns the result as a text[], it assumes that the returning value of the R function is a string and uses STRING_ELT() to access its elements. However, for this R function, this is not true since the return value is a data.frame. Thus, using STRING_ELT() would cause a type error and crash RClient.