Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id E676B632A88 for ; Thu, 22 Oct 2009 11:34:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 26692-03 for ; Thu, 22 Oct 2009 14:34:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cirrus.hsolutions.ch (cirrus.hsolutions.ch [212.203.66.103]) by mail.postgresql.org (Postfix) with ESMTP id 34C9E634822 for ; Thu, 22 Oct 2009 11:34:12 -0300 (ADT) Received: from [192.168.32.120] (unknown [78.234.64.238]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cirrus.hsolutions.ch (Postfix) with ESMTPSA id 0110A880003; Thu, 22 Oct 2009 16:39:02 +0200 (CEST) Message-ID: <4AE06D5D.4020908@hsolutions.ch> Date: Thu, 22 Oct 2009 16:34:05 +0200 From: Denis BUCHER Organization: Horus Digital Solutions =?ISO-8859-1?Q?S=E0rl?= User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Richard Huxton CC: pgsql-sql@postgresql.org Subject: Re: Problem with return type of function ??? References: <4AE042AF.9020507@hsolutions.ch> <4AE044C6.8010306@archonet.com> <4AE046B7.5070805@hsolutions.ch> <4AE05DD0.7010809@archonet.com> <4AE05E55.4000500@hsolutions.ch> <4AE06221.5040403@archonet.com> <4AE0655C.80400@hsolutions.ch> <4AE06A75.3040803@archonet.com> In-Reply-To: <4AE06A75.3040803@archonet.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/104 X-Sequence-Number: 33303 Richard Huxton a écrit : >>> The other thing you could try is printing out row before returning it: >>> RAISE NOTICE 'row = %', row; >>> RETURN NEXT ROW; >>> It might be you've not got what you were expecting. >> Thanks a lot, good idea... >> >> But it looks good : > > Hmm... > >>> SELECT * FROM rma.test ('19G256259'); >>> NOTICE: row = (12066602,19G256259,170224,PN6405B,2009-09-22,"FORERUNNER 405 NOIR",2009-09-22,15090,14748) >>> ERREUR: wrong record type supplied in RETURN NEXT >>> CONTEXTE : PL/pgSQL function "test" line 12 at return next >>> >>> \d rma.serial_number >>> Table « rma.serial_number » >>> Colonne | Type | Modificateurs >>> -------------+-----------------------+------------------------------------------------------------------- >>> sn_id | bigint | not null default nextval('rma.serial_number_sn_id_seq'::regclass) >>> sn | character varying(30) | >>> no_client | integer | >>> no_art_bw | character varying(11) | >>> sn_fc_date | date | >>> desc_fr | character varying(40) | >>> sn_cm_date | date | >>> no_facture | integer | >>> no_commande | integer | > > I was wondering if maybe there was a bug to do with domains or complex > column types, but there's nothing out of the ordinary here. Yes... > OK - can you generate a test script with just CREATE TABLE, CREATE > FUNCTION, one INSERT and a function-call? I'll try and recreate it here. > Oh, and what version of PostgreSQL are we talking about? > Bienvenue dans psql 8.1.17, l'interface interactive de PostgreSQL. OK I prepared what you asked and I tested it myself before sending. And I think I've found the problem (but not the solution !) : When I dump the FUNCTION, I get this : > CREATE test(character varying) RETURNS SETOF serial_number instead of this : > CREATE test(character varying) RETURNS SETOF rma.serial_number That seems to be some bug in Postgres ? The problem is then clear, it doesn't take SETOF rma.serial_number but SETOF public.serial_number Do you see how we could solve this ? And do you think this is the problem ? Thanks a lot again for all your help ! Denis