Re: [HACKERS] Custom aggragation function that creates an array

2010-10-23 Thread Leonardo Francalanci
Before you start coding, have you looked over what's in contrib/intarray ? There's nothing that fulfills my needs there, but I guess it would be the perfect place to watch for code examples! Thank you (I think I made my custom aggregation function work, but I'll look into intarray code to

Re: [HACKERS] pg_hba.conf host name wildcard support

2010-10-23 Thread Peter Eisentraut
On tor, 2010-10-21 at 06:38 +0300, Peter Eisentraut wrote: So, as previously indicated, let's add some wildcard support to the pg_hba.conf host name feature. After looking around a bit, two syntaxes appear to be on offer: 1. TCP Wrappers style, leading dot indicates suffix match. So

Re: [HACKERS] ask for review of MERGE

2010-10-23 Thread Marko Tiikkaja
On 2010-10-23 8:34 AM +0300, Greg Smith wrote: While the performance doesn't need to be great in V1, there needs to be at least some minimal protection against concurrency issues before this is commit quality. What's been bothering me is that so far there has not been an agreement on whether

Re: [HACKERS] Creation of temporary tables on read-only standby servers

2010-10-23 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian br...@momjian.us writes: Greg Stark wrote: It seems to me simpler and more direct to just nail relcache entries for these objects into memory and manipulate them directly. They can be constructed from the global catalog tables and then tweaked to point to

Re: [HACKERS] ask for review of MERGE

2010-10-23 Thread Greg Smith
Marko Tiikkaja wrote: What's been bothering me is that so far there has not been an agreement on whether we need to protect against concurrency issues or not. In fact, there has been almost no discussion about the concurrency issues which AIUI have been the biggest single reason we don't

Re: [HACKERS] ask for review of MERGE

2010-10-23 Thread Tom Lane
Greg Smith g...@2ndquadrant.com writes: Marko Tiikkaja wrote: What's been bothering me is that so far there has not been an agreement on whether we need to protect against concurrency issues or not. In fact, there has been almost no discussion about the concurrency issues which AIUI have

[HACKERS] window function count(*) and limit

2010-10-23 Thread Jesper Krogh
Hi. I have been puzzled about the evaluation order when using window functions and limit. jk=# select * from testtable; id | value +--- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 |10 (10 rows) jk=# select

Re: [HACKERS] window function count(*) and limit

2010-10-23 Thread Tom Lane
Jesper Krogh jes...@krogh.cc writes: I have been puzzled about the evaluation order when using window functions and limit. It's basically FROM - WHERE - window functions - LIMIT. I expected it to either count to 3 or blow up and tell me that count(*) wasn't a window function. Any aggregate

Re: [HACKERS] window function count(*) and limit

2010-10-23 Thread Jesper Krogh
On 2010-10-23 18:42, Tom Lane wrote: Jesper Kroghjes...@krogh.cc writes: I have been puzzled about the evaluation order when using window functions and limit. It's basically FROM - WHERE - window functions - LIMIT. I expected it to either count to 3 or blow up and tell me

Re: [HACKERS] GIN vs. Partial Indexes

2010-10-23 Thread Josh Berkus
On 10/08/2010 02:44 PM, Robert Haas wrote: In any case, I would expect that GIN could actually do this quite efficiently. What we'd probably want is a concept of a null word, with empty indexable rows entered in the index as if they contained the null word. So there'd be just one index

[HACKERS] create c function with void argument bug?

2010-10-23 Thread A.M.
Hello, It seems that this: CREATE OR REPLACE FUNCTION test_fsync_speed() RETURNS float AS '$libdir/test_fsync_speed','\ test_fsync_speed' LANGUAGE C IMMUTABLE STRICT; is not equivalent to this (note void argument): CREATE OR REPLACE FUNCTION test_fsync_speed(void) RETURNS float AS

Re: [HACKERS] xlog.c: WALInsertLock vs. WALWriteLock

2010-10-23 Thread David Fetter
On Fri, Oct 22, 2010 at 12:08:54PM -0700, fazool mein wrote: Hello guys, I'm writing a function that will read data from the buffer in xlog (i.e. from XLogCtl-pages and XLogCtl-xlblocks). I want to make sure that I am doing it correctly. Got an example of what the function might look

Re: [HACKERS] ask for review of MERGE

2010-10-23 Thread Boxuan Zhai
This did seem to find a bug in the implementation after running for a while: TRAP: FailedAssertion(!(epqstate-origslot != ((void *)0)), File: execMain.c, Line: 1732) Line number there is relative to what you can see at

Re: [HACKERS] Bug in plpython's Python Generators

2010-10-23 Thread Jan Urbański
On 21/10/10 20:48, Alvaro Herrera wrote: Excerpts from Alvaro Herrera's message of jue oct 21 15:32:53 -0300 2010: Excerpts from Jean-Baptiste Quenot's message of jue oct 21 09:20:16 -0300 2010: I get this error when calling the function: test=# select foobar(); ERROR: error fetching

Re: [HACKERS] ask for review of MERGE

2010-10-23 Thread Greg Stark
On Sat, Oct 23, 2010 at 9:12 AM, Tom Lane t...@sss.pgh.pa.us wrote: PostgreSQL doesn't have a good way to lock access to a key value that doesn't exist yet--what other databases call key range locking...Improvements to the index implementation are needed to allow this feature. This seems to

Re: [HACKERS] ask for review of MERGE

2010-10-23 Thread Josh Berkus
So the trick for MERGE on equality would be to refactor the btree api so that you could find the matching leaf page and *keep* that page locked. Then do an update against the conflicting row found there if any without ever releasing that page lock. Someone else can come along and delete the row

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: Latest patch attached. I've been working through this patch. It occurs to me that there's a fairly serious problem with the current implementation of insertion of new values within the bounds of the current sort ordering. Namely, that it does that by

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Josh Berkus
The disadvantage of this scheme is that if you repeatedly insert entries in the same place in the sort order, you halve the available range each time, so you'd run out of room after order-of-fifty halvings. This is not a real issue. If anyone is using an ENUM with 1000 values in it, they're

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Tom Lane
Josh Berkus j...@agliodbs.com writes: The disadvantage of this scheme is that if you repeatedly insert entries in the same place in the sort order, you halve the available range each time, so you'd run out of room after order-of-fifty halvings. This is not a real issue. If anyone is using an

Re: [HACKERS] create c function with void argument bug?

2010-10-23 Thread Tom Lane
A.M. age...@themactionfaction.com writes: It seems that this: CREATE OR REPLACE FUNCTION test_fsync_speed() RETURNS float AS '$libdir/test_fsync_speed','\ test_fsync_speed' LANGUAGE C IMMUTABLE STRICT; is not equivalent to this (note void argument): CREATE OR REPLACE FUNCTION

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Robert Haas
On Oct 23, 2010, at 7:12 PM, Tom Lane t...@sss.pgh.pa.us wrote: Andrew Dunstan and...@dunslane.net writes: Latest patch attached. I've been working through this patch. It occurs to me that there's a fairly serious problem with the current implementation of insertion of new values within

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Oct 23, 2010, at 7:12 PM, Tom Lane t...@sss.pgh.pa.us wrote: I've been working through this patch. It occurs to me that there's a fairly serious problem with the current implementation of insertion of new values within the bounds of the current

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Robert Haas
On Oct 23, 2010, at 7:52 PM, Tom Lane t...@sss.pgh.pa.us wrote: I still prefer the idea of not changing rows once they're inserted, though Me too. But I really dislike the idea of having a failure mode where we can't insert for no reason that the user can understand. So I'm trying to think

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: Why would you need to lock out type comparisons? Didn't you get the point? The hazard is to a concurrent process that is merely trying to load up its enum-values cache so that it can perform an enum comparison. I don't want such an operation to have to

Re: [HACKERS] patch: Add JSON datatype to PostgreSQL (GSoC, WIP)

2010-10-23 Thread Terry Laurenzo
I'm still going to write up a proposed grammar that takes these items into account - just ran out of time tonight. The binary format I was thinking of is here: http://github.com/tlaurenzo/pgjson/blob/master/pgjson/shared/include/json/jsonbinary.h This was just a quick brain dump and I

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Andrew Dunstan
On 10/23/2010 07:12 PM, Tom Lane wrote: Andrew Dunstanand...@dunslane.net writes: Latest patch attached. I've been working through this patch. Cool. [snip: reallocating enum sortorder on existing values has race conditions. Suggestion to use a float8 instead and add new value half way

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: Seriously, I think it might be OK. Could we provide some safe way of resetting the sortorder values? Or even a not-entirely-safe superuser-only function might be useful. Binary upgrade could probably call it safely, for example. You could do it

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Robert Haas
On Sat, Oct 23, 2010 at 8:11 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: Why would you need to lock out type comparisons? Didn't you get the point?  The hazard is to a concurrent process that is merely trying to load up its enum-values cache so that it can

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Andrew Dunstan
On 10/23/2010 08:54 PM, Tom Lane wrote: Another thought here is that the split-in-half rule might be unnecessarily dumb. It leaves equal amounts of code space on both sides of the new value, even though the odds of subsequent insertions on both sides are probably unequal. But I'm not sure if

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: I suppose you could fix this by always updating every row, and storing in each row the total count of elements (or a random number). Then it'd be obvious if you'd read an inconsistent view of the world. Well, the easy way to read a consistent view of

Re: [HACKERS] patch: Add JSON datatype to PostgreSQL (GSoC, WIP)

2010-10-23 Thread Robert Haas
On Sat, Oct 23, 2010 at 8:33 PM, Terry Laurenzo t...@laurenzo.org wrote: I'm still going to write up a proposed grammar that takes these items into account - just ran out of time tonight. The binary format I was thinking of is here:   

Re: [HACKERS] WIP: extensible enums

2010-10-23 Thread Robert Haas
On Sun, Oct 24, 2010 at 12:26 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: I suppose you could fix this by always updating every row, and storing in each row the total count of elements (or a random number).  Then it'd be obvious if you'd read an