[GENERAL] PLPython function and multiple line insert

2009-06-05 Thread Andi Klapper
Hi everyone, I hope, I am on the right list. If not my apology. I'd like to insert multiple lines as following with PLPython: SQL statement: INSET INTO table1 (field1, field2, field3) VALES ('abc', 'abc', TRUE), ('def', 'def', FALSE), ('ghi', 'ghi', TRUE);

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Tom Lane
Merlin Moncure writes: > On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane wrote: >> I think you can loop over the results in plpgsql, for instance > also sql functions can direct 'returning' results directly to the > return of the function (at least in 8.4). That bit is new in 8.4, which is why I didn't

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Merlin Moncure
On Fri, Jun 5, 2009 at 6:51 PM, Tom Lane wrote: > Joshua Tolley writes: >> On Mon, Jun 01, 2009 at 04:21:27PM +0100, Shak wrote: >>> Something like: >>> SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ; >>> sounds reasonable but results in a syntax error. I am able to return single >>> results in

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Tom Lane
Joshua Tolley writes: > On Mon, Jun 01, 2009 at 04:21:27PM +0100, Shak wrote: >> Something like: >> SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ; >> sounds reasonable but results in a syntax error. I am able to return single >> results into a variable or record, but not more than one result.

Re: [GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Joshua Tolley
On Mon, Jun 01, 2009 at 04:21:27PM +0100, Shak wrote: > When RETURNING from a DELETE statement (or similar), how do you access the > results being returned? > > Something like: > > SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ; > > sounds reasonable but results in a syntax error. I am able to r

Re: [GENERAL] why dropping a trigger may cause a deadlock

2009-06-05 Thread Tom Lane
Ivan Sergio Borgonovo writes: > I don't get it. > Why dropping the triggers would cause a deadlock anyway? > I bet it is due to my naïve view of the problem but I think a > trigger is a "function". Unless there is concurrent access to the > table where the function is defined... I can't see why

Re: [GENERAL] How to automatically propagate new/changed database functions from one database to another

2009-06-05 Thread Atul Chojar
Could you give some examples of such utilities? Thanks! atul -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Joshua D. Drake Sent: Friday, June 05, 2009 1:37 PM To: Atul Chojar Cc: pgsql-general@postgresql.org Subjec

Re: [GENERAL] NOT NULL with CREATE TYPE

2009-06-05 Thread Jeff Davis
On Fri, 2009-06-05 at 10:58 -0700, Jean Hoderd wrote: > The above example was absurdly simple, but in the real world the query > is complex enough that instead of being just a SELECT is actually the > return of a PL/PGSQL function. I just want a way to tell the client > which fields from the retur

Re: [GENERAL] why dropping a trigger may cause a deadlock

2009-06-05 Thread Ivan Sergio Borgonovo
On Fri, 05 Jun 2009 10:46:11 -0400 Tom Lane wrote: > Ivan Sergio Borgonovo writes: > > I've encountered this error for the first time > > psql:./import_stock_scratch.sql:9: ERROR: deadlock detected > > DETAIL: Process 11095 waits for AccessExclusiveLock on relation > > 250545 of database 24856

Re: [GENERAL] NOT NULL with CREATE TYPE

2009-06-05 Thread Jean Hoderd
Hi, > So I don't recommend you try to do this. What is the actual problem > you are trying to solve? Why do you want the client library to be > concerned with attnotnull at all? In general the client library needs to check attnotnull to make sure that the client is not making a type mistake.

Re: [GENERAL] Schema, database, or tables in different folders?

2009-06-05 Thread Eric Schwarzenbach
Alan Hodgson wrote: > On Tuesday 02 June 2009, "Carlos Oliva" wrote: > >> Is there a way to create a database or a table of a database in its own >> folder? We are looking for ways to backup the sytem files of the >> database to tape and one to exclude some tables from this backup. We >> can

Re: [GENERAL] max execution time of query

2009-06-05 Thread S Arvind
Thanks Chris & kretschmer. But one small doubt in it,, What happens to update or insert query? - Arvind S * "Many of lifes failure are people who did not realize how close they were to success when they gave up." -Thomas Edison * On Fri, Jun 5, 2009 at 11:59 AM, Chris wrote: > S Arvind wrote: >

Re: [GENERAL] maintaining referential integrity

2009-06-05 Thread David
On Fri, Jun 5, 2009 at 6:27 PM, Brandon Metcalf wrote: > What would be the best way to maintain referential integrity in the > following situation?   Let's say I have the following table > >  CREATE TABLE workorder ( >      workorder_id INTEGER  NOT NULL, >      part_id      INTEGER  DEFAULT NULL,

Re: [GENERAL] maintaining referential integrity

2009-06-05 Thread Andy Colson
Brandon Metcalf wrote: What would be the best way to maintain referential integrity in the following situation? Let's say I have the following table CREATE TABLE workorder ( workorder_id INTEGER NOT NULL, part_id INTEGER DEFAULT NULL, generic BOOLEAN DEFAULT FA

Re: [GENERAL] How to automatically propagate new/changed database functions from one database to another

2009-06-05 Thread Joshua D. Drake
On Fri, 2009-06-05 at 13:12 -0400, Atul Chojar wrote: > We want to implement a mechanism by which if any database function is > created or modified in one database, then the same should > automatically get done in another (1 or more) database(s). > > > > It seems triggers on system catalogs lik

Re: [GENERAL] catalog view use to find DATABASE, LANGUAGE,TABLESPACE, SCHEMA, SEQUENCE privileges granted to user or role

2009-06-05 Thread Louis Lam
Hi Matijn, Thank you very much for the suggestion. I was able to figure this out yesterday by running this query to get the source code from the view then strip out the permission check and it work great. select * from pg_views where viewname = 'table_privileges' Thank you and Tom Lane for the

Re: [GENERAL] NOT NULL with CREATE TYPE

2009-06-05 Thread Tom Lane
Jean Hoderd writes: > I have tried the following, but it's not accepted: > create type result as (name text not null, age int4 not null); Frankly, the notion that a "not null" condition might be associated with a SQL data type is simply a bad idea. The SQL committee let this happen for domains i

Re: [GENERAL] catalog view use to find DATABASE, LANGUAGE, TABLESPACE, SCHEMA, SEQUENCE privileges granted to user or role

2009-06-05 Thread Martijn van Oosterhout
On Wed, Jun 03, 2009 at 01:46:00PM -0500, Louis Lam wrote: > So if I need to find out what table, view and function are granted to > user or role. I should be force to use pg_class and pg_proc? Unless I > can have superuser access? Use \dv+ on the information_schema view you want and copy the qu

[GENERAL] How to automatically propagate new/changed database functions from one database to another

2009-06-05 Thread Atul Chojar
We want to implement a mechanism by which if any database function is created or modified in one database, then the same should automatically get done in another (1 or more) database(s). It seems triggers on system catalogs like pg_proc are not allowed. Is there any way in postgres to do this,

Re: [GENERAL] postgresql source code is worth to read

2009-06-05 Thread John R Pierce
youngvon...@gmail.com wrote: > On 6月4日, 下午1时52分, "youngvon...@gmail.com" > wrote: > >> i want to understand database knowledge about ipc,store,etc with a >> project,ie,postgresql. I want to ask postgresql source code is very >> good, is worth to learn . >> > I want to ask if postgresql s

[GENERAL] NOT NULL with CREATE TYPE

2009-06-05 Thread Jean Hoderd
Dear list, Here's the situation: I want to create a functional API to a Postgresql database, in such a way that instead of issuing raw SQL commands (SELECT, INSERT, etc), the client will only invoke functions from this API. For example, to get all people in the database, the client will invoke f

[GENERAL] maintaining referential integrity

2009-06-05 Thread Brandon Metcalf
What would be the best way to maintain referential integrity in the following situation? Let's say I have the following table CREATE TABLE workorder ( workorder_id INTEGER NOT NULL, part_id INTEGER DEFAULT NULL, generic BOOLEAN DEFAULT FALSE, PRIMARY KEY (

Re: [GENERAL] limit table to one row

2009-06-05 Thread Brandon Metcalf
p == pgmaili...@codecraft.se writes: p> On 4 jun 2009, at 22.17, Richard Broersma wrote: p> > On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf p> > wrote: p> >> Is there a way when creating a table to limit it to one row? That p> >> is, p> >> without using a stored procedure? p> > p> >

Re: [GENERAL] How to know the indexes on a Table

2009-06-05 Thread Tom Lane
"Anirban Pal" writes: > Is there any way, to know the name of indexes on a table, defined in a > database. I mean can I query something like > Select Index_name from pg_class where relname = "Table_name" . Thanks in > advance. You need to join through pg_index, specifically its columns indrel

Re: [GENERAL] invalid byte sequence for encoding "UTF8": 0xab

2009-06-05 Thread Vick Khera
On Fri, Jun 5, 2009 at 9:57 AM, Tom Lane wrote: > The ASCII code for '<' is 0x3c, not 0xab.  I am not sure what you are > actually typing; although it's suggestive that the LATIN1 code 0xab > corresponds to a symbol that looks approximately like '<<'.  The most > likely bet is that you are typing t

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-05 Thread Alan Hodgson
On Tuesday 02 June 2009, "Carlos Oliva" wrote: > Thank you for your response. The tablespace should work for us. Perhaps > you can help me with the following questions: > > 1) If we were to create a different table space for a database that has > archival tables -- they will be backed up once, i

Re: [GENERAL] Schema, database, or tables in different folders?

2009-06-05 Thread Alan Hodgson
On Tuesday 02 June 2009, "Carlos Oliva" wrote: > Is there a way to create a database or a table of a database in its own > folder? We are looking for ways to backup the sytem files of the > database to tape and one to exclude some tables from this backup. We > can selectively backup folders of t

Re: [GENERAL] information request

2009-06-05 Thread Alan McKay
The easiest way to get started is to use your package management system to install PG for you. If you are on a Fedora/Centos or similar based system then this is easily accomplished with the 'yum' command. The minimal packages to add would likely be : postgresql-server postgresql The latter giv

Re: [GENERAL] Schema, database, or tables in different folders?

2009-06-05 Thread Grzegorz Jaśkiewicz
oops, I just realised you asked that question before :P -- 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] Schema, database, or tables in different folders?

2009-06-05 Thread Grzegorz Jaśkiewicz
yes, it is called table space. Check this groups archive, it was discussed quite recently. -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] Using results from RETURNING

2009-06-05 Thread Shak
Hi all, When RETURNING from a DELETE statement (or similar), how do you access the results being returned? Something like: SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ; sounds reasonable but results in a syntax error. I am able to return single results into a variable or record, but no

[GENERAL] Creating schema, database, or table in different folder.

2009-06-05 Thread Carlos Oliva
Is there a way to create a database or a table of a database in its own folder? We are looking for ways to backup the sytem files of the database to tape and one to exclude some tables from this backup. We can selectively backup folders of the file system so we figure that if we can create a sche

[GENERAL] Using results from DELETE ... RETURNING

2009-06-05 Thread Shak
Hi all, When RETURNING from a DELETE statement (or similar), how do you access the results being returned? Something like: SELECT COUNT(*) FROM (DELETE FROM a RETURNING *) ; sounds reasonable but results in a syntax error. I am able to return single results into a variable or record, but not m

[GENERAL] Schema, database, or tables in different folders?

2009-06-05 Thread Carlos Oliva
Is there a way to create a database or a table of a database in its own folder? We are looking for ways to backup the sytem files of the database to tape and one to exclude some tables from this backup. We can selectively backup folders of the file system so we figure that if we can create a sche

[GENERAL] Schema, databse, or tables in different system folder

2009-06-05 Thread Carlos Oliva
Thank you for your response. The tablespace should work for us. Perhaps you can help me with the following questions: 1) If we were to create a different table space for a database that has archival tables -- they will be backed up once, is it sufficient to backup the tablespace folder once?

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-05 Thread Carlos Oliva
Thank you for your response. The tablespace should work for us. Perhaps you can help me with the following questions: 1) If we were to create a different table space for a database that has archival tables -- they will be backed up once, is it sufficient to backup the tablespace folder once?

[GENERAL] information request

2009-06-05 Thread ahmed saeed
hello, i am new to postgresql.actually i use openoffice for my database needs but i see over internet people talking postgresql is the best solution for database needs.i would love to make tables,queries,reports etc.can you guide me what product i should download and use? thanks and GOD ble

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-05 Thread Carlos Oliva
Would the backup be unrecoverable if I shutdown the databse first? "Chris Browne" wrote in message news:87ab4qfs48@dba2.int.libertyrms.com... "Carlos Oliva" writes: Is there a way to create a database or a table of a database in its own folder? We are looking for ways to backup the sytem

[GENERAL] recursive execute

2009-06-05 Thread Rastislav Hudak
Hi, I'd like to get an array containing distinct values (always integers) form a column in a table that is provided as a parameter. So I created this function: CREATE OR REPLACE FUNCTION get_distinct_values(table_name text, param_name text) RETURNS integer[] AS $BODY$ DECLARE _values integer[];

[GENERAL] postgresql source code is worth to read

2009-06-05 Thread youngvon...@gmail.com
hello,all i want to understand database knowledge about ipc,store,etc with a project,ie,postgresql. I want to ask postgresql source code is very good, is worth to learn . thanks. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://

Re: [GENERAL] why dropping a trigger may cause a deadlock

2009-06-05 Thread Tom Lane
Ivan Sergio Borgonovo writes: > I've encountered this error for the first time > psql:./import_stock_scratch.sql:9: ERROR: deadlock detected > DETAIL: Process 11095 waits for AccessExclusiveLock on relation > 250545 of database 248569; blocked by process 11099. Process 11099 > waits for AccessSh

Re: [GENERAL] postgresql source code is worth to read

2009-06-05 Thread youngvon...@gmail.com
On 6月4日, 下午1时52分, "youngvon...@gmail.com" wrote: > hello,all > i want to understand database knowledge about ipc,store,etc with a > project,ie,postgresql. I want to ask postgresql source code is very > good, is worth to learn . > > thanks. I want to ask if postgresql source code is very well,an

[GENERAL] Function: Change data while walking through records

2009-06-05 Thread stevesub
Hi, I keep having this need to create a function that will change the row data as I am walking through the data. For example, I process each row in order, if column1 change from previous row, set column2 to true. Is this possible? I can run another query to modify the data, but that doesn't see

[GENERAL] trigger functions with arguments

2009-06-05 Thread Kev
I came across this curious behaviour today, at least in the 2009-03-24 beta (I can't run a newer beta), that I couldn't find in the docs, although maybe I missed it. I found this really confusing until I figured it out, so I thought I should share, and if it's not in the docs, it should probably b

[GENERAL] Authenticate via SSPI/GSSAPI on Windows Server

2009-06-05 Thread Thomas Walther
Hey there, I developed a program where you must authenticate on startup. Now my users already authenticate themselves when they login on Windows, so basically they authenticate twice. To avoid this, the docs told me to use GSSAPI or SSPI as psql authentication method, so my program could use the Wi

[GENERAL] Create Foreign Key Constraint on a View

2009-06-05 Thread Christopher Brodt
I'm attempting to create a Foreign Key Constraint between a table and a view in PostgreSQL 8.3. Ex: ALTER TABLE public.table ADD CONSTRAINT table_to_view_fk FOREIGN KEY (view_key) REFERENCES public.view (view_key) ON DELETE NO ACTION ON UPDATE NO ACTION NOT DEFERRABLE; However, I get an error

[GENERAL] How to know the indexes on a Table

2009-06-05 Thread Anirban Pal
Hi all, Is there any way, to know the name of indexes on a table, defined in a database. I mean can I query something like Select Index_name from pg_class where relname = "Table_name" . Thanks in advance. --- Thanks & Reagrds Anirban Pal | Software Engineer Newgen Software Technolo

Re: [GENERAL] Move PGdata to a different drive

2009-06-05 Thread David Fetter
On Thu, Jun 04, 2009 at 11:11:29AM -0400, Bruce Momjian wrote: > Jennifer Trey wrote: > > Hi, > > What file should I be working with? > > Just shut down the server and move the directory whever you want and > restart the server. There are no file contents that need changing. > Of course should ad

Re: [GENERAL] invalid byte sequence for encoding "UTF8": 0xab

2009-06-05 Thread Tom Lane
"Grand, Mark D." writes: > ... I get this message: > ERROR: invalid byte sequence for encoding "UTF8": 0xab > HINT: This error can also happen if the byte sequence does not match the > encoding expected by the server, which is controlled by "client_encoding". > It is complaining about the '<'

Re: [GENERAL] sequences and RULEs

2009-06-05 Thread Rafal Pietrak
On Fri, 2009-06-05 at 14:32 +0100, Richard Huxton wrote: > Rafal Pietrak wrote: > > The NEW tuple of the table EVENTLOG, in its ID field at the moment of > > RULE execution has a value of 5! But after everything is finished, the > > actual value deposited in that record is 4. > > A rule rewrites t

Re: [GENERAL] sequences and RULEs

2009-06-05 Thread Richard Huxton
Rafal Pietrak wrote: Now I'd like to write a RULE, that automatically updates references between EVENTLOG and STATUS: The NEW tuple of the table EVENTLOG, in its ID field at the moment of RULE execution has a value of 5! But after everything is finished, the actual value deposited in that reco

Re: [GENERAL] Using a multi-valued function in a view

2009-06-05 Thread Radcon Entec
By George, I think you've got it! (Imagine a hokey imitation British accent.) I only had to make one small change.  It complained it didn't know about a column named "charge".  When I changed it to:     select charge, (cn).* from (select charge, chargeneeds(charge) as cn from charge) q; it worke

[GENERAL] invalid byte sequence for encoding "UTF8": 0xab

2009-06-05 Thread Grand, Mark D.
I am having a vexing problem with a script I am writing to populate reference tables in a new database. I am running postgreSQL 8.3 with psql 8.3.7. Psql reads this SQL statement: INSERT INTO META_AUTH.DOMAIN_META_ASSERTION (TITLE, DESCRIPTION, META_ASSERTION) VALUES ('Super-User Aut

[GENERAL] sequences and RULEs

2009-06-05 Thread Rafal Pietrak
Hi All! I've seen sometning unexpected here. I'd apreciate it if someone could give me a hint of why this have happened and may be a sugesstion of a workaround. I'm writing "Building Access Control System" (BACS). My environment is "Debian testing" with "their current" postgresql version: 8.3.7.

[GENERAL] why dropping a trigger may cause a deadlock

2009-06-05 Thread Ivan Sergio Borgonovo
I've encountered this error for the first time psql:./import_stock_scratch.sql:9: ERROR: deadlock detected DETAIL: Process 11095 waits for AccessExclusiveLock on relation 250545 of database 248569; blocked by process 11099. Process 11099 waits for AccessShareLock on relation 250510 of database 2

Re: [GENERAL] recursive execute

2009-06-05 Thread Albe Laurenz
Rastislav Hudak wrote: > I'd like to get an array containing distinct values (always > integers) form a column in a table that is provided as a > parameter. So I created this function: > > CREATE OR REPLACE FUNCTION get_distinct_values(table_name text, param_name > text) > RETURNS integer[] A