Re: [GENERAL] join from array or cursor

2009-08-21 Thread Sam Mason
On Fri, Aug 21, 2009 at 10:49:52AM -0400, Merlin Moncure wrote: > On Fri, Aug 21, 2009 at 10:17 AM, Sam Mason wrote: > > CREATE TYPE foo AS ( i int, j int ); > > > > SELECT (id((SELECT (1,2)::foo))).*; > > > > or am I missing something obvious? > > I t

Re: [GENERAL] join from array or cursor

2009-08-21 Thread Sam Mason
$1; $$; SELECT (id((1,2))).*; But this seems nasty and bumps up against the annoying "record type has not been registered" that I hit all to often. More fiddling gets to: CREATE TYPE foo AS ( i int, j int ); SELECT (id((SELECT (1,2)::foo))).*; or am I missing something obvious?

Re: [GENERAL] join from array or cursor

2009-08-21 Thread Sam Mason
elp to wrap the generate_series call into a function so you don't have to refer to "myPkArray" so many times. -- 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] Function for replace

2009-08-20 Thread Sam Mason
mat for literals that appear in your SQL code. 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] Postgre RAISE NOTICE and PHP

2009-08-20 Thread Sam Mason
When you get a response you know the email address is actually useful for contacting the user, rather than it being a typo and going somewhere 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: R: [GENERAL] Field's position in Table

2009-08-20 Thread Sam Mason
es that the column order is the same as when it was created but there are (unimplemented) suggestions about how to "fix" this. See for example: http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list

Re: [GENERAL] Temp table or normal table for performance?

2009-08-20 Thread Sam Mason
in ways > far too convoluted to use a single query with UNION and ORDER BY, and > then returning the results. Sounds like you want a temp table to keep things in; you can add an ON COMMIT DROP which should help keep things tidy. If you're on 8.4 the WITH clause may make this use

Re: [GENERAL] Wich the best way to control the logic of a web application?

2009-08-19 Thread Sam Mason
27;s just a character string to the database. To go to the other extreme, referential integrity is (almost?) always best done inside the database as it has all the information needed to do the right thing. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@pos

Re: [GENERAL] Monitoring the sequence cycles

2009-08-19 Thread Sam Mason
n and hence if you write something into a logging table you're going to loose it if the transaction rolls back. -- 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] text type has no default operator class for GIN?

2009-08-19 Thread Sam Mason
On Tue, Aug 18, 2009 at 08:21:49PM -0400, Tom Lane wrote: > Sam Mason writes: > > On Tue, Aug 18, 2009 at 03:50:47PM -0600, Bob Gobeille wrote: > >>> CREATE INDEX "ufile_name_search" ON "public"."uploadtree" USING GIN > >>> (&quo

Re: [GENERAL] text type has no default operator class for GIN?

2009-08-18 Thread Sam Mason
x on a plain TEXT column it's saying that it doesn't how to use those operators with a values of TEXT type. As soon as you pull this value apart (with the to_tsvector) you end up with something that PG can get some traction on and all is good. Maybe a useful question to ask is, what are y

Re: [GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 05:24:52AM -0700, John R Pierce wrote: > Sam Mason wrote: > > SELECT course, date, COUNT(*) > > FROM application_preferred_date > > GROUP BY course, date; > > the problem as stated is more complex than that. A student could, in > theory,

Re: [GENERAL] There are procedures in Postgres 8.3?

2009-08-18 Thread Sam Mason
about EnterpriseDB specific features, I'd recommend asking on EnterpriseDB forums. -- 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 database model for canvassing (and analysing) opinion

2009-08-18 Thread Sam Mason
9-08-28'), ('cs1234','database 101','2009-08-31'); If I wanted to know how many people wanted to do each course on each date, I'd just do: SELECT course, date, COUNT(*) FROM application_preferred_date GROUP BY course, date; Hope that gives you some ideas! -- 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] 2 versions of Postgres on the same machine

2009-08-18 Thread Sam Mason
untu) then this is how it works by default. You can have as many different "major" (i.e. 8.2, 8.3 and 8.4) versions installed and running at the same time as you want. Building from source isn't too hard though, it's the keeping it up to date that's more of a fiddle. --

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

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 10:32:35AM +0200, Daniel Verite wrote: > Sam Mason wrote: > > I've just realized another case where it's not consistent; why does the > > following return true: > > > > SELECT row(null) IS NULL; > > > > and yet the fol

Re: [GENERAL] Get most recent message between users?

2009-08-17 Thread Sam Mason
get the most recent message between two users? More details would help, but failing that how about: SELECT DISTINCT ON (to_user, from_user) id, to_user, from_user, created FROM messages ORDER BY to_user, from_user, created DESC; That would only chop out id=1 from the above list. -- Sam http

Re: [GENERAL] binary timestamp conversion

2009-08-17 Thread Sam Mason
he number of microseconds since 2000-01-01, otherwise it's a double representing the number of seconds since the same date. I don't know perl well enough to know if what you're doing is the right thing, but the values you're getting out don't look right to me. -- Sam h

Re: [GENERAL] design, plpgsql and sql injection in dynamically generated sql

2009-08-17 Thread Sam Mason
you seem to suggest then having them as separate functions would make this easier. If they really are that similar then you should have all the data in one table anyway! -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-17 Thread Sam Mason
On Mon, Aug 17, 2009 at 04:00:54PM +0200, Harald Fuchs wrote: > In article <20090816122526.gw5...@samason.me.uk>, > Sam Mason writes: > > > I've just had a look and PG does actually seem to be returning values as > > I'd expect, i.e. 0 <= n < 1. >

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

2009-08-17 Thread Sam Mason
ot; to mean the same as "v IS NOT DISTINCT FROM NULL", this being the same as "NOT (v IS DISTINCT FROM NULL) lots of times, but if I'm interested in knowing if a member of a RECORD is NULL then I want to know specifically which attribute it is. I think I'm saying that PG sho

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-17 Thread Sam Mason
On Mon, Aug 17, 2009 at 12:17:29PM +, Jasen Betts wrote: > On 2009-08-17, Sam Mason wrote: > (i.e. their internal state is the same as > > it was before) but individual numbers *will* be repeated. > > numbers will not be repeated intil the state wraps if the number > re

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Sam Mason
e I found recently is a SIMD implementation of the "Mersenne Twister" called SFMT[1]. -- Sam http://samason.me.uk/ [1] http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/ -- 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] Generating random unique alphanumeric IDs

2009-08-16 Thread Sam Mason
alled the birthday attack and it's one of the basic tests for hash functions--any bias in their output will shrink this number even further. -- 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] Generating random unique alphanumeric IDs

2009-08-16 Thread Sam Mason
ator is defined to return a value between 0 and 1 inclusive, it's generally much more useful if it runs from 0 to less than 1 and would mean that I wouldn't need the "mod" above and would remove the (slight) biasing towards choosing 'a'. -- Sam http://s

Re: [GENERAL] [Q] parsing out String array

2009-08-16 Thread Sam Mason
{A,B,C},{D,E,F}}'::text[]); and you'd get back your six rows. It appears to do the correct thing with arrays of higher dimensionality to me, but I only tried up to five. -- 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] [Q] parsing out String array

2009-08-15 Thread Sam Mason
o that PG doesn't get confused between the type declaration and the array indexing. -- 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] pgstatindex

2009-08-14 Thread Sam Mason
me PG spends trying to keep it full the more it's got to keep rearranging it, the more empty space there is the more time it's got to spend looking for the right thing. I don't really know if 80% is good here, but it doesn't sound bad. -- Sam http://samason.me.uk/ -

Re: [GENERAL] mail alert

2009-08-14 Thread Sam Mason
k forward to having such a feature in Postgres actually. Right > now, I'm using cron to do those checks. You could use one of the embedded languages (plperl or plpython) to do the sending of emails if you want. You'd still need something "outside" the database to actually start

Re: [GENERAL] adding a nullable col could rewrite the whole table?

2009-08-14 Thread Sam Mason
here are and hence each row knows if a new column is going to be off the end and means it doesn't need to rewrite the table when adding a new NULLable column. I made a suggestion about how to generalize this to non-NULLable columns with a default value, but haven't written a

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

2009-08-13 Thread Sam Mason
7;ve looked through I've not found anything definite either way. I think my interests here are more pedagogical that anything else, but PG's behavior is somewhat inconsistent and it could be nice to figure out what the "best" way of fixing these inconsistencies are. -- Sam

Re: [GENERAL] max_allowed_packet equivalent in Postgres?

2009-08-13 Thread Sam Mason
On Fri, Aug 14, 2009 at 12:03:37AM +0100, Greg Stark wrote: > On Thu, Aug 13, 2009 at 11:20 PM, Sam Mason wrote: > > Is it worth having a note about having enough memory floating around > > for those limits to actually be hit in practice?  There would be no > > way of creatin

Re: [GENERAL] max_allowed_packet equivalent in Postgres?

2009-08-13 Thread Sam Mason
Is it worth having a note about having enough memory floating around for those limits to actually be hit in practice? There would be no way of creating a row 1.6TB in size in one go, it would be ~800 UPDATE statements to get it up to that size as far as I can see. -- Sam http://samason.me.uk/

Re: [GENERAL] Selecting rows by content of array type field

2009-08-13 Thread Sam Mason
other way how to index this? Expressions? I think you want a GIN index; have a look at: http://www.postgresql.org/docs/current/static/indexes.html -- 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] Can I get Field informations from system tables?

2009-08-13 Thread Sam Mason
playing around with running psql with -E. -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/information-schema.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] array syntax and geometric type syntax

2009-08-13 Thread Sam Mason
#x27;s bad, I think it's mainly because it may mask other problems later on. It's not going to affect much fundamental either way though. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http:/

Re: [GENERAL] Looping through string constants

2009-08-13 Thread Sam Mason
me and other people about this. It's basically awkward interaction with the optimizer not being able to expand this out because it may change behavior. Try: http://archives.postgresql.org/pgsql-general/2009-06/msg00233.php IMMUTABLE is good though, don't go removing that

Re: [GENERAL] array syntax and geometric type syntax

2009-08-13 Thread Sam Mason
ble quotes. For example, if we evaluate the above: SELECT '{"elem1","elem2","elem_n"}'::TEXT[]; (sadly the normal literal syntax doesn't work for arrays) we get back: {elem1,elem2,n} So, PG has read in the literal, turned it into a real valu

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

2009-08-13 Thread Sam Mason
you don't stuff rows into columns :) When you say "columns", do you mean the value associated with a particular attribute in a particular row of a particular table? Surely this is a normal value and just because it happens to be stored in a table it shouldn't be any different f

Re: [GENERAL] Looping through string constants

2009-08-13 Thread Sam Mason
E 'sql' IMMUTABLE STRICT I'd recommend taking off the "STRICT" from this. It will, counter intuitively, slow things down when you're not expecting it. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make c

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

2009-08-12 Thread Sam Mason
On Wed, Aug 12, 2009 at 08:02:10PM +0200, Daniel Verite wrote: >Sam Mason wrote: > > But it seems to be a somewhat arbitrary choice to handle > > IS NULL for rows differently from everything else. > > For scalar or array types, "is null" means that the value hap

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

2009-08-12 Thread Sam Mason
eral case of an exponential increase in complexity, but it's still nasty. Anybody else think this thread is past it's bed time and should be put to rest? -- 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] comparing NEW and OLD (any good this way?)

2009-08-12 Thread Sam Mason
ow that consists entirely of NULL values being treated as NULL is OK, but some weird halfway house is horrible. Standards' conforming, but still horrible. -- 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] Help interpreting pg_stat_bgwriter output

2009-08-11 Thread sam mulube
30min checkpoint_segments = 10 checkpoint_completion_target = 0.9 Not sure what other config settings are pertinent here, but I can supply them if required. I am using postgresql 8.3.7-0ubuntu8.04.1, running on an OpenVZ VPS. Thanks for any pointers. Sam Mulube

Re: [GENERAL] PQstatus does not seem to work

2009-08-10 Thread Sam Mason
st as normal and if it fails because the connection was closed then you can open a new one and try again. -- 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] Arrays and LIKE

2009-08-08 Thread Sam Mason
ARY KEY (msgid, ord), type TEXT CHECK (type IN ('to','from','cc','bcc')), address TEXT ); CREATE INDEX mailaddrs_address_idx ON mailaddrs (address); then you can do: SELECT DISTINCT msgid FROM mailaddrs WHERE address ILIKE 'david%';

Re: [GENERAL] Getting linux $USER (and perhaps other env vars) in PL/pg-sql?

2009-08-07 Thread Sam Mason
rom a device that doesn't have "users"? Maybe the "current_user" variable[1] helps? -- Sam http://samason.me.uk/ [1] http://www.postgresql.org/docs/current/static/functions-info.html -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To ma

Re: [GENERAL] psql and Emacs on Windows

2009-08-07 Thread Sam Mason
above works fine on a linux box using emacs to access PostgreSQL. Yes, this is much more reliable in my experience. -- 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] batch inserts in python & libpq

2009-08-07 Thread Sam Mason
FROM (VALUES (1,'hi'), (2,'bye')) x(i,v) WHERE f.id = x.i; The "best" solution depends on the details of the problem though! -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscrip

Re: [GENERAL] Clients disconnect but query still runs

2009-08-06 Thread Sam Mason
there a way to get the list of SQL statements that were previously > executed as part of a given transaction? I'd play with logging and setting your "log_line_prefix"[1] to include the process id and "log_statement" to "all". It's then a simple matte

Re: [GENERAL] Update Query doesn't affect all records

2009-08-05 Thread Sam Mason
"sorrend::integer > 9" and it > > should work ;-) > > That's kinda what I was thinking at first, but the pastebin he posted > showed them in proper int type order. Also the fact that 12 "works". > Otherwise we're blind men describing an elephan

Re: [GENERAL] Does derby have an embedded Mode like Derby ?

2009-08-05 Thread Sam Mason
7;s the way things are. We can try and suggest ways to make writing your tests easier, but I'm not sure what else we can do. -- 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] Does derby have an embedded Mode like Derby ?

2009-08-05 Thread Sam Mason
common setup if you have 20+ test boxes!) than to bake in a large set of assumptions into your test scripts? -- 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] Does derby have an embedded Mode like Derby ?

2009-08-04 Thread Sam Mason
bad. See: http://wiki.postgresql.org/wiki/FAQ#Can_PostgreSQL_be_embedded.3F -- 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] parameters in functions and overlap with names of columns

2009-08-04 Thread Sam Mason
o declare local variables with an underscore prefix such as "_col1" in your example. > Is there another way other than just simply rename the variable? I don't think so. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)

Re: [GENERAL] Privilege problems: access denied on select for owner?

2009-08-03 Thread Sam Mason
issions to access it. You probably need to do: ALTER TABLE users OWNER TO sample; -- 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] \copy command error

2009-08-03 Thread Sam Mason
\copy is a special command in psql that does a copy from the system that psql is running in, rather than a normal COPY command that runs on the server. I believe \copy is implemented as a COPY FROM STDIN... with psql automatically piping the data over the connection for you. -- Sam http://sam

Re: [GENERAL] \copy command error

2009-08-03 Thread Sam Mason
trick You'll want to use the real CSV parser then, the code in psql would look like this: \copy gisp FROM 'd:/projects/gisp/gisp.csv' WITH CSV PG and MS Excel have an almost identical definition of what a CSV file should look like, opening the file in Excel is always a good quick check

Re: [GENERAL] using generate_series to iterate through months

2009-08-03 Thread Sam Mason
to generate a microsecond spaced series covering several years: CREATE FUNCTION generate_series(timestamp,timestamp,interval) RETURNS SETOF timestamp LANGUAGE plpgsql IMMUTABLE AS $$ DECLARE _c timestamp := $1; BEGIN WHILE _c < $2 LOOP RETURN NEXT _c;

Re: [GENERAL] character 0xe29986 of encoding "UTF8" has no equivalent in "LATIN2"

2009-08-02 Thread Sam Mason
special letters to > simple ones. It would be easy to write a regex to strip out the invalid characters if that's what you want. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.po

Re: [GENERAL] Division by zero

2009-08-02 Thread Sam Mason
On Sun, Aug 02, 2009 at 06:03:11PM +0200, Pavel Stehule wrote: > 2009/8/2 Sam Mason : > > On Sun, Aug 02, 2009 at 05:22:45PM +0200, Pavel Stehule wrote: > >> 2009/8/2 Sam Mason : > >> > On Sun, Aug 02, 2009 at 02:20:18PM +0200, Pavel Stehule wrote: > >> &

Re: [GENERAL] Division by zero

2009-08-02 Thread Sam Mason
On Sun, Aug 02, 2009 at 05:22:45PM +0200, Pavel Stehule wrote: > 2009/8/2 Sam Mason : > > On Sun, Aug 02, 2009 at 02:20:18PM +0200, Pavel Stehule wrote: > >> There is paradox - IMMUTABLE function break inlinig :(. There is maybe bug > > > > Not in any tests I'v

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 > >

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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-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] 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] 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] 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] 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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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

<    1   2   3   4   5   6   7   8   9   >