Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a69NZ-0000Z0-PM for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Dec 2015 03:55:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a69NY-0001BT-EZ for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Dec 2015 03:55:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a69Mv-0000UZ-Kc for pgsql-bugs@postgresql.org; Tue, 08 Dec 2015 03:55:13 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1a69Mm-0001Ry-OU for pgsql-bugs@postgresql.org; Tue, 08 Dec 2015 03:55:12 +0000 MIME-Version: 1.0 Subject: BUG #13805: plpgsql execute using expression evaluate wrong To: pgsql-bugs@postgresql.org From: amutu@amutu.com Date: Tue, 08 Dec 2015 03:54:44 +0000 Message-ID: <20151208035444.5253.30717@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13805 Logged by: Jov Email address: amutu@amutu.com PostgreSQL version: 9.4.5 Operating system: CentOS 6 Description: test case: CREATE OR REPLACE FUNCTION public.test() RETURNS void LANGUAGE plpgsql AS $function$ declare n int = 4; rt timestamp[]; rt2 interval; begin execute $$select array_agg(g.i) from generate_series(now() - ('$1 month')::interval,now(),'1 month') g(i)$$ into r t using n; raise notice 'rt : %',rt; execute $$select array_agg(g.i) from generate_series(now() - ($1::varchar || ' month')::interval,now(),'1 month') g(i)$$ into rt using n; raise notice 'rt : %',rt; execute $$select ('$1 month')::interval $$ into rt2 using n; raise notice 'rt2 : %',rt2; execute $$select ($1::varchar || ' month')::interval $$ into rt2 using n; raise notice 'rt2 : %',rt2; end; $function$ ~ ~ No changes db_001=# select * from test(); NOTICE: rt : {"2015-11-08 11:46:28.500811","2015-12-08 11:46:28.500811"}-----wrong answer,should 4 elements NOTICE: rt : {"2015-08-08 11:46:28.500811","2015-09-08 11:46:28.500811","2015-10-08 11:46:28.500811","2015-11-08 11:46:28.500811","2015-12-08 11:46:28.500811"} NOTICE: rt2 : 1 mon-----wrong,should 4 mons NOTICE: rt2 : 4 mons test ------ (1 row) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs