Re: [GENERAL] "parameterized views" or return-type-inferring SQL functions?

2010-07-19 Thread Craig Ringer
Oh, sorry for the reply-to-self, but I know I can write an SQL function with an OUT parameter list to do this. Like creating a custom rowtype for the job, though, this gets cumbersome if the column-list is long, or changes to the input tables might ever result in a change to column-list types, add

[GENERAL] "parameterized views" or return-type-inferring SQL functions?

2010-07-19 Thread Craig Ringer
Hi folks I've noticed a pattern in my SQL and am curious to know if others face the same thing, and if so how they're handling it. I often have the need to wrap up some complex query 'x' into a reusable unit, so I don't copy it repeatly all over the place. This query often requires one or more pa

Re: [GENERAL] Insert and Retrieve unsigned char sequences using C

2010-07-19 Thread Lew
vinicius_bra wrote: I'm developing a system in C and I have a unsigned char pointer that represents a struct and I like to store it in a bytea column in postgreSQL. The pointer does not represent the struct. How can I do it? Example: str_t temp; unsigned char *ptr; ptr = (unsigned char *)&te

[GENERAL] Insert and Retrieve unsigned char sequences using C

2010-07-19 Thread vinicius_bra
Hi All, I'm developing a system in C and I have a unsigned char pointer that represents a struct and I like to store it in a bytea column in postgreSQL. How can I do it? Example: str_t temp; unsigned char *ptr; ptr = (unsigned char *)&temp; store(ptr); I've already tried some examples, but I di

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Joe Conway
On 07/19/2010 01:54 PM, Igor Neyman wrote: > What you suggest is completely different from what OP asked. > > Jen wants to avoid getting error on CREATE TABLE in case her table > already exists (but proceed with CREATE TABLE, if it doesn't). > What you suggest, will drop the table (IF EXISTS), and

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Igor Neyman
> -Original Message- > From: Joe Conway [mailto:m...@joeconway.com] > Sent: Monday, July 19, 2010 12:59 PM > To: Jennifer Trey > Cc: pgsql-general@postgresql.org > Subject: Re: Create table if not exists ... how ?? > > On 07/19/2010 09:33 AM, Jennifer Trey wrote: > > I can't figure out

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread Michael Friedrich
Peter C. Lai wrote: From the roll-your-own side, have you looked at an alternative Nagios event broker called livestatus? It's written by Matthias Kettner as part of his client-centric mk-check Nagios plugin suite. Regarding this in reflection of this email livestatus won't make that much

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread Peter C. Lai
>From the roll-your-own side, have you looked at an alternative Nagios event broker called livestatus? It's written by Matthias Kettner as part of his client-centric mk-check Nagios plugin suite. At the moment it only brokers live data (hence livestatus), but it is intended to replace NDO as the g

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread Michael Friedrich
Original Message Subject: Re: [GENERAL] NASA needs Postgres - Nagios help From: Duncavage, Daniel P. (JSC-OD211) To: Michael Friedrich , Martin, Brian D. (JSC-OD)[UNITED SPACE ALLIANCE LLC] Date: 2010-07-19 19:35 Thank you for the time and thought. I've added Brian Martin,

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread Michael Friedrich
Original Message Subject: Re: [GENERAL] NASA needs Postgres - Nagios help From: Sean E. Connolly To: Michael Friedrich , daniel.p.duncav...@nasa.gov, brian.d.mar...@nasa.gov Date: 2010-07-19 21:23 Fine, so there will be a lot of boring modifying of the src and associated s

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread Sean E. Connolly
> NODutils however has no real working support for PostgreSQL, IDOutils (which > I >mentioned elsewhere in the thread) from the icinga fork does have basic >support. >The SQL queries used in NDOUtils are highly MySQL specific, mostly the ON >DUPLICATE KEY functionality based on unique constr

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread Dave Page
On Mon, Jul 19, 2010 at 5:57 PM, tuanhoanganh wrote: > I have checked SHOW fsync, It is ON. > When I view table dmvt on PgAdmin, it only has 1332 rows, but command > "SELECT count(*) FROM dmvt" return 2449 rows. By default pgAdmin shows the number of rows listed in pg_class, which is not always a

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread EllisGL
Ignore the previous link. -- 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] NASA needs Postgres - Nagios help

2010-07-19 Thread EllisGL
On Jul 13, 12:10 pm, ste...@kaltenbrunner.cc (Stefan Kaltenbrunner) wrote: > Duncavage, Daniel P. (JSC-OD211) wrote: > > > We are implementingNagioson Space Station and want to use PostgreSQL > > to store the data on orbit and then replicate that db on the ground.   > > The problem is, most people

Re: [GENERAL] Inheritance and trigger/FK propagation

2010-07-19 Thread Karsten Hilbert
> On Thu, Jul 15, 2010 at 4:05 AM, Davor J. wrote: > > It seems no secret that a child table will not fire a trigger defined on > > it's parent table. Various posts comment on this. But nowhere could I > find a > > reason for this. > > Do you want your trigger that redirects insert on parent tabl

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Scott Marlowe
On Mon, Jul 19, 2010 at 10:33 AM, Jennifer Trey wrote: > I can't figure out the correct syntax... > I have this, but it just keeps complaining about the IF > IF NOT EXISTS (SELECT table_name FROM information_schema.tables where > table_name = 'post_codes') > THEN > CREATE TABLE post_codes > ( >   

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Joe Conway
On 07/19/2010 10:43 AM, Jennifer Trey wrote: > No I don't want to drop it ... there is valuable data in there! I > only want to create it if it doesn't already exist... likely going to > happen first time the application will run. I want to create the table > then and populate. But not the next

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Said Ramirez
Assuming you know the schema name, you could always check the catalog table, something like select count(*) from pg_tables where schemaname= 'foo' and tablename='bar' If it returns, then you know a table by the name foo.bar exists. if not you can create it. -Said Jennifer Trey wrote: No

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Steve Atkins
On Jul 19, 2010, at 10:43 AM, Jennifer Trey wrote: > No I don't want to drop it ... there is valuable data in there! I only > want to create it if it doesn't already exist... likely going to happen first > time the application will run. I want to create the table then and populate. > But n

Re: [GENERAL] Inheritance and trigger/FK propagation

2010-07-19 Thread Vick Khera
On Thu, Jul 15, 2010 at 4:05 AM, Davor J. wrote: > It seems no secret that a child table will not fire a trigger defined on > it's parent table. Various posts comment on this. But nowhere could I find a > reason for this. Do you want your trigger that redirects insert on parent table to the prope

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Jennifer Trey
No I don't want to drop it ... there is valuable data in there! I only want to create it if it doesn't already exist... likely going to happen first time the application will run. I want to create the table then and populate. But not the next time. Should I just let Java throw and exception an

Re: [GENERAL] NASA needs Postgres - Nagios help

2010-07-19 Thread Duncavage, Daniel P. (JSC-OD211)
Thank you for the time and thought. I've added Brian Martin, who is my project lead for this effort. He's a better person to converse with than I am. -Original Message- From: Michael Friedrich [mailto:michael.friedr...@univie.ac.at] Sent: Sunday, July 18, 2010 4:35 PM To: Duncavage

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Joe Conway
On 07/19/2010 09:33 AM, Jennifer Trey wrote: > I can't figure out the correct syntax... > > I have this, but it just keeps complaining about the IF > > IF NOT EXISTS (SELECT table_name FROM information_schema.tables where > table_name = 'post_codes') > > THEN > > CREATE TABLE post_codes Proba

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread tuanhoanganh
I have checked SHOW fsync, It is ON. When I view table dmvt on PgAdmin, it only has 1332 rows, but command "SELECT count(*) FROM dmvt" return 2449 rows. My postgresql.conf is default of EnterpriseDB Postgres 8.3.9. Please help me. Sorry for my English. Tuan Hoang Anh. On Mon, Jul 19, 2010 at 9:

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Jennifer Trey
You all make it sound so easy :) How do I write the above using a function? Cheers, Jen

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Peter Geoghegan
> >> How should this be written ? > > I don't think you can use the "IF" like this in a normal query. You could > write a pl/pgsql function instead to do this.. You can write such a query inline in 9.0, by use of DO...but you probably just want to define a function for now -- Regards, Peter Geogh

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Pavel Stehule
Hello you can use IF statement only inside plpgsql function. CREATE TABLE doesn't support clause IF. Regards Pavel Stehule 2010/7/19 Jennifer Trey : > I can't figure out the correct syntax... > I have this, but it just keeps complaining about the IF > IF NOT EXISTS (SELECT table_name FROM infor

Re: [GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Raymond O'Donnell
On 19/07/2010 17:33, Jennifer Trey wrote: I can't figure out the correct syntax... I have this, but it just keeps complaining about the IF IF NOT EXISTS (SELECT table_name FROM information_schema.tables where table_name = 'post_codes') THEN CREATE TABLE post_codes ( area character varying(

[GENERAL] Create table if not exists ... how ??

2010-07-19 Thread Jennifer Trey
I can't figure out the correct syntax... I have this, but it just keeps complaining about the IF IF NOT EXISTS (SELECT table_name FROM information_schema.tables where table_name = 'post_codes') THEN CREATE TABLE post_codes ( area character varying(10) NOT NULL, district character varying(10

Re: [GENERAL] index scan and functions

2010-07-19 Thread arno
Le lundi 19 juillet 2010, à 17:09:02 +0100, Sam a écrit : > On Mon, Jul 19, 2010 at 05:55:48PM +0200, arno wrote: > > But when using a custom function to compute my where parameter > > > inet_to_bigint is a function that transform an inet address its integer > > representation. > > > Is there a

Re: [GENERAL] index scan and functions

2010-07-19 Thread Sam Mason
On Mon, Jul 19, 2010 at 05:55:48PM +0200, arno wrote: > But when using a custom function to compute my where parameter > inet_to_bigint is a function that transform an inet address its integer > representation. > Is there a way, either to put function return value in a variable, or to tell > pos

[GENERAL] index scan and functions

2010-07-19 Thread arno
Hi, In a table, I've some geoip informations with indexes to two colums \d geoip Table « public.geoip » Colonne | Type | Modificateurs --+--+--- begin_ip | bigint | end_ip | bigint | country | character(2) | Index : "geoip_b

Re: [GENERAL] Can not change log_min_duration_statement parameter on PG 8.2.4

2010-07-19 Thread Nicolas Payart
Ooops, I just realized I set the parameter to the ROLE postgres a few weeks ago... ALTER ROLE postgres SET log_min_duration_statement TO DEFAULT; solved my problem... which was not a problem in fact, juste a mistake :| -- Nico Le 19/07/2010 12:36, Nico a écrit : Hello, I am running a 8.2.4

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread Craig Ringer
On 19/07/10 18:37, tuanhoanganh wrote: > When I use pgadmin to view data of table dmvt, it have data. But when I > "select * from dmvt" there is error on log > > 2010-07-19 17:32:17 ICTWARNING: invalid page header in block 207 of > relation "dmvt"; zeroing out page > 2010-07-19 17:32:35 ICTLOG:

[GENERAL] Can not change log_min_duration_statement parameter on PG 8.2.4

2010-07-19 Thread Nico
Hello, I am running a 8.2.4 PostgreSQL instance on a debian etch server. I have a problem trying to change the parameter log_min_duration_statement. Its actuel value in the postgresql.conf is "-1" (log off) : log_min_duration_statement = -1# -1 is disabled, 0 logs all statements

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread Craig Ringer
On 19/07/10 19:02, Jayadevan M wrote: >> Yesterday my server is power off, when i start server, some of table is > blank. Is there anyway to rescue it. > The "Power Off" - is it a planned/regular one? If yes, it makes sense to > have a normal shutdown of the database before the "Power Off". ...

Re: [GENERAL] pg_dump and --inserts / --column-inserts

2010-07-19 Thread Sam Mason
On Sat, Jul 17, 2010 at 07:46:23PM +0200, Thomas Kellerer wrote: > Tom Lane wrote on 17.07.2010 19:35: >> I'd dismiss those numbers as being within experimental >> error, except it seems odd that they all differ in the same direction. > > And it's reproducable (at least on my computer). As I said I

Re: [GENERAL] Incorrect FTS result with GIN index

2010-07-19 Thread Oleg Bartunov
Artur, I don't know, but could you try linux machine ? Oleg On Mon, 19 Jul 2010, Artur Dabrowski wrote: Hello Oleg, my results are different. The analysis looks like this (please note the different numbers of rows): Aggregate (cost=104.05..104.06 rows=1 width=0) (actual time=152.133..152.1

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread Jayadevan M
> Yesterday my server is power off, when i start server, some of table is blank. Is there anyway to rescue it. The "Power Off" - is it a planned/regular one? If yes, it makes sense to have a normal shutdown of the database before the "Power Off". You said "some of table is blank". If those table

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread tuanhoanganh
When I use pgadmin to view data of table dmvt, it have data. But when I "select * from dmvt" there is error on log 2010-07-19 17:32:17 ICTWARNING: invalid page header in block 207 of relation "dmvt"; zeroing out page 2010-07-19 17:32:35 ICTLOG: server process (PID 3480) was terminated by excepti

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread tuanhoanganh
Yes, I don't have backup. On Mon, Jul 19, 2010 at 4:24 PM, A. Kretschmer < andreas.kretsch...@schollglas.com> wrote: > In response to tuanhoanganh : > > Is there anyway to rescue data afer power off. > > I have postgres database version 8.3.9 on windows 2003. > > Yesterday my server is power off,

Re: [GENERAL] Incorrect FTS result with GIN index

2010-07-19 Thread Artur Dabrowski
Hello Oleg, my results are different. The analysis looks like this (please note the different numbers of rows): Aggregate (cost=104.05..104.06 rows=1 width=0) (actual time=152.133..152.135 rows=1 loops=1) -> Bitmap Heap Scan on search_tab (cost=5.39..103.98 rows=25 width=0) (actual time=76.

Re: [GENERAL] Rescue data after power off

2010-07-19 Thread A. Kretschmer
In response to tuanhoanganh : > Is there anyway to rescue data afer power off. > I have postgres database version 8.3.9 on windows 2003. > Yesterday my server is power off, when i start server, some of table is blank. > Is there anyway to rescue it. Restore the data from your backup. You haven't a

Re: [GENERAL] Full Text Search ideas

2010-07-19 Thread Steve Grey
On 19 July 2010 01:46, Howard Rogers wrote: > On Mon, Jul 19, 2010 at 6:16 AM, Tom Lane wrote: > > Howard Rogers writes: > >> ims=# select count(*) from search_rm > >> where to_tsvector('english', textsearch) @@ to_tsquery('english','bat & > sb12n'); > >> count > >> --- > >> 3849 > >> (1 r

[GENERAL] Rescue data after power off

2010-07-19 Thread tuanhoanganh
Is there anyway to rescue data afer power off. I have postgres database version 8.3.9 on windows 2003. Yesterday my server is power off, when i start server, some of table is blank. Is there anyway to rescue it. Please help me. I am very confuse. Tuan Hoang Anh