Re: [GENERAL] pg_start_backup question

2009-10-30 Thread Guillaume Lelarge
Le samedi 31 octobre 2009 à 00:39:54, db de a écrit : > Below is what I did: > I opened a super user connection to creat a super user statement. Then use > the super user statement to execute "SELECT pg_start_backup('label')". > > try > { > superuserCont = java.sql.DriverManager.getConnect

Re: [GENERAL] Rewriting select statements

2009-10-30 Thread David Fetter
On Sat, Oct 31, 2009 at 08:57:03AM +1100, Phil Cairns wrote: > Tom Lane wrote: > > "Phil Cairns" writes: > > > I want to have the server do this: If the query has no where > > > clause, use a where clause of "where 1=0". > > > > > Is this possible? > > > > It's doubtless *possible*, but if you'r

Re: [GENERAL] What order of steps of the postgres when you change information in the table?

2009-10-30 Thread Scott Marlowe
2009/10/30 Denis Feklushkin : > > Problem: > It is necessary to synchronize the "users" table with an > external storage of passwords (krb5) > > I made a trigger: > > CREATE TRIGGER "10_krb5" >  AFTER INSERT OR UPDATE OR DELETE >  ON users >  FOR EACH ROW >  EXECUTE PROCEDURE user2krb5_python(); >

[GENERAL] When was a Function Added?

2009-10-30 Thread Paul Nickerson
When was the ECPG function PGTYPEStimestamp_add_interval added to ECPG? My school has a server for student assignments and demonstrations with SunOS 5.9, PostgreSQL 7.4.8, ECPG 3.1.1, and GCC 3.4.6. In the documentation linked below, I can see that that function goes back as far as Postg

[GENERAL] What order of steps of the postgres when you change information in the table?

2009-10-30 Thread Denis Feklushkin
Problem: It is necessary to synchronize the "users" table with an external storage of passwords (krb5) I made a trigger: CREATE TRIGGER "10_krb5" AFTER INSERT OR UPDATE OR DELETE ON users FOR EACH ROW EXECUTE PROCEDURE user2krb5_python(); Everything works, except that when you d

Re: [GENERAL] Rewriting select statements

2009-10-30 Thread Scott Marlowe
Oh, nevermind, read the thread again. On Fri, Oct 30, 2009 at 5:40 PM, Scott Marlowe wrote: > On Fri, Oct 30, 2009 at 3:57 PM, Phil Cairns wrote: >> Tom Lane wrote: >>> Tell the library authors to fix their broken code.  This is blithering >>> stupidity in *any* SQL database, not only Postgres.

Re: [GENERAL] Rewriting select statements

2009-10-30 Thread Scott Marlowe
On Fri, Oct 30, 2009 at 3:57 PM, Phil Cairns wrote: > Tom Lane wrote: >> Tell the library authors to fix their broken code.  This is blithering >> stupidity in *any* SQL database, not only Postgres. > > Tried that, and got no response. I fully agree that it's broken, but my > users just see the de

Re: [GENERAL] pg_start_backup question

2009-10-30 Thread db de
Below is what I did: I opened a super user connection to creat a super user statement. Then use the super user statement to execute "SELECT pg_start_backup('label')". try { superuserCont = java.sql.DriverManager.getConnection(URL, su, suPassword); suStatement = superuserCont.create

Re: [GENERAL] Rewriting select statements

2009-10-30 Thread Scott Marlowe
On Fri, Oct 30, 2009 at 2:07 PM, Phil Cairns wrote: > I want to have the server do this: > > If the query has no where clause, use a where clause of "where 1=0". > > Is this possible? Anyway to add a 'limit 1' to the end of the query somewhere on the app side? Like Tom said, this app sounds reta

Re: [GENERAL] Problem with plpython

2009-10-30 Thread Justin Pasher
Steve Erickson wrote: I'm running PostgreSQL 8.3 with pl/python 8.3. I am getting a different date/time format when executing the below examples. The results are the same whether I use os.popen or os.system. In plpython, I run: import os cmd = 'ls -al /var/log/messages > /var/tmp/log'

Re: [GENERAL] pg_start_backup question

2009-10-30 Thread Guillaume Lelarge
Le vendredi 30 octobre 2009 à 23:41:54, db de a écrit : > How to execute "SELECT pg_start_backup('label');" from java as a SQL > statement? I tries to use: > Statement.execute("SELECT pg_start_backup('label')") > > But it does not work. > You should have an error message in your PostgreSQL logs.

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Tom Lane
Thom Brown writes: > How is pgAdmin determining the serial type in this case? Most likely it's looking for the pg_depend entry that shows the sequence as being "owned by" the column. However, that's an oversimplification of reality. I would imagine that pgAdmin will lie to you in exactly the sa

[GENERAL] pg_start_backup question

2009-10-30 Thread db de
How to execute "SELECT pg_start_backup('label');" from java as a SQL statement? I tries to use: Statement.execute("SELECT pg_start_backup('label')") But it does not work. Thanks. Jack

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Mark Morgan Lloyd
Tom Lane wrote: Thinking of SERIAL as a type is your first mistake ;-). It is not a type. It is a shorthand for making a sequence and sticking a suitable default on a plain integer column. So what LIKE sees is an integer column with a default, and it copies that. That's entirely fair, and t

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Thom Brown
2009/10/30 Tom Lane : > Thom Brown writes: >> Well I realise SERIAL is a convenience rather than a datatype in its >> own right, but I'm surprised that LIKE can't differentiate between a >> column created with integer and one created with serial.  The table >> continues to report a serial datatype

Re: [GENERAL] Rewriting select statements

2009-10-30 Thread Phil Cairns
Tom Lane wrote: > "Phil Cairns" writes: > > I want to have the server do this: > > If the query has no where clause, use a where clause of "where 1=0". > > > Is this possible? > > It's doubtless *possible*, but if you're asking for it to actually > happen in any supported version of Postgres, th

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Tom Lane
Thom Brown writes: > Well I realise SERIAL is a convenience rather than a datatype in its > own right, but I'm surprised that LIKE can't differentiate between a > column created with integer and one created with serial. The table > continues to report a serial datatype after its creation. Really

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Thom Brown
2009/10/30 Tom Lane : > Thom Brown writes: >> I can see why you wouldn't expect it to end up sharing the same >> sequence.  If you were to manually create a sequence and wanted to use >> it on a column, you probably wouldn't bother using the SERIAL >> datatype, but use integer instead.  So really

Re: [GENERAL] Rewriting select statements

2009-10-30 Thread Tom Lane
"Phil Cairns" writes: > I want to have the server do this: > If the query has no where clause, use a where clause of "where 1=0". > Is this possible? It's doubtless *possible*, but if you're asking for it to actually happen in any supported version of Postgres, the answer is no way. It's direct

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Tom Lane
Thom Brown writes: > I can see why you wouldn't expect it to end up sharing the same > sequence. If you were to manually create a sequence and wanted to use > it on a column, you probably wouldn't bother using the SERIAL > datatype, but use integer instead. So really since we know the first > ta

[GENERAL] Rewriting select statements

2009-10-30 Thread Phil Cairns
I want to have the server do this: If the query has no where clause, use a where clause of "where 1=0". Is this possible? Why would I want to do this? Because a third party library (ArcGIS) has a "feature" such that when a relation name is registered with it, it does a "select * from " and then

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Scott Bailey
My personal feeling is that when you provide any ordering operator and negation you can easily provide an absolute value operator. We've already (somewhat arbitrarily) decided that one of '1month -30days' and '-1month 30days) is "greater" than the other, so why not provide an operator that retu

[GENERAL] Problem with plpython

2009-10-30 Thread Steve Erickson
I'm running PostgreSQL 8.3 with pl/python 8.3. I am getting a different date/time format when executing the below examples. The results are the same whether I use os.popen or os.system. In plpython, I run: import os cmd = 'ls -al /var/log/messages > /var/tmp/log' x = os.popen(cmd) for al

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Thom Brown
2009/10/30 Mark Morgan Lloyd : >> On Fri, Oct 30, 2009 at 8:44 AM, Mark Morgan Lloyd >> wrote: >>> >>> What is the "correct" behavior of a serial column when a table is created >>> with LIKE? The manual is silent on this. >>> >>> What appears to be happening with 8.2 is that the column in the new

Re: [GENERAL] Possible to UPDATE array[] columns?

2009-10-30 Thread Sam Mason
On Fri, Oct 30, 2009 at 06:23:28PM +, Sam Mason wrote: > On Fri, Oct 30, 2009 at 10:47:26AM -0700, Blake Starkenburg wrote: > > ID | scores > > 2 | {54,14,21,8} > > 3 | {12,0,7} > > > > Now I want to append the score of 12 on row:ID 2 so the new scores would > > read {54,14,21,8,12}. > >

Re: [GENERAL] Possible to UPDATE array[] columns?

2009-10-30 Thread Sam Mason
On Fri, Oct 30, 2009 at 10:47:26AM -0700, Blake Starkenburg wrote: > ID | scores > 2 | {54,14,21,8} > 3 | {12,0,7} > > Now I want to append the score of 12 on row:ID 2 so the new scores would > read {54,14,21,8,12}. You need to use the normal array concatenation operator, ||, for example:

Re: [GENERAL] Possible to UPDATE array[] columns?

2009-10-30 Thread Pavel Stehule
2009/10/30 Blake Starkenburg : > Using SQL is it possible to UPDATE (append) onto an array[] column. For > example say I have a column named "scores int[]". > > ID  | scores > 2   | {54,14,21,8} > 3   | {12,0,7} > > Now I want to append the score of 12 on row:ID 2 so the new scores would > read {54

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Mark Morgan Lloyd
On Fri, Oct 30, 2009 at 8:44 AM, Mark Morgan Lloyd wrote: What is the "correct" behavior of a serial column when a table is created with LIKE? The manual is silent on this. What appears to be happening with 8.2 is that the column in the new table refers to the original sequence generator. -- M

Re: [GENERAL] Possible to UPDATE array[] columns?

2009-10-30 Thread Thom Brown
2009/10/30 Blake Starkenburg : > Using SQL is it possible to UPDATE (append) onto an array[] column. For > example say I have a column named "scores int[]". > > ID  | scores > 2   | {54,14,21,8} > 3   | {12,0,7} > > Now I want to append the score of 12 on row:ID 2 so the new scores would > read {54

[GENERAL] Possible to UPDATE array[] columns?

2009-10-30 Thread Blake Starkenburg
Using SQL is it possible to UPDATE (append) onto an array[] column. For example say I have a column named "scores int[]". ID | scores 2 | {54,14,21,8} 3 | {12,0,7} Now I want to append the score of 12 on row:ID 2 so the new scores would read {54,14,21,8,12}. I thought maybe simply leaving th

Re: [GENERAL] Correlated Subquery and calculated column non-functional

2009-10-30 Thread Thomas Kellerer
The Frog wrote on 30.10.2009 11:07: select product.manufacturer, product.brand, SUM(sales.qtysold * sales.unitprice) as turnover, (select count(*) from cube_sales.sales as Q WHERE SUM(sales.qtysold * sales.unitprice) > turnover) + 1 as rank from cube_sales.

Re: [GENERAL] Correlated Subquery and calculated column non-functional

2009-10-30 Thread Richard Broersma
On Fri, Oct 30, 2009 at 10:42 AM, Raymond O'Donnell wrote: > On 30/10/2009 10:07, The Frog wrote: >> select >>       product.manufacturer, >>       product.brand, >>       SUM(sales.qtysold * sales.unitprice) as turnover, >>       (select count(*) from cube_sales.sales as Q WHERE SUM(sales.qtysold

Re: [GENERAL] Correlated Subquery and calculated column non-functional

2009-10-30 Thread Raymond O'Donnell
On 30/10/2009 10:07, The Frog wrote: > select > product.manufacturer, > product.brand, > SUM(sales.qtysold * sales.unitprice) as turnover, > (select count(*) from cube_sales.sales as Q WHERE SUM(sales.qtysold * > sales.unitprice) > turnover) + 1 as rank You can't use the al

[GENERAL] Correlated Subquery and calculated column non-functional

2009-10-30 Thread The Frog
Hi Everyone, I am having an issue with a query that I thought would be a fairly simple matter to implement, but apparently I have done something wrong. Can anyone point me in the right direction for a solution and explain where I have made my mistake? The idea is to produce a rank value for each r

Re: [GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread silly8888
In 8.4, the sequence value is copied only when INCLUDING DEFAULTS is specified. Otherwise, only the not null constraint is copied. I think this is the most reasonable behavior and I don't see why it should have been explicitly stated in the manual. On Fri, Oct 30, 2009 at 8:44 AM, Mark Morgan Llo

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Sam Mason
On Fri, Oct 30, 2009 at 11:39:26AM -0300, Alvaro Herrera wrote: > Sam Mason wrote: > > + Datum > > + interval_abs(PG_FUNCTION_ARGS) > > + { > > + Interval *interval1 = PG_GETARG_INTERVAL_P(0); > > + Interval *interval2 = PG_GETARG_INTERVAL_P(1); > > Surely it must receive a single argument

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Alvaro Herrera
Sam Mason wrote: > + Datum > + interval_abs(PG_FUNCTION_ARGS) > + { > + Interval *interval1 = PG_GETARG_INTERVAL_P(0); > + Interval *interval2 = PG_GETARG_INTERVAL_P(1); Surely it must receive a single argument? -- Alvaro Herrerahttp://www.CommandPro

Re: [GENERAL] checkpoints/bgwriter tuning verification

2009-10-30 Thread Vick Khera
On Thu, Oct 29, 2009 at 10:24 PM, Greg Smith wrote: > There are two ways that that writes can hang: > > 1) You've gotten to the point in the checkpoint cycle where it's calling > fsync to flush everything out of the filesystem.  At this point you could > potentially have a big chunk of data that n

Re: [GENERAL] checkpoints/bgwriter tuning verification

2009-10-30 Thread Vick Khera
On Thu, Oct 29, 2009 at 4:42 PM, Scott Marlowe wrote: > First step to speed things up is putting pg_xlog on its own disk(s). > Since pg_xlog is mostly sequentially access, it's much faster when > Did that with a symlink. I always do that. My frustration is that I have this really fast RAID subs

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Sam Mason
On Fri, Oct 30, 2009 at 02:14:31PM +0200, Marko Kreen wrote: > Slightly makes sense, but only slightly. We deterministically know, > that we dont have certain timestamp, thus we need to use some default > values. We already have situation that does that: > > extract(epoch from interval) You'r

Re: [GENERAL] checkpoints/bgwriter tuning verification

2009-10-30 Thread Guillaume Lelarge
Le vendredi 30 octobre 2009 à 03:24:05, Greg Smith a écrit : > On Thu, 29 Oct 2009, Vick Khera wrote: > > Greg, do you have a performance tuning book? If so, I really want to > > buy it! Your articles are awesome. > > Give me a few more months... > Are you kidding or is it a great teaser? it w

[GENERAL] CREATE TABLE LIKE and SERIAL

2009-10-30 Thread Mark Morgan Lloyd
What is the "correct" behavior of a serial column when a table is created with LIKE? The manual is silent on this. What appears to be happening with 8.2 is that the column in the new table refers to the original sequence generator. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opi

Re: [GENERAL] checkpoints/bgwriter tuning verification

2009-10-30 Thread Brad Nicholson
On Fri, 2009-10-30 at 07:15 -0400, Steve Clark wrote: > On 10/29/2009 04:42 PM, Scott Marlowe wrote: > > On Thu, Oct 29, 2009 at 12:46 PM, Vick Khera wrote: > >> On my primary DB I'm observing random slowness which just doesn't make > >> sense to me. The I/O system can easily do 40MB/sec writes,

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Marko Kreen
On 10/30/09, Sam Mason wrote: > On Fri, Oct 30, 2009 at 01:45:24PM +0200, Marko Kreen wrote: > > On 10/30/09, Tom Lane wrote: > > > > That was the point of my '1 day -25 hours' example. Whether you > > > consider that positive or negative seems mighty arbitrary. > > > > If I can add it to a

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Sam Mason
On Fri, Oct 30, 2009 at 01:45:24PM +0200, Marko Kreen wrote: > On 10/30/09, Tom Lane wrote: > > That was the point of my '1 day -25 hours' example. Whether you > > consider that positive or negative seems mighty arbitrary. > > If I can add it to a timestamp and get a deterministic result, > the

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Marko Kreen
On 10/30/09, Tom Lane wrote: > Jeff Davis writes: > > Yes, that is a strange case. When you can't tell if an interval is > > positive or negative, how do you define the absolute value? > > That was the point of my '1 day -25 hours' example. Whether you > consider that positive or negative see

Re: [GENERAL] Absolute value of intervals

2009-10-30 Thread Sam Mason
On Fri, Oct 30, 2009 at 12:55:51AM -0400, Tom Lane wrote: > Jeff Davis writes: > > Yes, that is a strange case. When you can't tell if an interval is > > positive or negative, how do you define the absolute value? > > That was the point of my '1 day -25 hours' example. Whether you > consider tha

Re: [GENERAL] checkpoints/bgwriter tuning verification

2009-10-30 Thread Steve Clark
On 10/29/2009 04:42 PM, Scott Marlowe wrote: On Thu, Oct 29, 2009 at 12:46 PM, Vick Khera wrote: On my primary DB I'm observing random slowness which just doesn't make sense to me. The I/O system can easily do 40MB/sec writes, but I'm only seeing a sustained 5MB/sec, even as the application is

Re: [GENERAL] Forms generator ?

2009-10-30 Thread Thom Brown
2009/10/28 Stuart Adams : > >  Looking for a forms generator for a web based UI for >  entering/modifiying/viewing a table's records. > >  Any recommendations ??? > > Thanks, >   Stuart > Do you mean a full-access web app like phppgadmin? http://phppgadmin.sourceforge.net/ Thom -- Sent via pgsq

[GENERAL] dblink and commit

2009-10-30 Thread Daniel Chiaramello
Hello. I an wondering how things happen, related to transactions using dblink. I am doing the following thing (simplified, of course), on ServerA: BEGIN insert into TableA_ServerA (...) select * from dblink(ServerB, select * from tableA_Serve

Re: [GENERAL] Forms generator ?

2009-10-30 Thread Marcin Stępnicki
Dnia Wed, 28 Oct 2009 12:59:22 -0400, Stuart Adams napisał(a): > Looking for a forms generator for a web based UI for > entering/modifiying/viewing a table's records. > > Any recommendations ??? http://python-rum.org/ http://www.djangobook.com/en/beta/chapter06/ -- Sent via pgsql-general