From: Pavan Deolasee Date: Tue, 4 Oct 2016 07:50:45 +0000 (+0530) Subject: Fix an oversight in a5b53b0dda52 where we failed to track whether parameter X-Git-Tag: XL9_5_R1_4~10 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=b899b6c0126b54c698caa9ee99b428a25d360a6c;p=postgres-xl.git Fix an oversight in a5b53b0dda52 where we failed to track whether parameter value has been computed or not at all places Report and test case by Agoston David --- diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 1aeff9e7f8..406e32d4f7 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -218,6 +218,7 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags) prmdata->value = extparams->params[i].value; prmdata->isnull = extparams->params[i].isnull; prmdata->ptype = extparams->params[i].ptype; + prmdata->done = true; } /* * Truncate exec parameters from the list of received parameters @@ -2850,6 +2851,8 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree) parentestate->es_param_exec_vals[i].value; estate->es_param_exec_vals[i].isnull = parentestate->es_param_exec_vals[i].isnull; + estate->es_param_exec_vals[i].done = + parentestate->es_param_exec_vals[i].done; } } diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out index 40b1577b87..e39e4d65ab 100644 --- a/src/test/regress/expected/subselect.out +++ b/src/test/regress/expected/subselect.out @@ -901,3 +901,83 @@ select nextval('ts1'); 11 (1 row) +SELECT setseed(0); + setseed +--------- + +(1 row) + +-- DROP TABLE IF EXISTS asd ; +CREATE TABLE IF NOT EXISTS asd AS +SELECT clientid::numeric(20), + (clientid / 20 )::integer::numeric(20) as userid, + cts + ((random()* 3600 *24 )||'sec')::interval as cts, + (ARRAY['A','B','C','D','E','F'])[(random()*5+1)::integer] as state, + 0 as dim, + ((ARRAY['Cat','Dog','Duck'])[(clientid / 10 )% 3 +1 ]) ::text as app_name, + md5(random()::text) as new_value, + ((ARRAY['A','B'])[(clientid / 10 )% 2 +1 ]) ::text as platform + FROM generate_series('2016-01-01'::timestamp,'2016-10-01'::timestamp,interval '15 day') cts , generate_series( 1000,2000,10) clientid , generate_series(1,6) t +ORDER BY new_value +; +SELECT dates::timestamp as dates ,B.platform,B.app_name, B.clientid, B.userid, + B.cts, B.state as state, + B.new_value +FROM ( VALUES +('2016.08.30. 08:52:43') ,('2016.08.29. 04:57:12') ,('2016.08.26. 08:15:05') , +('2016.08.24. 11:49:51') ,('2016.08.22. 08:45:29') ,('2016.08.21. 04:53:47') ,('2016.08.20. 08:44:03') +) AS D (dates) +JOIN +( SELECT DISTINCT clientid FROM asd + WHERE userid=74 ) C ON True +INNER JOIN LATERAL ( + SELECT DISTINCT ON (clientid,app_name,platform,state,dim) x.* + FROM asd x + INNER JOIN (SELECT p.clientid,p.app_name,p.platform , p.state, p.dim , + MAX(p.cts) AS selected_cts + FROM asd p + where cts