Re: [SQL] how to determine array size

2003-06-10 Thread Forest Wilkinson
>> I need to enumerate the constraints on any given column in a table, so >> I'm examining pg_constraint to get the relevant information. The >> conkey array contains a list of constrained columns, and although I am >> able to check conkey[1] for constraints on a single column, I would >> like to

[SQL] how to determine array size

2003-06-09 Thread Forest Wilkinson
I need to enumerate the constraints on any given column in a table, so I'm examining pg_constraint to get the relevant information. The conkey array contains a list of constrained columns, and although I am able to check conkey[1] for constraints on a single column, I would like to properly handle

[SQL] Empty queries guaranteed to work?

2003-05-27 Thread Forest Wilkinson
Tom Lane mentioned in this post that an empty query can be sent to the server to determine whether the connection is still good: http://archives.postgresql.org/pgsql-hackers/2001-10/msg00643.php Is a query of "" guaranteed to work as long as the connection is good? What about ";" or " "? Backgro

[SQL] are NEW and OLD rule attributes broken?

2001-05-18 Thread Forest Wilkinson
(Postgres 7.0.3, linux kernel 2.4.2, i386, red hat 7.1) I'm trying to build rules to automatically populate several tables with references to any new rows inserted into a primary key table. The primary key is a sequence. Here's what's going on: mydb=# create table foo (fooid serial primary

[SQL] ON UPDATE CASCADE overhead?

2001-05-17 Thread Forest Wilkinson
If I add ON UPDATE CASCADE to my foreign key definitions, how much will it affect performance for queries that don't trigger the cascade? Cheers, Forest ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command

Re: [HACKERS] Re: [SQL] possible row locking bug in 7.0.3 & 7.1

2001-03-30 Thread Forest Wilkinson
On Thursday 29 March 2001 22:15, Tom Lane wrote: > > Just looked in heapam.c - I can fix it in two hours. > > The question is - should we do this now? > > This scares the hell out of me. > > I do NOT think we should be making quick-hack changes in fundamental > system semantics at this point of th

Re: [SQL] possible row locking bug in 7.0.3 & 7.1

2001-03-27 Thread Forest Wilkinson
On Tuesday 27 March 2001 15:14, Tom Lane wrote: > Forest Wilkinson <[EMAIL PROTECTED]> writes: > > session1<< create function nextid( varchar(32)) returns int8 as ' > > session1<< select * from idseq where name = $1::text for update; > > session1<&

[SQL] possible row locking bug in 7.0.3 & 7.1

2001-03-27 Thread Forest Wilkinson
t; commit; session2>> COMMIT session2<< select * from idseq; session2>> name | id session2>> --+ session2>> myid | 2 session2>> (1 row) session1<< select * from idseq; session1>> name | id session1>> --+ ses

Re: [SQL] unreferenced primary keys: garbage collection

2001-01-24 Thread Forest Wilkinson
On Wed, 24 Jan 2001 00:26:58 -0500 (EST), Michael Fork wrote: >One other method is to setup up the foreign keys as ON DELETE RESTRICT, >then outside of your transaction block issue a DELETE FROM address WHERE >add_id = 1; If there are still records in the other tables referencing >this record, i

Re: [SQL] unreferenced primary keys: garbage collection

2001-01-23 Thread Forest Wilkinson
gt;> arrange for it with custom trigger procedures, checking all >> the five tables on DELETE or UPDATE on one of them. Forest Wilkinson wrote: >> > I have a database in which five separate tables may (or may not) reference >> > any given row in a table of postal add

[SQL] unreferenced primary keys: garbage collection

2001-01-19 Thread Forest Wilkinson
transaction. This is clearly undesirable. Isn't there some way to tell postgres *not* to roll back my transaction if a particular DELETE fails due to referential integrity? Are there any other options that might help me? Regards, Forest Wilkinson

Re: [SQL] Using a postgres table to maintain unique id?

2000-11-13 Thread Forest Wilkinson
On 13 Nov 2000 10:30:55 PST, Dr Frog wrote: >create sequnece seq_name ; > >there are additional options >start sql and type What are the "SQL" and "TYPE" options? I don't see reference to them in the docs. Can I use the TYPE option to create a sequence that's based in int8 (64 bit integer) in

[SQL] alter table add column implementation undesirable?

2000-11-09 Thread Forest Wilkinson
true? Forest Wilkinson

Re: [SQL] how to index a numeric(12,2) column?

2000-11-08 Thread Forest Wilkinson
>> I'd like to create an index on a column whose type is NUMERIC(12,2). >> There appears to be no default operator class for the numeric type. > >Uh, what version are you using? Works fine for me in 7.0.2. Sorry; I hit send before adding that information. I'm using postgres 6.5.3 on i386 Red Ha

[SQL] how to index a numeric(12,2) column?

2000-11-07 Thread Forest Wilkinson
I'd like to create an index on a column whose type is NUMERIC(12,2). There appears to be no default operator class for the numeric type. What class should I use instead? My guess is that something like this might work: CREATE INDEX foo_idx on foo (bar int8_ops); Will that work properly? Will

[SQL] transactions surrounding extension functions

2000-09-28 Thread Forest Wilkinson
former behavior would be dangerous, while the latter behavior would be desirable. Thanks, Forest Wilkinson

[SQL] Re: SQL functions not locking properly?

2000-09-26 Thread Forest Wilkinson
ng postgres 7.0.2 now, but I discovered this problem (and the workaround) with 6.5.2 or 6.5.3. >I'm up to my armpits in subselect-in-FROM right now, but will put this >on my to-do list. Will look at it in a week or two if no one else has >fixed it before then... > > regards, tom lane Thanks, Tom. Please let me know when there's a fix. I can provide more detailed C source code if you need it, but I think the relevant parts of the code are expressed in this message. Forest Wilkinson

[SQL] SQL functions not locking properly?

2000-09-25 Thread Forest Wilkinson
; commit; session1>> COMMIT (session2 resumes) session2>> nextid session2>> session2>> 0 session2>> (1 row) What gives??? I expected the second call to nextid() to return 2! session1<< select * from idseq; session1>> name | id session1>> ------+ session1>> myid | 1 session1>> (1 row) session2<< select * from idseq; session2>> name | id session2>> --+ session2>> myid | 1 session2>> (1 row) As you can see, my nextid() function is not synchronized the way I hoped. I don't know why though. Can someone help? Thanks, Forest Wilkinson

Re: [SQL] C functions and int8?

2000-09-21 Thread Forest Wilkinson
Thu, 21 Sep 2000 10:32:50 +0200 (CEST), Karel Zak wrote: > >On Thu, 21 Sep 2000, Forest Wilkinson wrote: > >> I have written a few Postgres extension functions in C, and want to modify >> some of them to return an int8. However, I don't see any int8 definition >>

[SQL] C functions and int8?

2000-09-21 Thread Forest Wilkinson
I have written a few Postgres extension functions in C, and want to modify some of them to return an int8. However, I don't see any int8 definition in postgres.h. (I have the 7.0.2 RPMs installed.) How should I accomplish this?

[SQL] non-cachable 'C' language functions

2000-08-11 Thread Forest Wilkinson
ble. (In order for my_next_uid() to be useful, it must retrieve a new value each time it is used.) Is my understanding correct? What should I do about it? The postgresql 6.5.2 docs for CREATE FUNCTION don't tell me how to make my functions non-cachable. Regards, Forest Wilkinson

[SQL] How to get a self-conflicting row level lock?

2000-07-07 Thread Forest Wilkinson
I have become maintainer of a program that uses PostgreSQL 6.5.2 for database functionality. It is littered with code blocks that do the following: 1. SELECT * FROM some_table WHERE foo = bar FOR UPDATE; 2. -- Choose a new value for some_field, which might or might not be based on its origina