[SQL] SECURITY DEFINER changes CURRENT_USER?

2003-07-20 Thread Chris Travers
Hi all; I found an unexpected behavior while trying to write a function to allow users to change their own passwords. The function is as follows: CREATE OR REPLACE FUNCTION change_password(VARCHAR) RETURNS BOOL AS ' DECLARE username VARCHAR; CMD VARCHAR; password ALIAS FOR $1; BEGIN

Re: [SQL] Why do the two queries below return different results?

2003-07-20 Thread Tom Lane
Warren Little [EMAIL PROTECTED] writes: Look at the following two queries. ... and not exists (select pid from casecombo where casepid = secondpid) ... and casepid not in (select secondpid from casecombo) The second query is broken and I don't understand why. I'll bet there are some NULL

Re: [SQL] column doesn't get calculated - updated

2003-07-20 Thread Tom Lane
[EMAIL PROTECTED] writes: when i copy/paste the select stmt into psql, it works. or if i use it dynamically. it doesn't work properly when i use it in a prepared statement -- which is what i am doing. Could we see a self-contained example of the problem? It's hard to tell whether you are

Re: [SQL] min() and NaN

2003-07-20 Thread Tom Lane
Michael S. Tibbetts [EMAIL PROTECTED] writes: I'd expect the aggregate function min() to return the minimum, valid numeric value. Instead, it seems to return the minimum value from the subset of rows following the 'NaN'. Not real surprising given than min() is implemented with

Re: [SQL] min() and NaN

2003-07-20 Thread Stephan Szabo
On Sun, 20 Jul 2003, Tom Lane wrote: Michael S. Tibbetts [EMAIL PROTECTED] writes: I'd expect the aggregate function min() to return the minimum, valid numeric value. Instead, it seems to return the minimum value from the subset of rows following the 'NaN'. Not real surprising given

Re: [SQL] SECURITY DEFINER changes CURRENT_USER?

2003-07-20 Thread Matthew Horoschun
Hi Chris, You want to use session_user. I would expect this to change the password of the user currently logged in but instead it changes MY password. Evidently when a function is called which is set to SECURITY DEFINER, it changes the context of the current user. The CURRENT_USER then

Re: [SQL] changing an update via rules

2003-07-20 Thread Stephan Szabo
On 15 Jul 2003, Lauren Matheson wrote: Hello, I am having difficulty setting an on update rule which seems to be caught in a recursive loop. Context is a table with three columns assigning users to groups with the third column being boolean to flag the primary group. I would like to set

Re: [SQL] min() and NaN

2003-07-20 Thread Stephan Szabo
On Tue, 15 Jul 2003, Michael S. Tibbetts wrote: Hi, I have a table containing a double precision column. That column contains at least one judiciously placed NaN. I'd expect the aggregate function min() to return the minimum, valid numeric value. Instead, it seems to return the minimum

Re: [SQL] Join table with itself for heirarchial system?

2003-07-20 Thread Oleg Bartunov
You might look on our contrib/ltree module (http://www.sai.msu.su/~megera/postgres/gist/ltree) Oleg On Wed, 16 Jul 2003, Benjamin Smith wrote: Can you query a set of nested entries to simulate a heirarchial system with a single query? I'm building a nested category table with a

Re: [SQL] inet versus text for ip addresses

2003-07-20 Thread Bruce Momjian
Dan Langille wrote: The PostgreSQL inet datatype stores an holds an IP host address, and optionally the identity of the subnet it is in, all in one field. This requires 12 bytes. Using my random data of approximately 8000 IP addresses collected during previous polls, I've found the