Re: [GENERAL] About the MONEY type

2016-12-17 Thread Bruce Momjian
On Wed, Nov 30, 2016 at 01:35:12PM -0800, John R Pierce wrote: > note, btw, TIMESTAMP WITH TIME ZONE doesn't actually store the timezone... > rather, it converts it to an internal representation of GMT, and then converts > it back to display time at the client's current (or specified) time zone.

[GENERAL] Love Your Database: Simple Validations

2016-12-17 Thread guyren
Love Your Database: Simple Validations I just posted the next blog post in my Love Your Database series about how to put your model logic in Postgres where it belongs. This one describes in principle how to put validations in Postgres and then capture them in your web application so you can

Re: [GENERAL] Checking data checksums...

2016-12-17 Thread Torsten Förtsch
I use this: create extension pageinspect; SELECT count(*) AS pages_read FROM ( SELECT c.oid::regclass::text AS rel, f.fork, ser.i AS blocknr, page_header(get_raw_page(c.oid::regclass::text, f.fork,

[GENERAL] Re: [GENERAL] Love Your Database project — Thoughts on effectively handling constraints?

2016-12-17 Thread Guyren Howe
On Dec 16, 2016, at 16:52 , Tom Lane wrote: > > The server already does deliver more-structured error data, although I confess > that I have no idea how to get at it in Ruby on Rails. In psql the case > looks about like this: Thanks for the advice. I’ve worked out how to

Re: [GENERAL] Checking data checksums...

2016-12-17 Thread David Steele
On 12/16/16 5:07 AM, ma...@kset.org wrote: > I enabled data checksums (initdb --data-checksums) on a new instance and > was wandering is there a command in the psql console, or from the linux > console, to force a checksum check on the entire cluster and get error > reports if it finds some

Re: [GENERAL] SQL query problem of a Quiz program

2016-12-17 Thread Torsten Förtsch
Did you try DISTINCT ON? postgres=# table x; id | qid | uid +-+ 1 | 25 | 1 2 | 25 | 1 3 | 25 | 1 4 | 26 | 1 5 | 26 | 1 6 | 27 | 1 7 | 27 | 1 8 | 25 | 2 9 | 25 | 2 10 | 25 | 2 11 | 26 | 2 12 | 26 | 2

Re: [GENERAL] Recursive row level security policy

2016-12-17 Thread Joe Conway
On 12/17/2016 02:04 PM, Stephen Frost wrote: > Note that RLS won't be applied for the table owner either (unless the > relation has 'FORCE RLS' enabled for it), so you don't have to have > functions which are run as superuser to use the approach Joe > recommended. Good point, thanks, I should

Re: [GENERAL] Recursive row level security policy

2016-12-17 Thread Stephen Frost
Simon, * Simon Charette (charett...@gmail.com) wrote: > Ahh makes sense, thanks for the explanation! > > I was assuming USING() clauses were executed in the context of the > owner of the policy, by passing RLS. No, as with views, a USING() clause is executed as the caller not the owner of the

Re: [GENERAL] Recursive row level security policy

2016-12-17 Thread Simon Charette
Ahh makes sense, thanks for the explanation! I was assuming USING() clauses were executed in the context of the owner of the policy, by passing RLS. 2016-12-17 13:18 GMT-05:00 Joe Conway : > On 12/17/2016 01:01 PM, Simon Charette wrote: >> Thanks a lot Joe, that seems to

Re: [GENERAL] Recursive row level security policy

2016-12-17 Thread Joe Conway
On 12/17/2016 01:01 PM, Simon Charette wrote: > Thanks a lot Joe, that seems to work! Good to hear. > I suppose this works because PostgreSQL cannot introspect the > get_owner_id procedure to detect it's querying the "accounts" table > and thus doesn't warn about possible infinite recursion?

Re: [GENERAL] Recursive row level security policy

2016-12-17 Thread Simon Charette
Thanks a lot Joe, that seems to work! I suppose this works because PostgreSQL cannot introspect the get_owner_id procedure to detect it's querying the "accounts" table and thus doesn't warn about possible infinite recursion? Simon 2016-12-16 9:36 GMT-05:00 Joe Conway : > On

Re: [GENERAL] SQL query problem of a Quiz program

2016-12-17 Thread Adrian Klaver
On 12/17/2016 07:25 AM, Arup Rakshit wrote: Hi, Here is a sample data from table "quiz_results": id | question_id | user_id +-+ 2 | 25 | 5142670086 3 | 26 | 4 | 26 | 5 | 27 | 6 | 25 | 5142670086 7 |

Re: [GENERAL] SQL query problem of a Quiz program

2016-12-17 Thread Melvin Davidson
On Sat, Dec 17, 2016 at 10:25 AM, Arup Rakshit wrote: > Hi, > > Here is a sample data from table "quiz_results": > > id | question_id | user_id > +-+ > 2 | 25 | 5142670086 > 3 | 26 | > 4 | 26 | > 5 |

[GENERAL] SQL query problem of a Quiz program

2016-12-17 Thread Arup Rakshit
Hi, Here is a sample data from table "quiz_results": id | question_id | user_id +-+ 2 | 25 | 5142670086 3 | 26 | 4 | 26 | 5 | 27 | 6 | 25 | 5142670086 7 | 25 | 5142670086 8 | 25 | 5142670086

[GENERAL] Re: [GENERAL] Love Your Database project — Thoughts on effectively handling constraints?

2016-12-17 Thread Kevin Grittner
On Fri, Dec 16, 2016 at 3:54 PM, Guyren Howe wrote: > What I need to do is turn this into something similar to the equivalent > Rails-side constraint failure, which is a nicely formatted error message on > the model object. Can you show what the text in such a message looks