Re: [GENERAL] select any table

2008-03-26 Thread Sam Mason
allow this (i.e. disallows revoking of access) should be taken out and shot quickly. Any language of reasonable complexity will support some form of information hiding (aka abstraction) and suggesting you can stop this by disallowing revoking of access is just silly. > Sam Mason wrote: > &g

Re: [GENERAL] Survey: renaming/removing script binaries (createdb, createuser...)

2008-03-26 Thread Sam Mason
1. b 2. c 3. d 4. b and c I do most of my admin using SQL these days. my preference would be towards keeping them because they're nice in the beginning. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] oddly high cost but low actual_time (but not in slony replicants)

2008-03-26 Thread Sam Mason
ny ideas? Looks like you've "disabled" seqscans. Because seqscan is a fallback method all disabling does is to make it very expensive. To check: SHOW enable_seqscan; If it's set then have a look in the config file, or maybe reset the per-role setting using ALTER ROLE[1].

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Sam Mason
st had a look at its source and gave up trying to understand it rather quickly. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Performance of update

2008-03-27 Thread Sam Mason
On Wed, Mar 26, 2008 at 01:26:03PM -0700, Sam wrote: > Iam trying to update a database table with approx 45000 rows. Iam not > updating all rows at a time. Iam updating 60 rows at a given time for > example. and this is happening in a FOR LOOP. A function that has the > update statemen

Re: [GENERAL] returned value from SQL statement

2008-03-27 Thread Sam Mason
TE FROM cust_portal.tmp_newsletterreg WHERE email = $3; $$; Sam [1] http://www.postgresql.org/docs/current/static/sql-savepoint.html [2] http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING -- Sent via pgsql-general mailing list (pgsq

Re: [GENERAL] dunction issue

2008-03-27 Thread Sam Mason
ROM users) u ON s.email = u.email; Why not put a foreign key on the "email" column to the users table---one less error to handle that way? Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] dunction issue

2008-03-27 Thread Sam Mason
OP, he seems to be missing a lot of the tools that databases' give you. Transactions and unique constraints being two significant ones. Writing stored procedures to do their work is just going to introduce unnecessary bugs and complication. Sam -- Sent via pgsql-general mailing list (

Re: [GENERAL] dunction issue

2008-03-28 Thread Sam Mason
On Fri, Mar 28, 2008 at 06:43:00PM +0900, Craig Ringer wrote: > Alain Roger wrote: > > I do not agree with you Sam. > > > > Stored procedure are safe from hacking (from external access). > > In that a stored procedure encapsulates a series of data operations, > m

Re: [GENERAL] SELECT DISTINCT ON and ORDER BY

2008-03-28 Thread Sam Mason
BY value, id) x ORDER BY order; No programming language will ever do exactly what you want straight away, it's a matter of using the tools it gives you. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] dunction issue

2008-03-28 Thread Sam Mason
On Sat, Mar 29, 2008 at 04:05:15AM +0900, Craig Ringer wrote: > Sam Mason wrote: > >>ALTER TABLE tmp_newsletterreg ADD CONSTRAINT simplistic_email_check > >>CHECK lower(trim(both ' ' from email)) LIKE '[EMAIL PROTECTED]'; > > > >Just ou

Re: [GENERAL] Escaping \n

2008-03-28 Thread Sam Mason
your database drivers are somehow mangling the statement somewhere between your code and the database. You could try running it locally from inside psql to find out. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Escaping \n

2008-03-28 Thread Sam Mason
On Fri, Mar 28, 2008 at 05:29:06PM -0400, Terry Lee Tucker wrote: > Thanks Sam. No, that is not what I tried. I had tried: > UPDATE bill SET notes = 'blah, blah, yeaE'\n'more stuff.' > It didn't dawn on me that the E went in front of the whole string! it's a

Re: [GENERAL] Using tables in other PostGreSQL database

2008-04-01 Thread Sam Mason
ut what this word means before using it too much as, again, it has a very specific technical meaning. However in Access you can perform a "Link Tables..." command which is what you may be describing, based upon the remainder of your description I doubt it though. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] choosing the right locking mode

2008-04-03 Thread Sam Mason
nd prevent possible collisions at the same time? This problem is always going to be awkward with a relational database though. The problem you want to solve is the opposite of their model. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] percentile rank query

2008-04-10 Thread Sam Mason
re) x, (SELECT count(*) AS total FROM scoretable) y ORDER BY score; Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Post-installation questions

2008-04-12 Thread Sam Mason
lls "Login Roles(1)". Users and Roles are very similar and all the old commands for dealing with users should still be there and automatically do the appropriate thing. If you don't get far, can you post the exact commands you're running and their responses and we may be able to

Re: [GENERAL] SQL injection, php and queueing multiple statement

2008-04-12 Thread Sam Mason
as early as possible. I personally think, and there's a lot of research saying the same thing, that statically-typed and safe languages with formally defined semantics are good tools here. PHP is a tool for writing code quickly, not for writing high assurance code. Sam -- Sent via p

Re: [GENERAL] No Return??

2008-04-13 Thread Sam Mason
e space between the ELSE and the IF which is introducing a new sub-expression. Either that, or move the RETURN after the final END IF. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Storage sizes for dates/times (documentation bug?)

2008-04-15 Thread Sam Mason
sion can occur (and seems to occur reasonably often based on previous posts to the mailing lists) suggests that the docs should highlight the differences more clearly. I'd also hazard a guess that we don't hear about it more because most people just work within a single time zone an

Re: [GENERAL] Storage sizes for dates/times (documentation bug?)

2008-04-15 Thread Sam Mason
On Tue, Apr 15, 2008 at 04:04:20PM +0200, Karsten Hilbert wrote: > On Tue, Apr 15, 2008 at 02:31:22PM +0100, Sam Mason wrote: > > On Tue, Apr 15, 2008 at 02:46:14PM +0200, Karsten Hilbert wrote: > > > Of course, the actual time stored in the database in UTC is > > > qu

Re: [GENERAL] Storage sizes for dates/times (documentation bug?)

2008-04-15 Thread Sam Mason
On Tue, Apr 15, 2008 at 06:48:27AM -0700, Adrian Klaver wrote: > On Tuesday 15 April 2008 6:31 am, Sam Mason wrote: > > My reasoning goes something like this: The WITH and WITHOUT clauses > > seem to be the opposite of my naive understanding of their purpose. I'd > >

Re: [GENERAL] generate_series woes

2008-04-16 Thread Sam Mason
providing hints (proofs would be the normal use) to the planner about what's going to happen when the code is run. This seems to imply that types couldn't be stored as OIDs any more (you'd be creating and destroying lots while planning the query) so would probably change the st

Re: [GENERAL] Storage sizes for dates/times (documentation bug?)

2008-04-16 Thread Sam Mason
On Wed, Apr 16, 2008 at 05:09:56PM +0200, Karsten Hilbert wrote: > On Tue, Apr 15, 2008 at 03:31:46PM +0100, Sam Mason wrote: > > But I was under the impression that you didn't want any time zone > > information. > Wrong impression. Doh, yes. > > I must be missing so

Re: [GENERAL] rounding problems

2008-05-12 Thread Sam Mason
changing the literals to represent values of different types and seeing how the result changes. You may get some mileage out of using EXPLAIN VERBOSE (you can see the cast being inserted in the 9./10 case, when compared to 9/10---function OID 1740 takes an int4 and returns a numer

Re: [GENERAL] Substring Problem

2008-05-13 Thread Sam Mason
runc, i.e.: SELECT date_trunc('month',date) AS yearmonth... I think it'll still realise it can use indexes (if they're appropriate) that way. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.

Re: [GENERAL] Conditional on Select List

2008-05-13 Thread Sam Mason
at the ELSE clause is executed when the expression evaluates to either NULL or FALSE, but because COUNT never returns a NULL value it doesn't matter here. It's also possible to have multiple WHEN clauses. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To

Re: [GENERAL] rounding problems

2008-05-14 Thread Sam Mason
floating point numbers will increase their errors. > i view the problem solved for 98% of problems. Floating point math is good for most problems, hence why most languages expose the abstraction. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make chan

Re: [GENERAL] rounding problems

2008-05-14 Thread Sam Mason
0.00 Which looks reasonable. Remember that floating point numbers store their state in base two, not base ten. All of those numbers look good to 15 decimal digits. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: htt

Re: [GENERAL] rounding problems

2008-05-14 Thread Sam Mason
On Wed, May 14, 2008 at 02:08:47PM -0400, Justin wrote: > Sam Mason wrote: > >What does foxpro use for storing numbers? or is it just that you never > >pushed it hard enough for the abstractions to show through. > > I know i pushed it. Foxpro for the most has onl

Re: [GENERAL] Vacuuming on heavily changed databases

2008-05-19 Thread Sam Mason
s where new data can be written. If the FSM is too small then PG will grow the table even though there is free space in the table (because it doesn't know it exists). VACUUM will normally give error messages about the FSM map being too small, that and the fact that you didn't mentione

Re: [GENERAL] Vacuuming on heavily changed databases

2008-05-19 Thread Sam Mason
On Mon, May 19, 2008 at 06:21:18PM +0100, Sam Mason wrote: > for t in foo bar baz > do ( while echo "VACUUM $t;" && false ; do true ; done | psql ) & > done oops, that "&& false" shouldn't be there! like like this: for t in foo bar

Re: [GENERAL] Join three fields into one on same table

2008-05-19 Thread Sam Mason
d guess the OP doesn't want the sub-query, if he posted the error message we'd know for sure. I'd guess something like: update table set date=(year||'-'||month||'-'||day||'01:00:00')::date; If the "date" column really is of date type, the

[GENERAL] intagg memory leak

2008-06-06 Thread Sam Mason
ve my immediate problem, but if anyone has any better solutions that would be great. I'm assuming the arrays that int_array_aggregate() returns aren't ever getting released. Memory usage goes to a few gigs (it's a 32bit build) before bombing out. Thanks, Sam [1] http://w

Re: [GENERAL] Database design: Storing app defaults

2008-06-18 Thread Sam Mason
idental. The main reason I'd do this is because it's solving a different problem, that of providing global defaults vs. table specific defaults. I'm not sure how you'd get all the types to match up, but then again this whole scheme of providing defaults seems a little alien to an

[GENERAL] Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)

2008-06-18 Thread Sam Mason
ning within a system are running on top of the cache they don't know or care whether the cache actually matches up to the disk. Therefore, if I understand things correctly, the state of fsync shouldn't matter in this use case. It's equally borken independent to the state of fsy

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Sam Mason
ed off, once this is running you can then run 8.3's version of pg_dump against it, then you can restore this dump into the new version of PG. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Sam Mason
umpall in /usr/bin/. pgdumpall (and pgdump by default) will produce output in SQL format. Restoring is just a simple matter of: psql dbname -f pg814data.sql Hope that helps! Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://

Re: [GENERAL] Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)

2008-06-18 Thread Sam Mason
On Wed, Jun 18, 2008 at 02:17:00PM -0400, Greg Smith wrote: > On Wed, 18 Jun 2008, Sam Mason wrote: > > >Isn't fsync only a side-effect of having a write-back cache between > >programs and the disk? This means it's only purpose is to ensure that > >the cache

Re: [GENERAL] Understanding fsync

2008-06-19 Thread Sam Mason
;s buffer cache. To summarize, fsync can be turned off when the user is unconcerned with power loss and when backups are always performed at the filesystem level. Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] finding firstname + lastname groups

2008-06-19 Thread Sam Mason
AVING COUNT(*) > 1; Sam -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] pg_dump estimation

2008-06-25 Thread Sam Mason
On Tue, Jun 24, 2008 at 11:13:14PM -0500, Marcelo Martins wrote: > is there a way to find out / calculate / estimate how big a pg_dump > using plain text format for a DB will be ? How about simply doing: pg_dump | wc -c Sam -- Sent via pgsql-general mailing list (pgsql-g

Re: [GENERAL] newbie table design question

2009-06-01 Thread Sam Mason
same order each time. Another thing you can get PG to do would be a constraint like: CHECK (time = date_trunc('minute',time)) this would ensure that you get at-most one entry per minute and that it's on the minute. This sort of thing should make some sorts of queries easier. -

Re: [GENERAL] xml to table (as oppose to table to xml)

2009-06-01 Thread Sam Mason
ious versions[2] have been posted to this list for older versions). -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/functions-xml.html#FUNCTIONS-XML-PROCESSING [2] http://archives.postgresql.org/message-id/b88c3460905290021o6870bb46tec88ced0c4064...@mail.gma

Re: [GENERAL] xml to table (as oppose to table to xml)

2009-06-01 Thread Sam Mason
r code, or even do the parsing from XML to something more structured outside PG. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] newbie table design question

2009-06-01 Thread Sam Mason
out its support for arrays. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Division by zero

2009-06-04 Thread Sam Mason
You need to take care of only one case here: denominator == 0; rest of the > cases will be handled sanely by the database. > > CASE WHEN packet_size = 0 THEN null ELSE cost/packet_size END as unit_cost Yes; or even shorter: cost/nullif(packet_size,0) AS unit_cost -- Sam htt

Re: [GENERAL] Division by zero

2009-06-04 Thread Sam Mason
On Thu, Jun 04, 2009 at 09:48:17AM -0400, Tom Lane wrote: > Sam Mason writes: > > If it's an SQL function and marked as IMMUTABLE it should (I believe > > anyway) get inlined somewhere along the line and take no more overhead > > than writing it out in full. > &g

Re: [GENERAL] Division by zero

2009-06-04 Thread Sam Mason
replace "WHERE fn_i" with "WHERE fn_v". I read this as it not inlining where I'd expect it to be, or am I missing something else? -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Division by zero

2009-06-04 Thread Sam Mason
On Thu, Jun 04, 2009 at 11:17:39AM -0400, Tom Lane wrote: > Sam Mason writes: > > I think that with 8.3 at least I'm going to carry on putting > > IMMUTABLE on where I think it should be. Consider: > > there are corner cases where it's useful to have the function

Re: [GENERAL] search for partial dates

2009-06-12 Thread Sam Mason
$ LANGUAGE sql STABLE; Why not use the to_char function[1]: SELECT to_char($1,'MMDD'); This is better because TEXT(dateval) doesn't have to give a string back in the form -MM-DD, it just does by default. Readability also seems to improve when using to_char. -- S

Re: [GENERAL] String Manipulation

2009-06-12 Thread Sam Mason
#x27;^[0-9]+'),7); If this is so that you can sort things based on their numeric order, why not just convert it to an integer rather than doing any padding? -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscri

Re: [GENERAL] String Manipulation

2009-06-12 Thread Sam Mason
unctions like this get added with each major version. Most useful docs for you are in: http://www.postgresql.org/docs/current/static/functions-string.html You can get to older releases quickly by replacing "current" with things like "8.2" and "7.4". -- Sam http:/

Re: [GENERAL] String Manipulation

2009-06-12 Thread Sam Mason
\h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit sam=> SELECT substring('1a','^[0-9]+'); substring --- 1 (1 row) sam=> -- Sam http://samason.

Re: [GENERAL] Dynamic table

2009-06-16 Thread Sam Mason
..) and the other for the actual measurement. Just had a quick flick through your previous posts; and I'd probably stick with the multiple tables approach. It's the most natural fit to relational databases and until you know more about the problem (i.e. you've experienced the data your

Re: [GENERAL] Dynamic table

2009-06-16 Thread Sam Mason
e decisions wouldn't be as forced as you're making it. Design is about picking and choosing between compromises and without knowing what the choices are you can't design anything, this is one of the problems with tests. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] Too many postgres instances

2009-06-18 Thread Sam Wun
Hi, Can anyone explain to me why my system is spawn so many postgress instances? System: FreeBSD 7.2 Stable I386 RAM: < 1GB Here is the output of the top command: Mem: 457M Active, 92M Inact, 150M Wired, 23M Cache, 85M Buf, 18M Free Swap: 999M Total, 150M Used, 849M Free, 14% Inuse Here is a lis

Re: [GENERAL] Slight change in query leads to unexpected change in query plan

2009-06-22 Thread Sam Mason
You may get better results with increasing the statistics target[1] for those columns as that will give PG more information, but if the columns are indeed correlated then that's not going to help. -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/sql-alter

Re: [GENERAL] Why my queryes doesnt not use indexes?

2009-06-22 Thread Sam Mason
probably want to probably want to do the following when creating the index: > CREATE INDEX users_nick_index ON users (nickname varchar_pattern_ops); That will allow PG to use the index in LIKE expressions. For more details see: http://www.postgresql.org/docs/current/static/indexes-opclass.ht

Re: [GENERAL] Can't start postgresql 8.3.7

2009-06-25 Thread Sam Wun
I copied the sample config file to postgresql workign directory before trying to start postgresql: # pwd /usr/local/share/postgresql twp1:postgresql # cp postgresql.conf.sample ../../pgsql/data/postgresql.conf On Fri, Jun 26, 2009 at 4:04 PM, Sam Wun wrote: > Hi, > > I had been running p

[GENERAL] Can't start postgresql 8.3.7

2009-06-25 Thread Sam Wun
Hi, I had been running postgresql 8.3.7 in freebsd for some time, but after I changed its postgresql.conf file, it can't start any more eventhoguh I changed the config back to its original file. Anything wrong? Here is the errros: Jun 26 15:58:52 twp1 postgres[1394]: [1-1] FATAL: could not crea

Re: [GENERAL]

2009-06-30 Thread Sam Mason
T * FROM a LEFT JOIN b ON a.id = b.id AND (b.id IS NULL OR a.c <> b.d) and I can't think of any other formulations after reading the link you gave---it only seems to talk about binary operators involving columns from two tables. Second shouldn't be allowed, but I included

Re: [GENERAL] singletons per row in table AND locking response

2009-07-10 Thread Sam Mason
quot;share" locks (multiple transactions can have a share lock on any table or row) and "update" locks (this locks out share and other update locks). -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscri

Re: [GENERAL] INSERT only unique records

2009-07-12 Thread Sam Mason
FROM from_t f LEFT JOIN to_t t ON f.num = t.num WHERE f.num > 2 AND t.num IS NULL; The SELECT DISTINCT part tells the database to only return distinct values from the query. The LEFT JOIN tells the database to filter out anything that already exists in the "to_t" table. --

Re: [GENERAL] xpath() subquery for empty array

2009-07-12 Thread Sam Mason
you're using unusual bounds on your array. Bah, the semantics of arrays in PG always seem over-complicated to me! -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] xpath() subquery for empty array

2009-07-12 Thread Sam Mason
<> [test for empty array?] Something like the following should do the right thing: SELECT x FROM ( SELECT xpath('//entry[contains(p, ''searchtext'')]/@*', docxml) AS x FROM docs) AS y WHERE array_upper(x, 1) > 0; -- Sam http://samas

Re: [GENERAL] pg_dump of a big table

2009-07-13 Thread Sam Mason
ld run pg_dump on another host, or do something like: pg_dump mydb | gzip | ssh otherbox "cat > out.sql.gz" -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] filter duplicates by priority

2009-07-14 Thread Sam Mason
ifferent priority becomes a distinct > tuple. I think you just want to swap the ORDER BY columns around; i.e: ORDER BY part_number, priority -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Timestamp indicies not being used!

2009-07-19 Thread Sam Mason
identifier you specified. BTW, if you're concerned about insert performance then the less indexes you have the better. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Timestamp indicies not being used!

2009-07-19 Thread Sam Mason
On Sun, Jul 19, 2009 at 02:56:04PM +0200, Andreas Kretschmer wrote: > Sam Mason wrote: > > The problem with just having an index on either column is that it's > > difficult to combine them and PG hence just thinks that it will be > > Since 8.1 PG can do an bitmap ind

Re: [GENERAL] PG handling of date expressions

2009-07-19 Thread Sam Mason
casting and forcing users to explicitly say that this is what they want. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] timestamp with time zone tutorial

2009-07-19 Thread Sam Mason
not had to solve a hard problem here. > (3) Give input to me so that I can write a good tutorial to post on >the postgres site? There's already a page on the postgres wiki about this[3], maybe something needs clarifying? -- Sam http://samason.me.uk/ [1] http:/

Re: [GENERAL] Should I CLUSTER on PRIMARY KEY

2009-07-19 Thread Sam Mason
ng for every table and almost certainly not just blindly doing it on the table's primary key. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Best practices for moving UTF8 databases

2009-07-21 Thread Sam Mason
\xBF]{3}|$$|| -- planes 4-15 $$\xF4[\x80-\x8F][\x80-\xBF]{2}$$|| -- plane 16 '*)$' ); This seems to do the right thing for me in an SQL_ASCII database. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] element from an array by its index

2009-07-21 Thread Sam Mason
NCTION array_index(anyarray,int) RETURNS anyelement IMMUTABLE LANGUAGE sql AS $$ SELECT $1[$2]; $$; -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] element from an array by its index

2009-07-21 Thread Sam Mason
On Tue, Jul 21, 2009 at 02:29:12PM -0400, Merlin Moncure wrote: > On Tue, Jul 21, 2009 at 10:47 AM, Sam Mason wrote: > > On Tue, Jul 21, 2009 at 04:08:51PM +0600, Murat Kabilov wrote: > >> I would like to know if there is a function that extracts an element by its > &

Re: [GENERAL] How would I get information regarding update when running for a long time?

2009-07-22 Thread Sam Mason
that the id column in those tables uniquely identify the rows in the table? This isn't going to make it slow, but will cause you to get a non-deterministic (i.e. normally "wrong") answer. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgre

Re: [GENERAL] Best way to import data in postgresl (not "COPY")

2009-07-22 Thread Sam Mason
enerating CSV files and hence will probably be easier to get correct. -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/sql-copy.html -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Select Column Auditing/Logging

2009-07-22 Thread Sam Mason
ike this be more amenable to optimization: CREATE FUNCTION tbl_auditor() RETURNS BOOLEAN IMMUTABLE AS $$ logquery; RETURN TRUE; $$; CREATE VIEW tbl_view AS SELECT * FROM tbl WHERE tbl_auditor(); -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-g

Re: [GENERAL] Best practices for moving UTF8 databases

2009-07-22 Thread Sam Mason
at least that's what looks strange to me now--not sure how it got moved though! -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] problem with pg_restore?

2009-07-23 Thread Sam Mason
oblems displaying million character > lines, > > I expect ther big guns "vim" and "emacs" also have no problems with > long lines. GNU Emacs is fine; just tried with a line consisting of a million copies of "helloworld " and it was a bit slow with som

Re: [GENERAL] A question on PSQL 8.3 setup

2009-07-23 Thread Sam Mason
orks then you've got the option of dumping the old data that was stashed away above and update the config file to point straight to the new location. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscripti

Re: [GENERAL] comparing NEW and OLD (any good this way?)

2009-07-23 Thread Sam Mason
cks#Attention_on_IS_NULL_and_IS_NOT_NULL_operators_for_composite_types is scary; even worse is that it was changed to be like this in 8.2 because the standard says it should behave this way. What on earth were they thinking when they defined the standard this way? -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing l

Re: [GENERAL] problem with pg_restore?

2009-07-23 Thread Sam Mason
usly for large files (i.e. a GB and over) it's not going to work, but I'd still expect tools to work ("less -n" seems to be my tool of choice at the moment). -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make chan

Re: [GENERAL] Very slow joins

2009-07-25 Thread Sam Mason
atly only foreign key constraints are affected by this setting, but I believe there are plans to extend this further. -- Sam http://samason.me.uk/ http://www.postgresql.org/docs/current/static/sql-set-constraints.html -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To ma

Re: [GENERAL] Is there a RECORD[] type in plpgsql?

2009-07-25 Thread Sam Mason
ave to run the query twice? Wouldn't that be a temporary table? -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Content-Type in form variables

2009-07-25 Thread Sam Mason
uments; python makes this sort of thing reasonably easy if you want to stay reasonably low level or there are lots of frameworks around to simplify things. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subs

Re: [GENERAL] Relational Algebra and Aggregate Functions

2009-07-26 Thread Sam Mason
s a "fold" from normal functional programming. The Wikipedia page is a reasonable description: http://en.wikipedia.org/wiki/Fold_(higher-order_function) Not sure how helpful that is though! -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@post

Re: [GENERAL] Join tables by nearest date?

2009-07-27 Thread Sam Mason
sers u, users_locations l WHERE u.id= l.user_id AND u.birthday <= l.created ORDER BY u.id, l.created Untested, but hopefully gives enough hints about where to look! -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/sql-select.html#SQL-DISTINCT --

Re: [GENERAL] Relational Algebra and Aggregate Functions

2009-07-28 Thread Sam Mason
instance, there are 10 bags each weighing 5 lbs, and > you want SUM(weight) - you need to project weight onto a collection which > allows for 10 occurences, or define the aggregate function to work on the > whole tuple somehow... I know a man named Krug worked out a formal theory > for this...

Re: [GENERAL] Relational Algebra and Aggregate Functions

2009-07-28 Thread Sam Mason
On Tue, Jul 28, 2009 at 11:26:01AM -0400, Robert James wrote: > On Tue, Jul 28, 2009 at 9:47 AM, Sam Mason wrote: > > On Tue, Jul 28, 2009 at 09:14:38AM -0400, Robert James wrote: > > > Many wrote that the functional programming 'fold' is a good model for > > &g

Re: [GENERAL] comparing NEW and OLD (any good this way?)

2009-07-29 Thread Sam Mason
On Wed, Jul 29, 2009 at 01:15:27PM +, Jasen Betts wrote: > On 2009-07-23, Sam Mason wrote: > > > > http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks#Attention_on_IS_NULL_and_IS_NOT_NULL_operators_for_composite_types > > > > is scary; even worse is that it

Re: [GENERAL] Clients disconnect but query still runs

2009-07-29 Thread Sam Mason
ng to test the client connections every once in a while to see if they're still valid. The postmaster seems like a reasonable place to do this to me, it has all the descriptors it just discards them at the moment. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing

Re: [GENERAL] integration of fulltext search in bytea/docs

2009-07-29 Thread Sam Mason
e bytea value out into the filesystem. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] integration of fulltext search in bytea/docs

2009-07-30 Thread Sam Mason
On Thu, Jul 30, 2009 at 03:09:12PM +0200, Radek Novotnnn wrote: > Is there possible to create pg trigger that runs shell script? Yes, pl/perl can do this. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to y

Re: [GENERAL] Can't execute function

2009-07-30 Thread Sam Mason
ot;pNOME" varchar, "pNOME_ABREV" varchar, [..] > VALUES ( pID_SOCIEDADE, You're mixing and matching quoting of identifiers, sometimes you use "pID_SOCIEDADE" and other times just pID_SOCIEDADE (i.e. without the quotes) and these are different identifiers. You need to pick

Re: [GENERAL] Design Database, 3 degrees of Users.

2009-07-31 Thread Sam Mason
PG, the things that will help you are roles[1], views[2], and functions[3] with "security definer" set. -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/user-manag.html [2] http://www.postgresql.org/docs/current/static/sql-createview.html [3] http://www.

Re: [GENERAL] Grouping Question

2009-07-31 Thread Sam Mason
unction ? Either use something like date_trunc[1], convert it to a string with to_char[2], or create a table that contains what you consider to be your week ranges in (i.e. year, week, startdate, enddate). -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/functi

Re: [GENERAL] Division by zero

2009-08-02 Thread Sam Mason
s going to be less of an issue with division that other operators, but it's worth bearing in mind. The "IMMUTABLE" options is a good one to specify though, keep that! -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Division by zero

2009-08-02 Thread Sam Mason
On Sun, Aug 02, 2009 at 02:20:18PM +0200, Pavel Stehule wrote: > 2009/8/2 Sam Mason : > > On Sun, Aug 02, 2009 at 12:08:28PM +0100, Oliver Kohll - Mailing Lists > > wrote: > >> CREATE OR REPLACE FUNCTION gtpb_divide(integer, integer) RETURNS integer > >

<    1   2   3   4   5   6   7   8   9   >