[HACKERS] building pgadmin4

2014-03-03 Thread Willy-Bas Loos
Hi,

I'm trying to build pgadmin4, out of curiosity.
I'm on a ubuntu 13.10 desktop vm.
I added qt webkitwidgets, and now I run into the next error, which doesn't
seem to make much sense:
wbloos2@vm1:~/pgadmin4/runtime$ qmake
Project MESSAGE: Building for QT5+...
Project ERROR: Unknown module(s) in QT: quick

I haven't found the word quick in any of the code and there's no .qml
file.

any clues?

Cheers,

WBL


-- 
Quality comes from focus and clarity of purpose -- Mark Shuttleworth


Re: [HACKERS] building pgadmin4

2014-03-03 Thread Willy-Bas Loos

 pgAdmin is off-topic for this mailing list.


so sorry, i misread the adress in the readme file

cheers,

WBL

-- 
Quality comes from focus and clarity of purpose -- Mark Shuttleworth


Re: [HACKERS] possible/feasible to specify field and value in error msg?

2013-07-04 Thread Willy-Bas Loos
On Wed, Jul 3, 2013 at 5:18 PM, Bruce Momjian br...@momjian.us wrote:

 On Wed, Jul  3, 2013 at 11:14:18AM -0400, Bruce Momjian wrote:
  We will add optional error details in Postgres 9.3:
 
http://momjian.us/main/blogs/pgblog/2013.html#April_11_2013



 I just tested this and it doesn't show the offending column name;
 sorry:

 test= CREATE TABLE test(x smallint);
 CREATE TABLE
 test= \set VERBOSITY verbose
 test= INSERT INTO test VALUES (1000);
 ERROR:  22003: smallint out of range
 LOCATION:  i4toi2, int.c:349



It's great to see that you people care about userland, judging by the
effort that you describe in your article.
In fact you're already doing the thing that i asked about, i see that even
the offending tuple is printed (which is new).
And of course it's not necessary to mention the column name when you
mention the constraint name.
(BTW: your remark about NOT NULL constraints is not necessary, that error
message is very clear:ERROR:  null value in column balance violates
not-null constraint )

This is not a constraint going off, and in this case, none of that applies.
But it seems probable to me that some day it will, seeing as you already
implemented it for constraints.

Thanks,

Willy-Bas Loos

-- 
Quality comes from focus and clarity of purpose -- Mark Shuttleworth


[HACKERS] possible/feasible to specify field and value in error msg?

2013-07-03 Thread Willy-Bas Loos
Hi,

I have some complicated query that truncates and fills a table and i get
this message:
ERROR:  smallint out of range
STATEMENT: my huge query
This is in postgres 8.4
I don't know where the error is, and the query takes rather long. So it is
going to be a bit cumbersome for me to debug this.

Would it be possible/feasible to specify, in future versions of postgres:
* what value
* which field (of which table)
* the offending tuple? (possibly truncated to some threshold nr of
characters)

I ask because i can imagine that, inside the code that handles this, you
might not have access to that information and adding access to it might be
inefficient.

I do get the whole query of course, and that is very handy for automated
things. But in this case, it doesn't help me.

Cheers,

WBL

-- 
Quality comes from focus and clarity of purpose -- Mark Shuttleworth


[GENERAL][HACKERS] register creation date of table

2011-10-14 Thread Willy-Bas Loos
Hi,

We have several users working on a 8.4 database, using it as a
back-end for several related apps and transfering data to and from it.
The database tends to get a bit messy, so i've made a little table to
provide an overview.
This table is truncated and refilled daily, it shows all tables and
views in the database and :
* the owner
* number of records (estimation)
* it's size on disk
* the description

There's a view on the table that shows the size as pg_size_pretty
When you edit the description in the table (or the view, but no
support in pgAdmin), the comment in the system tables is updated also.
I attatched my code, hope some people find it handy, sorry for the
names and comments being in dutch.

Now, i would like to improve this thing and add a creation date for the table.
I have some questions about that.
1. I think that there is no such information in the system tables. is
that correct?
I am planning to change the mechanism, so that the table is not
truncated, but new tables are inserted in the overview and dropped
tables are deleted from it. I need to do that in 2 steps (delete and
insert).
Then i can add a creation-date column which i will fill with 'today'.

2. i would like to go back in time. I think that i will just look up
the creation date for the files in the data directory and translate
their oid's to the object names and then update their dates. This
would of course only work from the last restore. Is that a good way to
do it?

Thanks,

WBL

-- 
Patriotism is the conviction that your country is superior to all
others because you were born in it. -- George Bernard Shaw

CREATE TABLE alg.tabellenenviews
(
  sorteren serial NOT NULL,
  relid integer,
  type text,
  schema name,
  tabelnaam name,
  eigenaar name,
  records_schatting bigint,
  grootte_bytes bigint,
  omschrijving text,
  CONSTRAINT tabellenenviews_pkey PRIMARY KEY (sorteren)
)
WITH (
  OIDS=FALSE
);
GRANT SELECT ON TABLE alg.tabellenenviews TO public;
GRANT UPDATE ON TABLE alg.tabellenenviews TO admins;
COMMENT ON TABLE alg.tabellenenviews IS 'Overzicht van alle tabellen en views in de database. (meer commentaar na harde return..)
Pas kolom omschrijving aan om commentaar van view of tabel ook aan te passen. 
Deze tabel wordt elke nacht automatisch opnieuw gegenereerd. 
Laatst geupdate op:2011-10-14 05:00:03.238905';


CREATE OR REPLACE FUNCTION alg.setcomment(p_type text, p_schema name, p_rel name, p_omschrijving text)
  RETURNS void AS
$BODY$
DECLARE
--t text;
BEGIN
--t:='COMMENT ON '||replace($1, 'tabel','TABLE')||' '||quote_ident($2)||'.'||quote_ident($3)||' IS '||quote_nullable($4);
--raise notice 'commando is:  %', t;
EXECUTE 'COMMENT ON '||replace($1, 'tabel','TABLE')||' '||quote_ident($2)||'.'||quote_ident($3)||' IS '||quote_nullable($4);
END
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION alg.setcomment(text, name, name, text) SET search_path=alg;

COMMENT ON FUNCTION alg.setcomment(text, name, name, text) IS 'wordt gebruikt door de triggerfunctie alg.tabellenviews_setcomment_triggerfunctie() om het commentaar op tabellen te veranderen als dat wordt aangepast in de tabel alg.tabellenenviews';


CREATE OR REPLACE FUNCTION alg.tabellenenviews_setcomment_triggerfunction()
  RETURNS trigger AS
$BODY$
BEGIN
PERFORM alg.setcomment(OLD.type, OLD.schema, OLD.tabelnaam, NEW.omschrijving);
NEW.sorteren:=OLD.sorteren;
NEW.relid:=OLD.relid;
NEW.type:=OLD.type;
NEW.schema:=OLD.schema;
NEW.tabelnaam:=OLD.tabelnaam;
NEW.eigenaar:=OLD.eigenaar;
NEW.records_schatting:=OLD.records_schatting;
NEW.grootte_bytes:=OLD.grootte_bytes;
--NEW.omschrijving:=OLD.omschrijving; --deze houdt dus de nieuwe waarde.
RETURN NEW;
END
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
COMMENT ON FUNCTION alg.tabellenenviews_setcomment_triggerfunction() IS 'past het commentaar van een tabel of view aan in de postgres systeemtabellen als dat wordt aangepast in de tabel alg.tabellenviews';


CREATE TRIGGER setcomment_trigger
  BEFORE UPDATE
  ON alg.tabellenenviews
  FOR EACH ROW
  EXECUTE PROCEDURE alg.tabellenenviews_setcomment_triggerfunction();

CREATE OR REPLACE VIEW alg.tabellenenviews_mooi AS 
 SELECT tabellenenviews.type, tabellenenviews.schema, tabellenenviews.tabelnaam, tabellenenviews.eigenaar, tabellenenviews.records_schatting, pg_size_pretty(tabellenenviews.grootte_bytes) AS grootte_mooi, tabellenenviews.omschrijving
   FROM alg.tabellenenviews;

GRANT SELECT ON TABLE alg.tabellenenviews_mooi TO public;
COMMENT ON VIEW alg.tabellenenviews_mooi IS 'Overzicht van alle tabellen en views in de database, met tekstuele weergave van de bestandsgrootte van de tabellen';

/*
--this is no use without support for editable views in pgAdmin

CREATE RULE _UPDATE AS ON UPDATE TO alg.tabellenenviews_mooi
	DO INSTEAD 
		UPDATE alg.tabellenenviews
		   SET omschrijving = NEW.omschrijving
		 WHERE schema = OLD.schema
		   AND tabelnaam = OLD.tabelnaam;

GRANT UPDATE ON TABLE alg.tabellenenviews_mooi TO public;
*/

--wordt afgevuurd vanuit de crontab