RE: ERROR: can't read "tgname": no such variable

From: Ramón Alberto Bruening González <albertobruening(at)hotmail(dot)com>
To: <cesar(dot)carbonara(at)gmail(dot)com>
Cc: <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: RE: ERROR: can't read "tgname": no such variable
Date: 2011-04-08 14:54:11
Message-ID: BLU157-w5809EDCB17193AF83A16B7A2A70@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda


A las ordenes...

Date: Fri, 8 Apr 2011 10:22:49 -0430
Subject: Re: [pgsql-es-ayuda] ERROR: can't read "tgname": no such variable
From: cesar(dot)carbonara(at)gmail(dot)com
To: albertobruening(at)hotmail(dot)com
CC: pgsql-es-ayuda(at)postgresql(dot)org

Perfecto!
Probado y funcionando!
Gracias

El 8 de abril de 2011 10:16, Ramón Alberto Bruening González <albertobruening(at)hotmail(dot)com> escribió:

Hola a todos, me paso algo igual y era que cada vez que cambiaba la estructura de una tabla no encontraba dicha tabla el mismo trigger de auditoria, entonces lo que hice fue cambiar lo siguiente:

Original:
spi_exec "SELECT relname AS tgname FROM pg_class WHERE relfilenode = $TG_relid"

Modificado:
spi_exec "SELECT relname AS tgname FROM pg_class WHERE oid = $TG_relid"

Cambia eso y avisame que tal te va....

Alberto B.

Date: Fri, 8 Apr 2011 10:07:42 -0430
Subject: [pgsql-es-ayuda] ERROR: can't read "tgname": no such variable

From: cesar(dot)carbonara(at)gmail(dot)com
To: pgsql-es-ayuda(at)postgresql(dot)org

Saludos
Tengo una función de auditoría similar a [0], hasta ahora, la estoy "personalizando" y va funcionando.Estoy agregando otra función que chequee X intentos fallidos para bloquear el usuario:

CREATE OR REPLACE FUNCTION check_login(uname TEXT, pass TEXT)RETURNS SETOF usuarios AS $$
DECLARE passed BOOLEAN; inten INTEGER;BEGIN SELECT (clave = $2) INTO passed FROM usuarios WHERE usuario = $1;
IF (passed = false) THEN

UPDATE usuarios SET intento = (intento + 1) WHERE usuario = $1;
SELECT intento INTO inten FROM usuarios WHERE usuario = $1;
IF (inten = 3) THEN

UPDATE usuarios SET activo = false WHERE usuario = $1; END IF; RETURN; ELSE UPDATE usuarios SET intento = 0 WHERE usuario = $1; RETURN QUERY SELECT * FROM usuarios WHERE usuario = $1;

END IF;
RETURN;END;$$ LANGUAGE plpgsql SECURITY DEFINER;
La tabla usuarios también tiene el disparador de la auditoría.

Al agregarle la función check_login al sistema, y hacer login, me devuelve:ERROR: can't read "tgname": no such variable

CONTEXT: can't read "tgname": no such variable while executing"spi_exec "SELECT nspname AS scname FROM pg_namespace AS n JOIN pg_class AS c ON c.relnamespace = n.oid WHERE c.relname = '$tgname'""

(procedure "__PLTcl_proc_909190_trigger_908521" line 15) invoked from within"__PLTcl_proc_909190_trigger_908521 trg_audit_log 908521 usuarios cc1 {{} id tabla20_campo2 usuario clave default_mask nivel_acceso fregistro activo us..."

in PL/Tcl function "log_to_audit_table"sentencia SQL: «UPDATE cc1.usuarios SET intento = 0 WHERE usuario = $1 »PL/pgSQL function "check_login" line 19 at SQL statement

Entiendo por el mensaje que como estoy haciendo un UPDATE dentro de la función y no se dispara el trigger? cómo debería hacerse?

[0]http://www.alberton.info/postgresql_table_audit.html
--
--
Sí no eres parte de la solución... eres parte del problema.

--... y no dejes de leer:
Netiqueta: Conjunto de reglas que regulan la conducta del usuario en internet

http://es.wikibooks.org/wiki/Netiquette-- Cesar A. Carbonara R.

C.I. Nº V.11.952.572
--
Usuario Linux 377997
www.gulmer.org.ve

--
--
Sí no eres parte de la solución... eres parte del problema.
--... y no dejes de leer:
Netiqueta: Conjunto de reglas que regulan la conducta del usuario en internet
http://es.wikibooks.org/wiki/Netiquette
-- Cesar A. Carbonara R.
C.I. Nº V.11.952.572
--
Usuario Linux 377997
www.gulmer.org.ve

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Lazaro Ruben Garcia Martinez 2011-04-08 15:16:12 Re: insert o update?
Previous Message Cesar A 2011-04-08 14:52:49 Re: ERROR: can't read "tgname": no such variable