Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fuzJi-0007xA-GZ for pgsql-general@arkaria.postgresql.org; Wed, 29 Aug 2018 12:11:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fuzJg-0004qx-Qh for pgsql-general@arkaria.postgresql.org; Wed, 29 Aug 2018 12:11:20 +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.89) (envelope-from ) id 1fuzJg-0004qp-J4 for pgsql-general@lists.postgresql.org; Wed, 29 Aug 2018 12:11:20 +0000 Received: from 9v6.net-wizard.org ([2a01:4f8:172:2a5c::9] helo=gandalf.net-wizard.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fuzJc-00068d-8l for pgsql-general@postgresql.org; Wed, 29 Aug 2018 12:11:19 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id 378E380DBF; Wed, 29 Aug 2018 14:11:14 +0200 (CEST) X-Virus-Scanned: Gentoo amavisd-new at aragorn Received: from aragorn.net-wizard.org ([127.0.0.1]) by localhost (aragorn.net-wizard.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5a1lo42Hf4xv; Wed, 29 Aug 2018 14:11:10 +0200 (CEST) Received: from MTEC0211 (mtec-lee-dock-2-133.ethz.ch [129.132.6.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: clavadetscher@swisspug.org) by gandalf.net-wizard.org (Postfix) with ESMTPSA id 79D7180DBB; Wed, 29 Aug 2018 14:11:06 +0200 (CEST) From: "Charles Clavadetscher" To: "'TalGloz'" , References: <1535533938898-0.post@n3.nabble.com> <019001d43f86$11742960$345c7c20$@swisspug.org> <1535541719123-0.post@n3.nabble.com> In-Reply-To: <1535541719123-0.post@n3.nabble.com> Subject: RE: Executing a Function with an INSERT INTO command fails Date: Wed, 29 Aug 2018 14:10:59 +0200 Message-ID: <019e01d43f91$5f3c4460$1db4cd20$@swisspug.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQJVxWXjLOJe92ub2y92injx2xA7XAMzTC3yAXvl5vejrhX18A== Content-Language: de-ch List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi > -----Original Message----- > From: TalGloz [mailto:glozmantal@gmail.com] > Sent: Mittwoch, 29. August 2018 13:22 > To: pgsql-general@postgresql.org > Subject: RE: Executing a Function with an INSERT INTO command fails >=20 > Charles Clavadetscher wrote > > Do you get any error? >=20 > The function executes perfectly and does what it's supposed to except = of the INSERT INTO part. I don't get any > errors. >=20 >=20 > > Does the select deliver any result at all? >=20 > Yes, booth SELECT deliver everything they supposed to. >=20 >=20 > > If yes, is there maybe already a trigger on table > > public.runtime_benchmark? >=20 > I didn=E2=80=99t crate any triggers for the table manually and I don't = think they are crated automatically. >=20 >=20 > > If not, is there maybe a policy on either public.nyc2015_09_enc or > > public.runtime_benchmark? >=20 > There are no security policy on any of them, at least I didn't set any = while creating the tables with PgAdmin4. > I use the tables on a local server for testing purposes only. >=20 >=20 > > If not, could you provide more information on the table? >=20 > What kind of information should I provide? The point is to try to reproduce the problem. So the table definition as = delivered by \d would be a good starting point. Or the CREATE TABLE = generated by pgAdmin. While I was having a closer look at the function I noticed that you call = another function to populate the sealArray. In order to try to reproduce the error I did: Create public.nyc2015_09_enc on assumptions and populate it with some = data. CREATE TABLE public.nyc2015_09_enc ( id INTEGER, "Pickup_longitude" TEXT, "Dropoff_longitude" TEXT ); INSERT INTO public.nyc2015_09_enc VALUES (1,'47.0','8.0'); INSERT INTO public.nyc2015_09_enc VALUES (2,'49.0','8.5'); SELECT * FROM public.nyc2015_09_enc; id | Pickup_longitude | Dropoff_longitude ----+------------------+------------------- 1 | 47.0 | 8.0 2 | 49.0 | 8.5 (2 rows) Create public.runtime_benchmark based on assuptions. CREATE TABLE public.runtime_benchmark ( test_number INTEGER, column_names TEXT, execution_time TEXT, operation_type TEXT, seal_or_sql TEXT ); Create your function. The sealArray creation is modified, because I = don't know how the function public.seal_diff_benchmark is defined. CREATE OR REPLACE FUNCTION seal_diff_benchmark_pgsql(sealparams = CHARACTER VARYING) RETURNS SETOF TEXT AS $outputVar$ DECLARE tempVar1 CHARACTER VARYING; tempVar2 CHARACTER VARYING; outputVar text; sealArray TEXT[]; outputArray TEXT[]; BEGIN FOR i IN 1..2 LOOP SELECT "Pickup_longitude", "Dropoff_longitude" INTO tempVar1, = tempVar2 FROM public.nyc2015_09_enc WHERE id=3Di; --sealArray :=3D (SELECT public.seal_diff_benchmark(tempVar1, = tempVar2, sealparams)); sealArray :=3D ARRAY[tempVar1, tempVar2, sealparams]; outputArray[i] :=3D sealArray[1]; INSERT INTO public.runtime_benchmark (test_number, = column_names, execution_time, operation_type, seal_or_sql) VALUES (1, = 'Pickup_longitude, Dropoff_longitude', sealArray[2], 'sub', 'seal'); END LOOP; FOREACH outputVar IN ARRAY outputArray LOOP RETURN NEXT outputVar; END LOOP; END; $outputVar$ LANGUAGE plpgsql; Is there any reason for the loop 1..2? And test it. SELECT * FROM public.runtime_benchmark ; test_number | column_names | execution_time | operation_type | = seal_or_sql -------------+--------------+----------------+----------------+----------= --- (0 rows) SELECT * FROM seal_diff_benchmark_pgsql('0.12'); seal_diff_benchmark_pgsql --------------------------- 47.0 49.0 (2 rows) SELECT * FROM public.runtime_benchmark ; test_number | column_names | execution_time | = operation_type | seal_or_sql -------------+-------------------------------------+----------------+----= ------------+------------- 1 | Pickup_longitude, Dropoff_longitude | 8.0 | = sub | seal 1 | Pickup_longitude, Dropoff_longitude | 8.5 | = sub | seal (2 rows) Unfortunately I am not able to reproduce the problem, but maybe with the = table and functions definitions, as well as the 2 data rows that are = selected in the function, is that easier to analyze. Regards Charles > Best regards, > Tal >=20 >=20 >=20 > -- > Sent from: = http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html