Re: Consulta Migrar a 9.1 SOLUCIONADO

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Mario Soto Cordones <marioa(dot)soto(dot)cordones(at)gmail(dot)com>
Cc: 'Jaime Casanova' <jaime(at)2ndquadrant(dot)com>, 'Martín Marqués' <martin(dot)marques(at)gmail(dot)com>, 'Ayuda' <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Consulta Migrar a 9.1 SOLUCIONADO
Date: 2013-04-15 15:08:51
Message-ID: 20130415150851.GB8626@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

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(at)postgresql(dot)org)
Para cambiar tu suscripción:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Mario Soto Cordones 2013-04-15 15:38:49 RE: Consulta Migrar a 9.1 SOLUCIONADO
Previous Message Mario Soto Cordones 2013-04-15 15:04:11 RE: Consulta Migrar a 9.1 SOLUCIONADO