[GENERAL] TG_COLUMNS_UPDATED

2012-07-03 Thread david.sahagian
I would like another TG_* special variable to be available to a PL/pgSQL trigger-function. TG_COLUMNS_UPDATED Its value would be NULL unless: TG_OP == ' UPDATE' and TG_LEVEL == 'ROW' Data type == varbit One bit for each column of the table that the trigger is created on. 1 means that

[GENERAL] parsing SQLERRM ?

2012-06-14 Thread david.sahagian
(version == 9.1) In my PL/pgSQL stored functions, I want to be able to distinguish which FK-constraint caused the [foreign_key_violation] exception. . . . BEGIN delete from MY_COOL_TABLE where id = 123 ; EXCEPTION WHEN foreign_key_violation THEN CASE WHEN (SQLERRM tell

[GENERAL] parsing the SQLERRM string

2012-06-11 Thread david.sahagian
(version == 9.1) In my PL/pgSQL stored functions, I want to be able to distinguish which FK constraint caused the [foreign_key_violation] exception. . . . BEGIN delete from MY_COOL_TABLE where id = 123 ; EXCEPTION WHEN foreign_key_violation THEN CASE WHEN (SQLERRM tell

Re: [GENERAL] Change the default [tgenabled] for new "internal" triggers ?

2012-03-26 Thread david.sahagian
Scenario: (not slony, it is home-grown replication) A change on the Primary db is Captured and then Propagated to the Secondary db. Then the change is Applied to the Secondary db, with [session_replication_role] = 'replica'. I agree that I don't want my "user triggers" to fire as part of the App

[GENERAL] Change the default [tgenabled] for new "internal" triggers ?

2012-03-23 Thread david.sahagian
Today I learned that . . . the firing of even "internally generated constraint triggers" is affected by the value of [session_replication_role]. Sadly, I had previously assumed that such "internal" triggers did not care about [s_r_r]. Also learned that . . . when a FK constraint gets made, its

[GENERAL] usage of pg_get_functiondef() -- SQL state 42809

2012-03-19 Thread david.sahagian
-- This works. select TRG.tgname, TFX.proname, pg_get_functiondef(TFX.oid) as fdef from pg_trigger TRG inner join pg_proc TFX on TFX.oid = TRG.tgfoid where TRG.tgisinternal = true -- This blows up. -- SQL state: 42809 -- ERROR: "array_agg" is an aggregate function select T

[GENERAL] || versus concat( ), diff behavior

2012-03-02 Thread david.sahagian
Can anybody please point me to where this "difference of behavior" is explained/documented ? Thanks, -dvs- -- version = 9.1.3 do $$ declare v_str char(10); begin v_str := 'abc' ; raise info '%', concat(v_str, v_str) ; raise info '%', v_str||v_str ; end $$; INFO: abc abc INFO: ab

[GENERAL] 9.0 EXPLAIN Buffers: written=nnnn

2012-02-02 Thread david.sahagian
Do EXPLAIN ANALYZE: . . . only showing the bottom node . . . -> Seq Scan on Y (cost=0.00..37962.29 rows=876029 width=40) (actual time=16.728..92555.945 rows=876002 loops=1) Output: foo, bar Buffers: shared hit=146 read=29056 written=2325 ! "Total runtime: 375542.347 ms" Then Do

[GENERAL] not-always-full vacuuming in 9.0 ?

2011-12-27 Thread david.sahagian
select version() "PostgreSQL 9.0.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit" I ran the [check_bloat] query from check_postgres.pl (v 2.18.0) twice, doing a VACUUM FULL in between: -- the RS db, schemaname, tablename, tups, pages, otta, tblo

[GENERAL] not-always-full vacuuming in 9.0 ?

2011-12-22 Thread david.sahagian
select version() "PostgreSQL 9.0.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit" I ran the [check_bloat] query from check_postgres.pl (v 2.18.0) twice, doing a VACUUM FULL in between: -- the RS db, schemaname, tablename, tups, pages, otta, tbloa

[GENERAL] order by, within a plpgsql fx

2011-12-02 Thread david.sahagian
Please consider this plpgsql function: = = = = = = = = = = CREATE Or Replace FUNCTION fx_order_by ( ) RETURNS table( last_name text, first_name ) AS $eofx$ DECLARE -- BEGIN Return Query select lname, fname from my_table order by lname ASC ; END; $eofx$ LANGUAGE plpgsql; = =

[GENERAL] successive select statements

2011-11-21 Thread david.sahagian
In postgresql.org/docs/9.1/static/transaction-iso.html I read 13.2.1. Read Committed Isolation Level . . . two successive SELECT commands can see different data, even though they are within a single transaction . . . Please consider this code being executed by postgres: = = = = = = = = = = selec

[GENERAL] explicit deadlock-victim-priority mechanism

2011-10-25 Thread david.sahagian
ref = [ e1qzdjc-xv...@gemulon.postgresql.org ] I note with interest that [deadlock_timeout] can be used as . . . "a poor-man's deadlock priority mechanism: a transaction with a high [deadlock_timeout] is less likely to be chosen as the victim than one with a low [deadlock_timeout]" I for on

[GENERAL] COPY TO '|gzip > /my/cool/file.gz'

2011-07-20 Thread david.sahagian
From May 31, 2006; 12:03pm . . . "It struck me that we are missing a feature that's fairly common in Unix programs. Perhaps COPY ought to have the ability to pipe its output to a shell command, or read input from a shell command. " Maybe something like: COPY mytable TO '| gzip >/home/tgl/