Re: [SQL] OFFSET and subselects

2003-11-28 Thread Greg Stark
[EMAIL PROTECTED] (Dmitri Bichko) writes: > I am running in trouble with pagination here, somehow (rather naively) I > assumed that when doing a LIMIT and OFFSET, the subselects on the records > before the OFFSET would not be performed, which quite apparently is not the > case. So, LIMIT 50 OFFSE

[SQL] Infinite loop crashes server

2003-11-28 Thread George A.J
hi all, i am using PostgreSQL 7.3.2 on redhat linux 9. there is problem when executing pl/pg sql functions. if the function enter an infinite loop. the server is hanged. cannot cancel the query. the linux itself is hanged.i cannot kill postgres process. i have to reboot the machine manually.. waite

Re: [SQL] Stored procedures and relations

2003-11-28 Thread Stephan Szabo
On Fri, 28 Nov 2003, FET wrote: > Hi everybody, > I have a stored procedure that drops table A and then creates table A > again. The table A has no constraints on any columns. When I execute > the stored procedure by saying: SELECT sp_myproc(); It gives me an > error saying : Relation 68428 does

Re: [SQL] explicit joins wrong planning

2003-11-28 Thread Tomasz Myrta
Dnia 2003-11-28 22:57, Użytkownik Tom Lane napisał: Restructure planning of nestloop inner indexscans so that the set of usable joinclauses is determined accurately for each join. Formerly, the code only considered joinclauses that used all of the rels from the outer side of the join; thus for

Re: [SQL] Do update permissions require select permissions

2003-11-28 Thread Tom Lane
[EMAIL PROTECTED] (Chris Piker) writes: > Now as some other user one can do: >update data set stuff = 'other stuff'; > And it works okay. But the following fails: >update data set stuff = 'yet other stuff' where id = 1; > Why is this? Because the latter requires reading, not only writin

Re: [SQL] explicit joins wrong planning

2003-11-28 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > It's much better now (10x faster), but I've just found this plan still > isn't as I want to have. I wish I could have index usage on both fields, FWIW, I see this plan in 7.4 using your original test case: Nested Loop (cost=22.51..71.79 rows=1 width=

Re: [SQL] Bug: Sequence generator insert

2003-11-28 Thread Bruno Wolff III
On Tue, Nov 25, 2003 at 18:37:41 -0500, "Burr, Colin" <[EMAIL PROTECTED]> wrote: > > However, even though the new record failed to be inserted into the table, > the sequence generator was still updated. > > The sequence generator should only be updated if the record is successfully > inserted i

Re: [SQL] rules and return values question

2003-11-28 Thread Rod Taylor
> tables but it introduces too much overhead. In any case, we need the return > value (or an exception) from the function but there does not seem a way to > return it. Can't you use erreport() to return an exception message? ---(end of broadcast)-

Re: [SQL] explicit joins wrong planning

2003-11-28 Thread Tomasz Myrta
Dnia 2003-11-28 20:52, Użytkownik Tom Lane napisał: Tomasz Myrta <[EMAIL PROTECTED]> writes: If I add "and k.id_trasy=lt.id_trasy" into where clause (duplicate), the query works fine. Define "works fine", please (again, EXPLAIN ANALYZE would be a nice concrete description). Sorry, I thought th

[SQL] functional index and the planner (v7.4)

2003-11-28 Thread Roger Ging
I just installed v7.4 and restored a database from v7.3.4. I have an index based on a function that the planner is using on the old version, but doing seq scans on left joins in the new version. I have run analyze on the table post restore. the query returns in less than 1 second on version 7

[SQL] Do update permissions require select permissions

2003-11-28 Thread Chris Piker
I have run across a problem while creating a database with row level permission checking via views and triggers. The just of which is update does not work for a user unless they also have select permissions. Select permissions are handled with a view, while insert, update and delete permissions a

[SQL] Bug: Sequence generator insert

2003-11-28 Thread Burr, Colin
Dear Sir, I found a sequence generator software bug associated with duplicate key inserts that may be of interest to you. I first created a table with a primary key based on a sequence generator. The following script provides an example. CREATE SEQUENCE "id_seq" start 1 increment 1 maxvalue 21474

[SQL] Unsigned numbers

2003-11-28 Thread Kaloyan Iliev Iliev
Hello Friends, I have the following questions. I have a lot of fields in my database that are int or float. The problem is that I need them to be only positive (unsigned) and the users try to insert sometimes negative. I know that I can make this with CHECK CONSTRAINT but for some reasons this i

[SQL] Stored procedures and relations

2003-11-28 Thread FET
Hi everybody, I have a stored procedure that drops table A and then creates table A again. The table A has no constraints on any columns. When I execute the stored procedure by saying: SELECT sp_myproc(); It gives me an error saying : Relation 68428 does not exist. When I remove the CREATE FUNCTIO

Re: [SQL] SQL a simple menu - plz help

2003-11-28 Thread Randolf Richardson
>> Here, this link should help: >> >> Search PostgreSQL - Opera >> http://www.postgresql.org/search.cgi?q=connectby > > Thanks...rtfm I know :) RTFM? Oh, yeah, that's right -- Read The /FUNNY/ Manual! =D -- Randolf Richardson - [EMAIL PROTECTED] Vancouver, British

[SQL] rules and return values question

2003-11-28 Thread Mujdat Pakkan
We have an interesting case where we want to use Postgres both as a database and a front end to a proprietary database. For the latter, we wrote functions that access the proprietary database. Then we defined views on the proprietary database and wrote rules for insert/update/delete on those views

[SQL] OFFSET and subselects

2003-11-28 Thread Dmitri Bichko
I recently noticed a behaviour which seems quite suboptimal - I am working on a "mart" type application, which in practice means I end up with queries which have a few filters on several central tables, and then a few dozen subselects for other info (which seems to perform better than several dozen

Re: [SQL] How to quote date value?

2003-11-28 Thread nobody
I have found it in documentation, it is single quote. But it does not explain why SELECT '1/11/2003' AS "InvoiceDate"; returns "unknown" data type instead of "date". "nobody" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What is correct character to quote date values in SELECT. I

[SQL] How to quote date value?

2003-11-28 Thread nobody
What is correct character to quote date values in SELECT. Is is single quote? When I do: SELECT '1/11/2003' AS "InvoiceDate"; the returned value is of unknown type (not a date). Then I tried: SELECT 1/11/2003 AS "InvoiceDate"; and the InvoiceDate was set to zero (I guess the engine divided th

Re: [SQL] Expressional Indexes

2003-11-28 Thread Randolf Richardson, DevNet SysOp 29
[sNip] >> bearing in mind that this index can be used with queries that contain >> WHERE conditions like "create_date >= some-date-constant". The planner >> must be able to convince itself that the right-hand side of the WHERE >> condition is >= the cutoff in the index's predicate condition. Sinc

Re: [SQL] How to quote date value?

2003-11-28 Thread terry
If you want an explicit date, then cast it like this: SELECT '1/11/2003'::date AS "InvoiceDate"; Terry Fielder Manager Software Development and Deployment Great Gulf Homes / Ashton Woods Homes [EMAIL PROTECTED] Fax: (416) 441-9085 > -Original Message- > From: [EMAIL PROTECTED] > [mailt

[SQL] Maintaining an order for a group of records

2003-11-28 Thread Bruno De Fraine
Hello group, I'm looking for a neat way to accomplish the following with PostgreSQL. In a table, I have a group of records for which I want to store an order. The order has nothing to do with the data of the records; on the contrary, the order of the records might change without the (other) dat

Re: [SQL] SQL a simple menu - plz help

2003-11-28 Thread Randolf Richardson, DevNet SysOp 29
> As subj says. A simple menu is defined in a table. But how to extract > it? Heres the deal: > > Table menu has these 3 columns: menuidparentmenudesc > > Ok this should be easy right? Those menu-rows that has parent=0 is > "toplevel". And so forth. An example: > > 10"Items" > 2

Re: [SQL] How to quote date value?

2003-11-28 Thread nobody
Thanks, I learnt to use: SELECT CAST('1/11/2003' AS DATE) AS invoice_number; and it does what I would expect ;-). "Stephan Szabo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Fri, 21 Nov 2003, Gaetano Mendola wrote: > > > nobody wrote: > > > I have found it in documentation

Re: [SQL] SQL a simple menu - plz help

2003-11-28 Thread Randolf Richardson, DevNet SysOp 29
>> You're in need of the "CONNECT BY" option which is ideal for >> scenarios such as yours. Unfortunately PostgreSQL doesn't have it >> yet, but I believe there is a PLSQL script (or something like this) >> which emulates the CONNECT BY behaviour and it's called "connectby()" >> or something l

Re: [SQL] explicit joins wrong planning

2003-11-28 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > If I add "and k.id_trasy=lt.id_trasy" into where clause (duplicate), the > query works fine. Define "works fine", please (again, EXPLAIN ANALYZE would be a nice concrete description). regards, tom lane --

Re: [SQL] explicit joins wrong planning

2003-11-28 Thread Tomasz Myrta
Dnia 2003-11-28 20:18, Użytkownik Tom Lane napisał: Hard to say much when you didn't actually show us the output of EXPLAIN ANALYZE. OK, Here you are: explain analyze select * from plany pl join linia_trasy lt using (id_linii) join kursy k on (k.id_trasy=lt.id_trasy and k.event_date=pl.begind

Re: [SQL] explicit joins wrong planning

2003-11-28 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > Postgres doesn't use join on these both fields and doesn't use index > scan properly. Hard to say much when you didn't actually show us the output of EXPLAIN ANALYZE. regards, tom lane ---(end of broadcas

Re: [SQL] Scaler forms as function arguments

2003-11-28 Thread Greg Stark
Joe Conway <[EMAIL PROTECTED]> writes: > In 7.4 you could use an array. It would look like this: Though note that 7.4 doesn't know how to optimize this form: db=> explain select * from foo where foo_id in (1,2); QUERY PLAN