Mario Soto Cordones escribió:
> Hola Alvaro:
> 
> Esta es la función:
> 
> 
> CREATE OR REPLACE FUNCTION audit.audit_table (
>   target_table pg_catalog.regclass,
>   audit_rows boolean,
>   audit_query_text boolean,
>   ignored_cols text []
> )
> RETURNS void AS
> $body$
> DECLARE
>   stm_targets text = 'INSERT OR UPDATE OR DELETE OR TRUNCATE';
>   _q_txt text;
>   _ignored_cols_snip text = '';
> BEGIN
>     EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' ||
> quote_ident(target_table::text);

Hm, esto está mal.  Si target_table es un regclass, entonces podría
estar calificado con el nombre del esquema, y por lo tanto tratar de
pasarlo a través de quote_ident sería un error.  Observa:

alvherre=# create schema "Foo bar";
CREATE SCHEMA
alvherre=# create table "Foo bar"."bar Baz" ();
CREATE TABLE

alvherre=# select '"Foo bar"."bar Baz"'::regclass;
      regclass       
---------------------
 "Foo bar"."bar Baz"
(1 fila)

alvherre=# select quote_ident('"Foo bar"."bar Baz"'::regclass::text);
        quote_ident        
---------------------------
 """Foo bar"".""bar Baz"""
(1 fila)

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda@postgresql.org)
Para cambiar tu suscripción:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responder a