Re: [GENERAL] Bug, Feature, or what else?

2013-02-08 Thread Виктор Егоров
2013/2/8 Andreas Kretschmer > How can i drop a user as SUPERUSER (!) with all privileges? > According to the docs: http://www.postgresql.org/docs/current/interactive/sql-droprole.html > A role cannot be removed if it is still referenced in any database of the cluster; > an error will be raised

Re: [GENERAL] DEFERRABLE NOT NULL constraint

2013-02-05 Thread Виктор Егоров
2013/2/5 Darren Duncan : > I'd like to know what value there is in making NOT NULL and CHECK > deferrable. Consider such schema sample: - you have tables “groups” and “group_items” - each group must have at least one item - each group must have a “master” item, that is denoted in groups.master_ite

Re: [GENERAL] grouping consecutive records

2013-02-04 Thread Виктор Егоров
2013/2/4 Morus Walter : > I'd like to merge all consecutive records (ordered by sort, user_id) > having the same value in user_id and key and keep the first/last > value of sort of the merged records (and probably some more values > from the first or last merged record). > > So the result should be

Re: [GENERAL] Logging successful SELECTS?

2013-01-24 Thread Виктор Егоров
2013/1/24 Matthew Vernon : > I can get postgres to log unsuccessful queries, including the user who > wrote them, but I'm missing how to get postgres to log the successful > queries too (I don't need a store of the answer, just the query > itself). How do I do this? You can use either log_min_dura

Re: [GENERAL] Problem with aborting entire transactions on error

2012-12-10 Thread Виктор Егоров
2012/12/10 Thomas Kellerer > > Zbigniew, 10.12.2012 04:20: >> >> Yes, I read about using "savepoints" - but I think we agree, >> it's just cumbersome workaround - and not real solution, > > > It might be a bit cumbersome, but it *is* a proper solution to the problem - > not a workaround. Writing

Re: [GENERAL] How to list all schema names inside a PostgreSQL database through SQL

2012-11-15 Thread Виктор Егоров
2012/11/15 Xiaobo Gu : > How can I list all schema names inside a PostgreSQL database through > SQL, especially thoese without any objects created inside it. Something like this: select n.nspname, count(o.oid) from pg_namespace n left join pg_class o on n.oid=o.relnamespace group by 1 order

Re: [GENERAL] obtain the difference between successive rows

2012-10-20 Thread Виктор Егоров
2012/10/20 Berend Tober : > Your suggestion almost worked as is for this, except that you have to note > that reading for meter #2 and meter #3 overlap (I briefly owned two houses), > and that seemed to confuse the lag() function: > > SELECT > electric_meter_pk, > lag(reading_date) > OVER(

Re: [GENERAL] CTE materializing sets?

2012-10-09 Thread Виктор Егоров
2012/10/9 Serge Fonville : > This indeed is a very interesting question. > > At http://wiki.postgresql.org/wiki/CTEReadme it seems to suggest that a CTE > is just rewritten and the resulting query is executed. As was mentioned a couple of times in this list, CTE do have optimization fence feature

Re: [GENERAL] pg_upgrade default ports in the --help output

2012-10-04 Thread Виктор Егоров
2012/10/4 Adrian Klaver : > http://www.postgresql.org/docs/9.2/static/pgupgrade.html > "Obviously, no one should be accessing the clusters during the upgrade. > pg_upgrade defaults to running servers on port 50432 to avoid unintended > client connections. You can use the same port number for both c

[GENERAL] pg_upgrade default ports in the --help output

2012-10-04 Thread Виктор Егоров
Greetings. I just noticed the following default ports in the pg_upgrade --help: -p, --old-port=OLDPORTold cluster port number (default 50432) -P, --new-port=NEWPORTnew cluster port number (default 50432) Why is this different from: --with-pgport=PORTNUM set default port nu

Re: [GENERAL] Data recovery after inadvertent update?

2012-09-18 Thread Виктор Егоров
Check this post on depesz.com: http://www.depesz.com/2012/04/04/lets-talk-dirty/ 2012/9/18 Craig Ringer > Also, are there any functions to read raw tuple bytes to `RECORD's? I > couldn't find any in `pageinspect', `pgstattuple', `adminpack', etc. Am I > right in guessing that they're pretty much

Re: [GENERAL] return text from explain

2012-09-07 Thread Виктор Егоров
Hope this helps: CREATE OR REPLACE FUNCTION explain(in_sql text) RETURNS TABLE(explain_line text) AS $explain$ BEGIN RETURN QUERY EXECUTE 'EXPLAIN '||in_sql; END; $explain$ LANGUAGE plpgsql; SELECT * FROM explain('SELECT * FROM pg_locks'); -- Victor Y. Yegorov

Re: [GENERAL] Extensions and roles for access administration

2012-06-22 Thread Виктор Егоров
Thanks, this clarifies things for me. There's DROP ROLE IF EXISTS, which I'm using. 2012/6/22 Tom Lane > > Roles are not considered to be part of an extension: they really can't > be, since an extension is local to a database while a role is global to > the whole installation. As per the docume

[GENERAL] Extensions and roles for access administration

2012-06-22 Thread Виктор Егоров
Greetings. I've developed a small extension, that is essentially a collection of tables with a bunch of PL/pgSQL functions, that are API for the whole thing. Inside the extension script I am creating extra roles, and access to the extension's functions is provided using these extra roles. Given e

[GENERAL] How to find compiled-in default port number?

2012-03-13 Thread Виктор Егоров
Greetings. Is there a way to find out the compiled-in port number? I can parse `pg_config` output to check out port in cases port was actually specified. However if defaults had been used, is there any tool that will tell me the magic 5432 number or should I silently stick to this number in my s