Re: [SQL] Problem using IP functions

2001-05-12 Thread Tom Lane
"Marc Lamothe" <[EMAIL PROTECTED]> writes: > The subnet_number column is a varchar(16) which I assume you can compare > with a text data type, which is what host() returns. Are you on a pre-7.1 Postgres release? host() is buggy before 7.1 --- it includes a trailing null in its output, which it s

[SQL] Problem using IP functions

2001-05-12 Thread Marc Lamothe
Hi, I'm having trouble using the host() and netmask() functions within a select query. For some reason, the following query returns 1 row: ipdb=> select id, subnet_number from subnet where subnet_number = '216.46.13.0'; id | subnet_number +--- 96 | 216.46.13.0 (1 row) Yet, if

Re: [SQL] SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)

2001-05-12 Thread Tom Lane
=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= <[EMAIL PROTECTED]> writes: > Surprisingly "-" is defined for (date, date). What's surprising about that? It yields an integer number of days between the dates: regression=# select '2001-06-12'::date - '2000-06-12'::date; ?column? -- 3

Re: [SQL] can't get rid of unnesesary SORT step in explain plan for hash join

2001-05-12 Thread Tom Lane
Alexey Nalbat <[EMAIL PROTECTED]> writes: > So, my question is: how can I get rid of this unnesesary "Sort" step > in the execution plan for hash join? You can't, because it's not unnecessary. Hash join doesn't promise to produce its outputs in any particular order. But the Unique filter needs

[SQL] SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)

2001-05-12 Thread Hans-Jürgen Schönig
The "+" operator is not defined for (date, date) which seems very logical to me since adding dates does in my opinion not make sense. performance=# SELECT timestamp('2001-06-12'::date + '2000-06-12'::date); ERROR: Unable to identify an operator '+' for types 'date' and 'date' You will ha

[SQL] Re: Informix->PostgreSQL database convertion

2001-05-12 Thread Sylte
How is the SQL command UNLOAD (informix) used to extract both data and database architecture? Is it able to create a file of SQL statements like when using postgresql's command "pg_dump -f outputfile mydb" ---(end of broadcast)--- TIP 6: Have yo

[SQL] can't get rid of unnesesary SORT step in explain plan for hash join

2001-05-12 Thread Alexey Nalbat
Hello. I need to make some sql-statement to be executed as fast as possible. :) My database consists of: 1) table of categories having 1'000 rows, 2) table of manufacturers having 1'000 rows, 3) table of resellers having 1'000 rows, 4) table of products having 1'000'000 rows. In the products t

Re: [SQL] Re: multi-table join, final table is outer join count ...

2001-05-12 Thread Tom Lane
The Hermit Hacker <[EMAIL PROTECTED]> writes: > SELECT distinct s.gid, s.created, count(i.title) AS images > FROM status s LEFT JOIN images i ON (s.gid = i.gid AND i.active), > personal_data pd, relationship_wanted rw >WHERE s.active AND s.status != 0 > AND (s.gid = pd.gid

Re: [SQL] Constraints...

2001-05-12 Thread Stephan Szabo
Yes. It depends on what exactly you want for the update/delete cases on permissions. I believe that in any cases you can use the check function that's used by the fk implementation to do the insert/update check on objects. If you don't mind update/deletes on permission failing if the row being

[SQL] Re: multi-table join, final table is outer join count ...

2001-05-12 Thread The Hermit Hacker
Got it after a bit of fiddling ... actually, not bad code ... SELECT distinct s.gid, s.created, count(i.title) AS images FROM status s LEFT JOIN images i ON (s.gid = i.gid AND i.active), personal_data pd, relationship_wanted rw WHERE s.active AND s.status != 0 AND (s.gid =

[SQL] multi-table join, final table is outer join count ...

2001-05-12 Thread The Hermit Hacker
Okay, not sure best way to try and describe this ... have multiple tables, of a form like: table a gid int data text table b gid int data text table c gid int data text table d gid int data text I want to return: a.gid,a.data,b

[SQL] Constraints...

2001-05-12 Thread Michael Richards
Does anyone know how I can make a constraint on a key to enforce a 1 to n relationship where n>0? I've invented an example to show the sort of constraint I need: CREATE TABLE permissions ( id int4, userid int4, perm int4, primary key (id,userid) ); CREATE TABLE objects ( id int4, per