Re: [GENERAL] Best approach for a "gap-less" sequence

2006-08-16 Thread Adrian Klaver
On Wednesday 16 August 2006 10:59 am, elein wrote: > On Mon, Aug 14, 2006 at 02:46:17PM -0700, Adrian Klaver wrote: > > On Monday 14 August 2006 01:59 pm, Brad Nicholson wrote: > > > On Mon, 2006-08-14 at 16:08 -0400, Berend Tober wrote: > > > > Jorge Godoy wrote: > > > > > Chris <[EMAIL PROTECTED]

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Harpreet Dhaliwal
Also, I think you should check the special characters in the text that you are trying to store.   I realize from one of your emails that when u run the same query using the PGAdmin query tool, only a part of the the varchar gets stores and rest it trimmed.   This has something to do with the specia

Re: [GENERAL] Move db files from one pgsql instance to another

2006-08-16 Thread Jeff Davis
On Wed, 2006-08-16 at 20:37 +0200, Javier de la Torre wrote: > Yes! > > Thanks. It pointed me out to File system level backup. And there I > found a very important hint... you have to restore the whole database > cluster. I suppose this means that I have to transfer all databases in > my postgresq

Re: [GENERAL] COLLATE

2006-08-16 Thread Tom Lane
Kevin Murphy <[EMAIL PROTECTED]> writes: > What is the answer to Filip's question? I didn't see an answer in the list > archives. I've seen several copies of Joe Conway's pg_strxfrm.c code on the > web, and it always refers to the Warn_restart variable, which doesn't seem to > exist in the 8.1

Re: [GENERAL] Best approach for a "gap-less" sequence

2006-08-16 Thread Dawid Kuroczko
On 8/16/06, Dawid Kuroczko <[EMAIL PROTECTED]> wrote: -- then create a function to retrieve the values: CREATE FUNCTION gseq_nextval(t text) RETURNS integer AS $$ DECLARE n integer; BEGIN SELECT INTO n gseq_value+1 FROM gapless_seq WHERE gseq_name = t FOR UPDATE; UPDA

Re: [GENERAL] Best approach for a "gap-less" sequence

2006-08-16 Thread Dawid Kuroczko
On 8/12/06, Jorge Godoy <[EMAIL PROTECTED]> wrote: I was trying to solve a problem on an old system and realized that there might be some better approach for doing what I need. We have some documents that need to be ordered sequentially and without gaps. I could use a sequence, but if the transa

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 04:11:23PM -0400, Jasbinder Bali wrote: > I'm sending u the main() function that has the ECPG Insert statement and > commit in it. The program you posted isn't a simplified example as I requested. The idea is that anybody should be able to compile the code and run it; that'

Re: [GENERAL] COLLATE

2006-08-16 Thread Kevin Murphy
Filip Rembiałkowski wrote: Greg Stark wrote: But the closest partial solution suggested so far is the pg_xfrm (sic) function that has been implemented and posted at least three times by three different posters to the postgres mailing lists. In the interest of avoiding a fourth i

Re: [GENERAL] Segmentation Fault

2006-08-16 Thread Tom Lane
=?ISO-8859-1?Q?Poul_M=F8ller_Hansen?= <[EMAIL PROTECTED]> writes: >> Given that you're using duration logging and JDBC, I wonder whether you >> didn't trip over this recently-identified bug: >> http://archives.postgresql.org/pgsql-hackers/2006-08/msg00815.php >> Patch is here: >> http://archives.po

Re: [GENERAL] plpgsql dynamic queries and optional arguments

2006-08-16 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 02:36:44PM -0500, Curtis Scheer wrote: > Thanks for the reply I guess what I am actually looking for is an example of > a dynamic SQL select statement similar to how a static sql select can select > into a variable. In 8.1 you can select a single row or columns of a single

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Jasbinder Bali
This is the create table statement..CREATE TABLE raw_email(  id int4 NOT NULL,  raw_email varchar,  parsed_flag bool NOT NULL DEFAULT false,  CONSTRAINT pk_rawemail PRIMARY KEY (id)) WITHOUT OIDS; ALTER TABLE raw_email OWNER TO postgres;On 8/16/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Wed, Au

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Jasbinder Bali
I'm sending u the main() function that has the ECPG Insert statement and commit in it.---START---#include < stdio.h>#include #include #include EXEC SQL INCLUDE sqlca; #define MP 10#define MSG_LEN 102400

Re: [GENERAL] Triggers invoking a stored procedure or a C function

2006-08-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-08-16 11:55:39 -0400: > Hi, > Conventionally a trigger would fire a few sql queries on a particular event > and we have standard code for that. > > My requirement is to start a stored procedure or a C function as a trigger > action. > > Is this possible? Besides th

Re: [GENERAL] Best approach for a "gap-less" sequence

2006-08-16 Thread Berend Tober
elein wrote: On Mon, Aug 14, 2006 at 02:46:17PM -0700, Adrian Klaver wrote: On Monday 14 August 2006 01:59 pm, Brad Nicholson wrote: On Mon, 2006-08-14 at 16:08 -0400, Berend Tober wrote: Wouldn't SELECT ... FOR UPDATE give you the row lock you need without locking the table? If this is t

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 02:42:46PM -0400, Jasbinder Bali wrote: > Tried everthing but nothing seems to work. > :( Could you provide a simplified but complete example that shows what you're doing? That is, all SQL statements and C code necessary to create a table and whatever functions you're usin

Re: [GENERAL] plpgsql dynamic queries and optional arguments

2006-08-16 Thread Curtis Scheer
Allan, Thanks for the reply I guess what I am actually looking for is an example of a dynamic SQL select statement similar to how a static sql select can select into a variable. Thanks, Curtis Curtis, Here is an example function that uses dynamic sql. I use it under 7.4.5 Hope this helps. A

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Jasbinder Bali
Tried everthing but nothing seems to work.:(On 8/16/06, Jasbinder Bali <[EMAIL PROTECTED]> wrote: Also, i tried to mannualy run the insert query in the query tool insert into raw_email ( id  , raw_email  ) values ( 1 ,  'From [EMAIL PROTE

Re: [GENERAL] Timezones -- what comes out does not go in?

2006-08-16 Thread Julian Scarfe
From: "Tom Lane" <[EMAIL PROTECTED]> This works in CVS HEAD, thanks to some hard work by Joachim Wieland. One of these days I'll find an issue *before* you folks have patched it. :-) Thanks Julian ---(end of broadcast)--- TIP 9: In version

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Guy Rouillier
Harpreet Dhaliwal wrote: > Forgot to write that that was my question. > I mean can we call a stored procedure as an action of a trigger? Sure, here's a working example from a running application: CREATE OR REPLACE FUNCTION assign_detail_device_type_seq() RETURNS trigger AS $$ BEGIN IF

Re: [GENERAL] limitations of constraints, possible bugs

2006-08-16 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Added to TODO: > * Add support for arrays of domains I think BTW that this should be pretty low-hanging fruit given the recent rewrite of domain_in(). I don't think array_in() should need to care now whether the array elements are domains, whereas

Re: [GENERAL] Move db files from one pgsql instance to another

2006-08-16 Thread Javier de la Torre
Yes! Thanks. It pointed me out to File system level backup. And there I found a very important hint... you have to restore the whole database cluster. I suppose this means that I have to transfer all databases in my postgresql... What is actually a pity because there is a db on the production si

Re: [GENERAL] hint unique result fro union

2006-08-16 Thread Jaime Casanova
Mainly, thinking about partitions, I'd like to create a small, frequently accessed partition and a big, rarely accessed partition. I'd like to hint pg to stop the query on the parent partition at the first found item (and so hint not to analyze all the childs), because I know the index I'm using

Re: [GENERAL] Move db files from one pgsql instance to another

2006-08-16 Thread Jeff Davis
On Wed, 2006-08-16 at 20:04 +0200, Javier de la Torre wrote: > I am working right now in an strategy to improve the performance on my > server. The situation is this: > > I have a very large database that it is only update once a month, but > when is updated I have to process a lot of things on th

Re: [GENERAL] Best approach for a "gap-less" sequence

2006-08-16 Thread elein
On Mon, Aug 14, 2006 at 02:46:17PM -0700, Adrian Klaver wrote: > On Monday 14 August 2006 01:59 pm, Brad Nicholson wrote: > > On Mon, 2006-08-14 at 16:08 -0400, Berend Tober wrote: > > > Jorge Godoy wrote: > > > > Chris <[EMAIL PROTECTED]> writes: > > > >>I'm not sure what type of lock you'd need t

[GENERAL] Move db files from one pgsql instance to another

2006-08-16 Thread Javier de la Torre
Hi, I am working right now in an strategy to improve the performance on my server. The situation is this: I have a very large database that it is only update once a month, but when is updated I have to process a lot of things on the data to create caches, aditional tables, etc. The processing o

Re: [GENERAL] Partial indexes Vs standard indexes : Insert

2006-08-16 Thread Jeff Davis
On Wed, 2006-08-16 at 12:15 +0200, MaXX wrote: > > That should work. Keep in mind that the main idea of an index is to > > reduce the number of pages that have to be fetched from disk. If the > > record size is small, you may have at least one ICMP packet on 50% (or > > more) of the disk pages even

Re: [GENERAL] hint unique result fro union

2006-08-16 Thread Steve Atkins
On Aug 16, 2006, at 8:23 AM, Matteo Bertini wrote: Hello all! I'm quite new to pg, but I'm using it quite a lot in the last few monts. Deeping in new features, I found a question: is it possible to hint an unique result from a select? Mainly, thinking about partitions, I'd like to crea

[GENERAL] Triggers invoking a stored procedure or a C function

2006-08-16 Thread Harpreet Dhaliwal
Hi, Conventionally a trigger would fire a few sql queries on a particular event and we have standard code for that.   My requirement is to start a stored procedure or a C function as a trigger action.   Is this possible?   Thanks, ~Harpreet

Re: [GENERAL] Weird join result

2006-08-16 Thread Stephan Szabo
On Wed, 16 Aug 2006, Peter Nixonn wrote: > I am getting a result for an JOIN that I think is wrong. Maybe its my > understanding that is wrong here however, so please be gentle :-) > > The "phones" table contains a list of phone numbers and an associated > customer ID. The radacct table contains a

Re: [GENERAL] Determine Transactions Per Second

2006-08-16 Thread Jeff Davis
On Wed, 2006-08-16 at 10:24 -0400, John R. Allgood wrote: > I am needing to determine the tps for a production application > running on PostgreSQL 7.4.7. I know you can use pg_bench and create a > new database to determine an estimate of tps. Is there a way I can get > this info out of my produ

Re: [GENERAL] limitations of constraints, possible bugs

2006-08-16 Thread Bruce Momjian
Tom Lane wrote: > craigp <[EMAIL PROTECTED]> writes: > > for instance, if i create a domain (D) with some constraint, and create a > > table > > with a column of type D[], will that domain constraint be enforced for each > > element of the array? > > Currently we don't support arrays of domain ty

[GENERAL] hint unique result fro union

2006-08-16 Thread Matteo Bertini
Hello all!I'm quite new to pg, but I'm using it quite a lot in the last few monts.Deeping in new features, I found a question: is it possible to hint an unique result from a select?Mainly, thinking about partitions, I'd like to create a small, frequently accessed partition and a big, rarely accesse

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 02:59:23AM -0400, Harpreet Dhaliwal wrote: > I mean can we call a stored procedure as an action of a trigger? You'll need to write a trigger function that calls the non-trigger function (what you're referring to as "stored procedure"). Example: CREATE FUNCTION trigger_fun

Re: [GENERAL] Segmentation Fault

2006-08-16 Thread Poul Møller Hansen
Given that you're using duration logging and JDBC, I wonder whether you didn't trip over this recently-identified bug: http://archives.postgresql.org/pgsql-hackers/2006-08/msg00815.php Patch is here: http://archives.postgresql.org/pgsql-committers/2006-08/msg00278.php Sorry but didn't, but

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Jasbinder Bali
I did commit the transaction by writing EXEC SQL COMMIT; right after the insert statement.Then also its not inserting the record and says:[2998]: ECPGexecute line 97 Ok: INSERT 0 1and SQLCODE is still 0 ~JasOn 8/16/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Wed, Aug 16, 2006 at 01:46:30AM -0400

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Jasbinder Bali
Also, i tried to mannualy run the insert query in the query toolinsert into raw_email ( id  , raw_email  ) values ( 1 ,  'From [EMAIL PROTECTED] Tue Apr 15 20:24:47 2003X-MultiHeader: oneX-MultiHeader: twoX-MultiHeader: threeFrom: Simon C

[GENERAL] Determine Transactions Per Second

2006-08-16 Thread John R. Allgood
Hello I am needing to determine the tps for a production application running on PostgreSQL 7.4.7. I know you can use pg_bench and create a new database to determine an estimate of tps. Is there a way I can get this info out of my production database. Thanks -- "What I've done, of course, is

Re: [GENERAL] Weird join result

2006-08-16 Thread Harald Armin Massa
Peter,This returns 1280 rows, none of which are have a NULL value for sum. This surprised me at first as I thought the WHERE clause should apply before theOUTER JOIN but apparently not. I then tried the following:what gives you the impression that WHERE clauses should be applied before the JOINs ?

Re: [GENERAL] Segmentation Fault

2006-08-16 Thread Tom Lane
=?ISO-8859-1?Q?Poul_M=F8ller_Hansen?= <[EMAIL PROTECTED]> writes: > Last night one of my databases broke down temporary because of a > segmentation fault. > At 00:36:21 this was happening in the pgsql log > 2006-08-16 00:36:21 CEST - LOG: duration: 14673.110 ms statement: > EXECUTE amed> [PR

Re: [GENERAL] Massive slowdown when LIMIT applied

2006-08-16 Thread Tom Lane
Graeme Hinchliffe <[EMAIL PROTECTED]> writes: > If I do the following: > SELECT username,acctstarttime FROM radacct WHERE username='user' > ORDER BY acctstarttime; > again the results come up slightly slower as would be expected but > still very quickly.. (a few hundred rows in this case) >

Re: [GENERAL] Timezones -- what comes out does not go in?

2006-08-16 Thread Alvaro Herrera
Julian Scarfe wrote: > The timezone on our boxes is set to Etc/UCT (possibly a distro default). > > (psql 8.1.4) > > => select to_char(current_timestamp, 'HH24:MI:SS TZ'); > to_char > -- > 09:05:48 UCT > (1 row) > > => select '09:05:48 UCT'::time; > ERROR: invalid input syntax fo

Re: [GENERAL] Timezones -- what comes out does not go in?

2006-08-16 Thread Tom Lane
"Julian Scarfe" <[EMAIL PROTECTED]> writes: > The timezone on our boxes is set to Etc/UCT (possibly a distro default). > (psql 8.1.4) > => select to_char(current_timestamp, 'HH24:MI:SS TZ'); >to_char > -- > 09:05:48 UCT > (1 row) > => select '09:05:48 UCT'::time; > ERROR: inval

[GENERAL] Weird join result

2006-08-16 Thread Peter Nixonn
Hi Guys I am getting a result for an JOIN that I think is wrong. Maybe its my understanding that is wrong here however, so please be gentle :-) The "phones" table contains a list of phone numbers and an associated customer ID. The radacct table contains a list of all calls made (RADIUS Accounting

Re: [GENERAL] limitations of constraints, possible bugs

2006-08-16 Thread Tom Lane
craigp <[EMAIL PROTECTED]> writes: > for instance, if i create a domain (D) with some constraint, and create a > table > with a column of type D[], will that domain constraint be enforced for each > element of the array? Currently we don't support arrays of domain types (this should get fixed som

Re: [GENERAL] Is it possible (postgresql/mysql)

2006-08-16 Thread Harald Armin Massa
Louis,there may be an a unimportant performance penality for varchar, because of filling up and whatever. But the real reason: as much as I researched, NOBODY stated that varchar2 would be faster or better; but it limits the length. And I spend to much time in working around fixed field lengths in

Re: [GENERAL] Restarting Slony crashes Postgresql?

2006-08-16 Thread Christopher Browne
In an attempt to throw the authorities off his trail, "Nico" <[EMAIL PROTECTED]> transmitted: > Hi group, > > I'm using Slony-I 1.1.5 with Postgresql 8.1.4 on 3 DB server (OS = > debian sarge). > I set a replication from a database on server A (master) to 2 servers B > and C (slaves). > > Note tha

Re: [GENERAL] Segmentation Fault

2006-08-16 Thread Poul Møller Hansen
dmesg [2425253.737383] postmaster[4792]: segfault at 2aaab6f0e000 rip 2b73795b rsp 7f8c9228 error 4 Any suggestions ? Do you trust that machine's RAM? Can you try running memtest86 for some extended period of time? (just to make sure it's not a hardware issue)

Re: [GENERAL] Is it possible (postgresql/mysql)

2006-08-16 Thread louis gonzales
Harald, I had thought of that, but I wasn't sure if there was/is a way to create the index's upon table creation, as it appears is possible with MySQL. As for the replacing of varchar(xx) with a text data type, why do you recommend this? I want to stay as close as I can to the original code.

Re: [GENERAL] Is it possible (postgresql/mysql)

2006-08-16 Thread Harald Armin Massa
Louis,indizes are simply created outside the create tableCREATE INDEX someTable_Date_create  ON someTable  USING btree  (date_create);As you are working on transferring, maybe you like to drop those varchar(xx) and replace them with text. Saves a lot of hassle lateron. HaraldOn 8/16/06, louis gonza

[GENERAL] Is it possible (postgresql/mysql)

2006-08-16 Thread louis gonzales
Hello List, PostgreSQL 8.0.1 (on Solaris 9) There is a PERL program that a friend purchased which is used to create tables on a MySQL database, and of course ;) I want to run this on a PostgreSQL database server instead. The below is the code: $sth=runSQL("CREATE TABLE someTable (

Re: [GENERAL] Segmentation Fault

2006-08-16 Thread Chris Mair
> dmesg > [2425253.737383] postmaster[4792]: segfault at 2aaab6f0e000 rip > 2b73795b rsp 7f8c9228 error 4 > > > Any suggestions ? Do you trust that machine's RAM? Can you try running memtest86 for some extended period of time? (just to make sure it's not a hardware issue)

Re: [GENERAL] Segmentation Fault

2006-08-16 Thread Bill Moran
In response to "Poul Møller Hansen" <[EMAIL PROTECTED]>: > Last night one of my databases broke down temporary because of a > segmentation fault. > It has only happended this time and the database was fully recovered > afterwards, > but I was wondering what I can do anything to prevent it from h

[GENERAL] Segmentation Fault

2006-08-16 Thread Poul Møller Hansen
Last night one of my databases broke down temporary because of a segmentation fault. It has only happended this time and the database was fully recovered afterwards, but I was wondering what I can do anything to prevent it from happening again It happened while the backup was running (pg_dump

RES: [GENERAL] How to add days to date

2006-08-16 Thread Alejandro Michelin Salomon \( Adinet \)
Michael : I change my query to this : SELECT CAST( '2006-08-01' AS DATE ) + FP.carencia + ( FP.prazo * ( MFP.parcela - 1 )) AS vencimento FROM fi_mov_formas_pagamento MFP LEFT OUTER JOIN fi_formas_pagamento FP ON ( MFP.idformapagamento = FP.idformapagamento AND MFP.idempresa = FP.idempr

[GENERAL] Massive slowdown when LIMIT applied

2006-08-16 Thread Graeme Hinchliffe
Hi, I am using postgres 7.4.7 under Debian Sarge for RADACCT, this means a fairly large table of data allowing us to hold approx 12 months of data.  I have used a trigger to break the system in 2 and keep the live table which takes updates small, and all closed connections are inserted into a large

Re: [GENERAL] Partial indexes Vs standard indexes : Insert

2006-08-16 Thread MaXX
Jeff Davis wrote: On Tue, 2006-08-15 at 13:13 +0200, MaXX wrote: [snip] I have a table in which I store log from my firewall. For the protocol column (3 distinct values: TCP ~82%, UDP ~17%, ICMP ~1%, the table contains 1.7M rows), I use a partial index to find ICMP packets faster. It's ICMP

Re: [GENERAL] Partial indexes Vs standard indexes : Insert performance

2006-08-16 Thread MaXX
Gregory Stark wrote: MaXX <[EMAIL PROTECTED]> writes: In my understanding, a partial index is only touched when a matching row is inserted/updated/deleted (index constraint is true), so if I create a partial index for each protocol, I will slow down my machine as if I had created a single "norma

Re: [GENERAL] How to add days to date

2006-08-16 Thread Alban Hertroys
Alejandro Michelin Salomon ( Adinet ) wrote: Hi: I have problem trying to add same days to a date. '2006-08-01' + FP.carencia + ( FP.prazo * ( MFP.parcela - 1 )) --> This results in EX : '2006-08-01' + 30 + ( 7 * ( 3 - 1 )) ==> '2006-08-01' + 44 Looks like you could use the interval type her

[GENERAL] Timezones -- what comes out does not go in?

2006-08-16 Thread Julian Scarfe
The timezone on our boxes is set to Etc/UCT (possibly a distro default). (psql 8.1.4) => select to_char(current_timestamp, 'HH24:MI:SS TZ'); to_char -- 09:05:48 UCT (1 row) => select '09:05:48 UCT'::time; ERROR: invalid input syntax for type time: "09:05:48 UCT" UTC works, of c

[GENERAL] limitations of constraints, possible bugs

2006-08-16 Thread craigp
i'm curious about how constraints work (perhaps vs how they are supposed to work). for instance, if i create a domain (D) with some constraint, and create a table with a column of type D[], will that domain constraint be enforced for each element of the array? could i create a column constraint o

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-16 Thread Harpreet Dhaliwal
Forgot to write that that was my question. I mean can we call a stored procedure as an action of a trigger?  On 8/16/06, Harpreet Dhaliwal <[EMAIL PROTECTED]> wrote: Its actually something like the trigger should start a C function after insert and the C function has the ECPG code for some more i