Re: [SQL] Distinct oddity

2009-05-12 Thread Maximilian Tyrtania
am 12.05.2009 19:23 Uhr schrieb Alvaro Herrera unter alvhe...@commandprompt.com: >> FAKDB=# CREATE DATABASE "TestLatin9" >> FAKDB-# WITH ENCODING='LATIN9' >> FAKDB-#OWNER=postgres; >> ERROR: encoding LATIN9 does not match server's locale de_DE >> DETAIL: The server's LC_CTYPE setting r

Re: [SQL] Distinct oddity

2009-05-12 Thread Maximilian Tyrtania
am 11.05.2009 16:38 Uhr schrieb Alvaro Herrera unter alvhe...@commandprompt.com: >>>Note that the de_DE locale uses Latin9 encoding, which is incompatible >>>with UTF8. >>> I'd try checking if the problem is reproducible in >>> de_DE.utf8 (you need to create a new database for testing, obviously)

Re: [SQL] Distinct oddity

2009-05-12 Thread Alvaro Herrera
Maximilian Tyrtania wrote: > am 11.05.2009 16:38 Uhr schrieb Alvaro Herrera unter > alvhe...@commandprompt.com: > > >>>Note that the de_DE locale uses Latin9 encoding, which is incompatible > >>>with UTF8. > >>> I'd try checking if the problem is reproducible in > >>> de_DE.utf8 (you need to crea

Re: [SQL] Array: comparing first N elements?

2009-05-12 Thread Achilleas Mantzios
Στις Tuesday 12 May 2009 11:05:28 ο/η David Garamond έγραψε: > I have a "materialized path" tree table like this (simplified): > > CREATE TABLE product ( > id SERIAL PRIMARY KEY, > parents INT[] NOT NULL, > name TEXT NOT NULL, > UNIQUE (parents, name) > ); > CREATE INDEX name ON pr

Re: [SQL] Array: comparing first N elements?

2009-05-12 Thread Glenn Maynard
On Tue, May 12, 2009 at 4:05 AM, David Garamond wrote: > Previously I use TEXT column for parents, but arrays look interesting and > convenient so I'm considering migrating to arrays. However, how do I rewrite > this using arrays? > SELECT * FROM product > WHERE parents LIKE '0001/0010/%'; > In ot

Re: [SQL] Array: comparing first N elements?

2009-05-12 Thread David Garamond
2009/5/12 Achilleas Mantzios > you would want to look at the intarray contrib package for index suppor and > many other goodies, > also you might want to write fucntions first(parents), last(parents) and > then have an index > on those as well. > This way searching for the direct children of a no

Re: [SQL] Array: comparing first N elements?

2009-05-12 Thread Pavel Stehule
Hello create or replace function eqn(anyarray, anyarray, int) returns boolean as $$ select not exists(select $1[i] from generate_series(1,$3) g(i) except select $2[i] from generate_series(1,$3) g(i)) $$ language sql immutable strict; postgre

Re: [SQL] Array: comparing first N elements?

2009-05-12 Thread David Garamond
On Tue, May 12, 2009 at 3:28 PM, Pavel Stehule wrote: > Hello > > create or replace function eqn(anyarray, anyarray, int) > returns boolean as $$ > select not exists(select $1[i] from generate_series(1,$3) g(i) > except > select $2[i] from gener

[SQL] Array: comparing first N elements?

2009-05-12 Thread David Garamond
I have a "materialized path" tree table like this (simplified): CREATE TABLE product ( id SERIAL PRIMARY KEY, parents INT[] NOT NULL, name TEXT NOT NULL, UNIQUE (parents, name) ); CREATE INDEX name ON product(name); Previously I use TEXT column for parents, but arrays look interes