Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 3E9AE9FB264 for ; Fri, 24 Nov 2006 15:06:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 56771-07 for ; Fri, 24 Nov 2006 19:06:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by postgresql.org (Postfix) with ESMTP id 2D2029FB1DA for ; Fri, 24 Nov 2006 15:05:52 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id CA6D5353D8; Fri, 24 Nov 2006 11:05:49 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C406C353CB; Fri, 24 Nov 2006 11:05:49 -0800 (PST) Date: Fri, 24 Nov 2006 11:05:48 -0800 (PST) From: Stephan Szabo To: Marcelo Costa Cc: pgsql-admin@postgresql.org Subject: Re: Function ERRO after UPGRADE from 7.4 to 8.1.5 In-Reply-To: Message-ID: <20061124110401.H11828@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/210 X-Sequence-Number: 23737 On Fri, 24 Nov 2006, Marcelo Costa wrote: > Hi, all > > I migrate my database from 7.4 to 8.1.5 and make tests with aplication > but this don=B4t works fine. > > Some trigers don=B4t work and send to me error messages as this: > > Warning: pg_query(): Query failed: ERROR: INSERT is not allowed in a > non-volatile > function CONTEXT: SQL statement "insert into > ave.ave_aluno_avaliacao_diario_historico ( > codigo_ave_avaliacao , codigo_ave_aluno_caderneta , nota , presenca , fal= ta , > data_cadastro , justificativa , codigo_usuario ) select codigo_ave_avalia= cao , > codigo_ave_aluno_caderneta , nota , presenca , falta , data_cadastro , > justificativa , > codigo_usuario from ave.ave_aluno_avaliacao_diario where > codigo_ave_aluno_caderneta =3D $1 and codigo_ave_avaliacao =3D $2 " > PL/pgSQL function > "func_trg_ave_aluno_avaliacao_diario_a_iu" line 16 at SQL statement in...= (...) > > I see all trigers including func_trg_ave_aluno_avaliacao_diario_a_iu > and compile this but no erros send to me. > > Anybory can help me or send to me any link to that it can clarify. This looks to be from the following change in the 8.0 release notes: "Functions declared STABLE or IMMUTABLE always use the snapshot of the calling query, and therefore do not see the effects of actions taken after the calling query starts, whether in their own transaction or other transactions. Such a function must be read-only, too, meaning that it cannot use any SQL commands other than SELECT." You probably will need to redefine the functions to be volatile if they're currently stable or immutable.