Re: [GENERAL] What Programs Do You Use For PG?

2010-12-22 Thread Neil D'Souza
interesting project.  do you have any documentation describing how it works?
merlin

Hi Merlin,

  Thank you for your interest in the project.

  Here is how to get it up and running so that you can try out the same
application that you see running on:  http://173.230.133.34:8080/

 0. To build the project you need boost, flex, bison, and wt and g++.
I'm doing this on GNU/Linux - it should be possible to build on Windows too.
 1. Download and install the webtoolkit (http://www.webtoolkit.eu)
wt-3.1.6
 2. Download extjs-2.1 here is one link I found on google:
http://olex.openlogic.com/packages/extjs/2.1
 3. You need to follow the extjs deployment notes given in the Wt
documentation
   for example:
   my extjs-2.1 resides in /home/nxd/dnld/extjs-2.1-src ,
when deploying you will have to make a link to this directory
   cd /home/nxd/dnld/extjs-2.1-src
   ln -s adapter/ext/ext-base.js .
 4. Clone the repository on sourceforge (version control tool is git)
   /media/sda3/home/nxd/test2git clone git://
proghelp.git.sourceforge.net/gitroot/proghelp/proghelp
5.  Setup the build areas ( these steps might not be necessary as I
added dummy files to the directories, but just in case)
Promptcd proghelp
 Promptmkdir make-build-dir bin
Promptcd inputs
Promptmkdir -p output/CppCodeGenerator
Promptcd ..
6. Build the compiler - actually I cant really call it one considering
how simple it is.
CustomMakefile is the makefile for doing a build.

  /media/sda3/home/nxd/test2/proghelpmake -f CustomMakefile
 Ignore compile warnings :)
 The last output of the make file is to copy certain files to the
output folder - do it.
 cp inputs/CalendarCell.C inputs/CalendarCell.h
inputs/TimesheetCalendar.C inputs/TimesheetCalendar.h
inputs/output/CppCodeGenerator
 7. Build the sample application.
  /media/sda3/home/nxd/test3/proghelpcd inputs
 /media/sda3/home/nxd/test2/proghelp/inputs ../bin/csassist.exe
--database-name proghelpdemo1 emp2.sql

The generated code is written to output/CppCodeGenerator
It also creates a directory with the timestamp at which you
created the project - and all unified sql scripts are created there.


  8.   setup the sample database we used in step 7. Please note that
these commands are most probably not best practices and should not be used
in this way in a production environment. You may need to switch to user
postgres to run these commands. My postgres runs on port 5433 (because ... )


   8.1 Database creation related stuff
 /media/sda3/home/nxd/test2/proghelp/inputscreatedb -p 5433
proghelpdemo1

If the plpgsql language is not added to your template1 database
then you need to add the language to the database too.
 /media/sda3/home/nxd/test2/proghelp/inputscreatelang  -p 5433
plpgsql proghelpdemo1

   8.2 unified scripts setup

  1. Change to the timestamp directory where the unified scripts
reside. The name of the timestamp directory will be output in step 7.
   /media/sda3/home/nxd/test2/proghelp/inputscd
output/CppCodeGenerator/2010-12-22-13:12:20

 2. run the unified script creator shell scripts.
/media/sda3/home/nxd/test2/proghelp/inputs/output/
CppCodeGenerator/2010-12-22-13:12:20ls
 unified_create_func_sql.sh  unified_create_tables_sql.sh
unified_drop_func_sql.sh  unified_drop_tables.sql
unified_load_rdg_data_sql.sh
/media/sda3/home/nxd/test2/proghelp/inputs/output/
CppCodeGenerator/2010-12-22-13:12:20sh unified_create_tables_sql.sh
 /media/sda3/home/nxd/test2/proghelp/inputs/output/
CppCodeGenerator/2010-12-22-13:12:20sh unified_create_func_sql.sh
/media/sda3/home/nxd/test2/proghelp/inputs/output/
CppCodeGenerator/2010-12-22-13:12:20sh unified_load_rdg_data_sql.sh

  3. execute the scripts on the database
/media/sda3/home/nxd/test2/proghelp/inputs/output/
CppCodeGenerator/2010-12-22-13:12:20psql -p 5433 proghelpdemo1
  a. proghelpdemo1= \i unified_create_tables.sql
   b. proghelpdemo1= \i unified_load_rdg_data.sql
  step b will have some errors because my Random Data
Generator does not take care of foreign keys for master details tables.
These can be ingored.
   c. proghelpdemo1= \i unified_create_func.sql
  d. There is one stored procedure that is not automatically
added to the unified scripts, you need to load this one manually.

   proghelpdemo1= \q
 /media/sda3/home/nxd/test2/proghelp/inputs/output/
CppCodeGenerator/2010-12-22-13:12:20cd ..
 /media/sda3/home/nxd/test2/proghelp/inputs/output/CppCodeGeneratorpsql
-p 5433 proghelpdemo1
  proghelpdemo1= \i sp_User_Login_authenticate_login_postgres.sql
9. Build the generated app
  

Re: [GENERAL] Constraining overlapping date ranges

2010-12-22 Thread Vincent Veyron
Le mardi 21 décembre 2010 à 10:49 -0500, McGehee, Robert a écrit :
 PostgreSQLers,
 I'm hoping for some help creating a constraint/key on a table such that there 
 are no overlapping ranges of dates for any id. 
 
 Specifically: Using PostgreSQL 9.0.1, I'm creating a name-value pair table as 
 such this:
 
 CREATE TABLE tbl (id INTEGER, start_date DATE, stop_date DATE, value REAL);
 
 For a given id, I'd like to enforce that there is only one valid value on a 
 given date. For instance, this would be acceptable:
 
 idstart_date  stop_date   value
 2 2010-11-01  2010-12-01  3
 2 2010-12-02  2010-12-15  4
 3 2010-10-15  2010-12-15  -3
 
 But this would not: (notice start_date of line 2 is before stop_date of line 
 1).
 idstart_date  stop_date   value
 2 2010-11-01  2010-12-01  3
 2 2010-11-30  2010-12-15  4
 3 2010-10-15  2010-12-15  -3
 

You could use a rule, as explained here:

http://www.postgresql.org/docs/8.4/static/rules-update.html

In your case, something like :

create table bad (like tbl);

CREATE RULE no_overlap AS ON INSERT to tbl WHERE EXISTS (SELECT 1 from
tbl t1 WHERE t1.start_date between NEW.start_date and NEW.stop_date or
t1.stop_date between NEW.start_date and NEW.stop_date AND t1.id=NEW.id)
DO INSTEAD INSERT INTO bad VALUES
(NEW.id,NEW.start_date,NEW.stop_date,NEW.value);

Then have your app check if the new record went into bad, for instance.



-- 
Vincent Veyron
http://marica.fr/
Progiciel de gestion des dossiers de contentieux et d'assurance pour le service 
juridique



-- 
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] Constraining overlapping date ranges

2010-12-22 Thread Vincent Veyron
Le mardi 21 décembre 2010 à 10:49 -0500, McGehee, Robert a écrit :
 PostgreSQLers,
 I'm hoping for some help creating a constraint/key on a table such that there 
 are no overlapping ranges of dates for any id. 
 
 Specifically: Using PostgreSQL 9.0.1, I'm creating a name-value pair table as 
 such this:
 
 CREATE TABLE tbl (id INTEGER, start_date DATE, stop_date DATE, value REAL);
 
 For a given id, I'd like to enforce that there is only one valid value on a 
 given date. For instance, this would be acceptable:
 
 idstart_date  stop_date   value
 2 2010-11-01  2010-12-01  3
 2 2010-12-02  2010-12-15  4
 3 2010-10-15  2010-12-15  -3
 
 But this would not: (notice start_date of line 2 is before stop_date of line 
 1).
 idstart_date  stop_date   value
 2 2010-11-01  2010-12-01  3
 2 2010-11-30  2010-12-15  4
 3 2010-10-15  2010-12-15  -3
 

You could use a rule, as explained here:

http://www.postgresql.org/docs/8.4/static/rules-update.html

In your case, something like :

create table bad (like tbl);

CREATE RULE no_overlap AS ON INSERT to tbl WHERE EXISTS (SELECT 1 from
tbl t1 WHERE t1.start_date between NEW.start_date and NEW.stop_date or
t1.stop_date between NEW.start_date and NEW.stop_date AND t1.id=NEW.id)
DO INSTEAD INSERT INTO bad VALUES
(NEW.id,NEW.start_date,NEW.stop_date,NEW.value);

Then have your app check if the new record went into bad, for instance.



-- 
Vincent Veyron
http://marica.fr/
Progiciel de gestion des dossiers de contentieux et d'assurance pour le service 
juridique


-- 
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] Constraining overlapping date ranges

2010-12-22 Thread Filip Rembiałkowski
2010/12/21 McGehee, Robert robert.mcge...@geodecapital.com:
 PostgreSQLers,
 I'm hoping for some help creating a constraint/key on a table such that there 
 are no overlapping ranges of dates for any id.

 Specifically: Using PostgreSQL 9.0.1, I'm creating a name-value pair table as 
 such this:

 CREATE TABLE tbl (id INTEGER, start_date DATE, stop_date DATE, value REAL);

 For a given id, I'd like to enforce that there is only one valid value on a 
 given date. For instance, this would be acceptable:

 id      start_date      stop_date       value
 2       2010-11-01      2010-12-01      3
 2       2010-12-02      2010-12-15      4
 3       2010-10-15      2010-12-15      -3

 But this would not: (notice start_date of line 2 is before stop_date of line 
 1).
 id      start_date      stop_date       value
 2       2010-11-01      2010-12-01      3
 2       2010-11-30      2010-12-15      4
 3       2010-10-15      2010-12-15      -3

 I'd also appreciate it if anyone can provide any indexing hints on this table 
 to optimize queries like:
 SELECT value FROM tbl WHERE id=2 and '2010-12-02' BETWEEN start_date AND 
 stop_date;

 Thanks in advance, and sorry if I overlooked any obvious documentation!



No one has mentioned exclusionn constraints yet... :-)

I have combined it with period contrib (see
http://pgfoundry.org/projects/temporal/) to do what you want.
Note: you don't have to use this contrib; equivalently, you can CAST
date periods to boxes, just make sure the function is injective.

-- index requires immutable function, and for some unknown reason
(anybody?) point and period constructors are not immutable...
CREATE OR REPLACE FUNCTION f_point(integer) RETURNS point LANGUAGE sql AS
'SELECT point($1,$1)' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION f_period(date,date) RETURNS period LANGUAGE sql AS
'SELECT period($1,$2)' IMMUTABLE STRICT;

CREATE TABLE tbl (
id integer NOT NULL,
start_date date NOT NULL,
end_date date,
CONSTRAINT tbl_exclude_overlaps EXCLUDE USING gist ( f_point(id)
WITH ~=, f_period(start_date,end_date) WITH  )
);

INSERT INTO tbl SELECT 1, '2010-01-01', '2010-12-31';
INSERT 0 1
INSERT INTO tbl SELECT 1, '2011-01-01', '2011-03-31';
INSERT 0 1
INSERT INTO tbl SELECT 2, '2010-01-01', '2010-12-21';
INSERT 0 1
INSERT INTO tbl SELECT 2, '2010-12-22', '2010-12-31';
INSERT 0 1
INSERT INTO tbl SELECT 2, '2010-12-25', '2010-12-26';
ERROR:  conflicting key value violates exclusion constraint
tbl_exclude_overlaps
DETAIL:  Key (f_point(id), f_period(start_date, end_date))=((2,2),
[2010-12-25 00:00:00+01, 2010-12-26 00:00:00+01)) conflicts with
existing key (f_point(id), f_period(start_date, end_date))=((2,2),
[2010-12-22 00:00:00+01, 2010-12-31 00:00:00+01)).


greets,
Filip

-- 
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] Constraining overlapping date ranges

2010-12-22 Thread Thomas Kellerer

Filip Rembiałkowski, 22.12.2010 14:28:

INSERT INTO tbl SELECT 1, '2010-01-01', '2010-12-31';
INSERT 0 1


I'm curious why you use this syntax as you have fixed values and could use the 
standard VALUES construct without problems:

INSERT INTO tbl VALUES (1, '2010-01-01', '2010-12-31');

Regards
Thomas


--
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] Constraining overlapping date ranges

2010-12-22 Thread Filip Rembiałkowski
2010/12/22 Thomas Kellerer spam_ea...@gmx.net:

 I'm curious why you use this syntax as you have fixed values and could use
 the standard VALUES construct without problems:

 INSERT INTO tbl VALUES (1, '2010-01-01', '2010-12-31');

no particular reason; just two keystrokes less :-)

The SQL code is postgres-specific anyway.

-- 
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] Table inheritance foreign key problem

2010-12-22 Thread Tom Lane
Richard Broersma richard.broer...@gmail.com writes:
 On Tue, Dec 21, 2010 at 9:32 PM, Andy Chambers achamb...@mcna.net wrote:
 create table guidebooks (
  city check (city in (select name
 from cities)),

 This is a nice idea.  They only problem is that PostggreSQL doesn't
 support sub-selects in a tables check constraints:
 http://www.postgresql.org/docs/9.0/interactive/sql-createtable.html

And, before anybody says what if I hide the sub-select in a function,
here's the *real* problem with trying to use a CHECK constraint as a
substitute for a foreign key: it's not checked at the right times.
CHECK is assumed to be a condition involving only the values of the row
itself, so it's only checked during insert or update.  There is nothing
preventing a change in the other table from invalidating your FK
reference.

There are some subsidiary problems, like dump/reload not realizing that
there's any ordering constraint on how it restores the two tables, but
the lack of a defense against deletions in the PK table is the real
killer for this idea.

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Unable to write inside TEMP environment variable path

2010-12-22 Thread RensGroen

Hi there,

I wanted to install postgreSQL on a Windows XP machine, but during the
install it says:
http://postgresql.1045698.n5.nabble.com/file/n3315027/error.png 

Anyone knows what to do? The user is an admin, and there is enough free disk
space to write for.

Thanks in advance.

Rens
-- 
View this message in context: 
http://postgresql.1045698.n5.nabble.com/Unable-to-write-inside-TEMP-environment-variable-path-tp3315027p3315027.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

-- 
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] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Kelly Burkhart
On Tue, Dec 21, 2010 at 6:11 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 Merlin Moncure mmonc...@gmail.com writes:
 On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 If you just unconditionally flush there, it will result in an extra
 network message in the normal case where there's not another query
 to do.  The current code is designed not to flush until it sends
 ReadyForQuery.

 yeah, I was looking at that.  I don't see an easy way to test if there
 is another query waiting to execute right there.  Maybe a
 documentation patch is in order :-).

 dest.c doesn't have the info available.  I think that to do this, we'd
 need to move the responsibility for calling pq_flush out to postgres.c.
 Not sure if it's worth it.

So if I understand correctly, a flush will occur when all commands are
completed and prior to completion, whenever PqSendBuffer is full.
Analogous to stdio full vs. line buffering, this is full rather than
result buffering.

It seems to me that is not quite optimal and 'result buffering' would
be better.  Did you come to the same conclusion but decide that it's
not 'better enough' to justify polluting postgres.c with a special
flush to satisfy this case?

-K

-- 
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] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Merlin Moncure
On Wed, Dec 22, 2010 at 10:07 AM, Kelly Burkhart
kelly.burkh...@gmail.com wrote:
 On Tue, Dec 21, 2010 at 6:11 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 Merlin Moncure mmonc...@gmail.com writes:
 On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 If you just unconditionally flush there, it will result in an extra
 network message in the normal case where there's not another query
 to do.  The current code is designed not to flush until it sends
 ReadyForQuery.

 yeah, I was looking at that.  I don't see an easy way to test if there
 is another query waiting to execute right there.  Maybe a
 documentation patch is in order :-).

 dest.c doesn't have the info available.  I think that to do this, we'd
 need to move the responsibility for calling pq_flush out to postgres.c.
 Not sure if it's worth it.

 So if I understand correctly, a flush will occur when all commands are
 completed and prior to completion, whenever PqSendBuffer is full.
 Analogous to stdio full vs. line buffering, this is full rather than
 result buffering.

 It seems to me that is not quite optimal and 'result buffering' would
 be better.  Did you come to the same conclusion but decide that it's
 not 'better enough' to justify polluting postgres.c with a special
 flush to satisfy this case?

The basic issue is that multiple queries per libpq call is more or
less a misfeature -- it's not worth refactoring the backend protocol
handling to peek ahead to know if it needs to flush on command
complete.  Note that you can't use parametrized statements when using
this method, and use of parameterized statements should always be
encouraged.

Maybe there is another way to do what you are trying to do?

merlin

-- 
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] Cannot unsubscribe

2010-12-22 Thread Adrian Klaver
On Wednesday 22 December 2010 7:18:00 am William Gordon Rutherdale (rutherw) 
wrote:


 Unfortunately I haven't a clue what my password is supposed to be.

It would have been in the confirmation reply that you got when you signed up, 
on 
the off chance you still have it:)


 Clearly something is broken in the system, as it's contradicting itself
 by sending me emails but failing to recognise that same email address
 when I attempt to unsubscribe.  This is not my fault.

One of those left hand/right hand problems unfortunately.


 I need to have this problem fixed today.  This is my last day before the
 holidays.

 Could you please just fix it and get me off the list.

I am afraid I do not have the access. Your best bet would be to send an email 
to 
the admin- majordomo-ow...@postgresql.org

 -Will



-- 
Adrian Klaver
adrian.kla...@gmail.com

-- 
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] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Kelly Burkhart
On Wed, Dec 22, 2010 at 9:18 AM, Merlin Moncure mmonc...@gmail.com wrote:
 On Wed, Dec 22, 2010 at 10:07 AM, Kelly Burkhart
 kelly.burkh...@gmail.com wrote:
 On Tue, Dec 21, 2010 at 6:11 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 Merlin Moncure mmonc...@gmail.com writes:
 On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 If you just unconditionally flush there, it will result in an extra
 network message in the normal case where there's not another query
 to do.  The current code is designed not to flush until it sends
 ReadyForQuery.

 yeah, I was looking at that.  I don't see an easy way to test if there
 is another query waiting to execute right there.  Maybe a
 documentation patch is in order :-).

 dest.c doesn't have the info available.  I think that to do this, we'd
 need to move the responsibility for calling pq_flush out to postgres.c.
 Not sure if it's worth it.

 So if I understand correctly, a flush will occur when all commands are
 completed and prior to completion, whenever PqSendBuffer is full.
 Analogous to stdio full vs. line buffering, this is full rather than
 result buffering.

 It seems to me that is not quite optimal and 'result buffering' would
 be better.  Did you come to the same conclusion but decide that it's
 not 'better enough' to justify polluting postgres.c with a special
 flush to satisfy this case?

 The basic issue is that multiple queries per libpq call is more or
 less a misfeature -- it's not worth refactoring the backend protocol
 handling to peek ahead to know if it needs to flush on command
 complete.  Note that you can't use parametrized statements when using
 this method, and use of parameterized statements should always be
 encouraged.

 Maybe there is another way to do what you are trying to do?

The real world thing I'm trying to accomplish:  We have several GUI
applications that start up and must perform several queries before
displaying anything useful.  When the app is (latency wise) far away
from the DB, startup time is noticeably slower.  I was experimenting
with the multiple queries per libpq call (which doesn't seem like a
misfeature at all to me) to suggest to the owners of these apps a way
to realize faster startup.

In my particular case, sending multiple queries in one go will help
them regardless of weather they get the results back as they complete
or all at once.  Current behavior is surprising though based on how
the documentation is written.  I think I agree that 'result buffering'
is not better enough to justify significant work, on the other hand if
the fix is simple it would IMO be an improvement.

-K

-- 
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] Constraining overlapping date ranges

2010-12-22 Thread McGehee, Robert
Filip,
The period type + exclusion constraint was exactly the avenue I was taking, and 
I was also perplexed that period was not defined as immutable. Your solution, 
to force period() to be immutable, seemed like a reasonable one (though it 
didn't work, see below).

I tried implementing this on my existing table:
ALTER TABLE tbl ADD EXCLUDE USING gist
(f_point(id) WITH ~=, f_period(start_date, stop_date) WITH );

and the index correctly identified all of the overlapping periods in my table 
by failing with details on the improper key. HOWEVER, after fixing all of the 
offending data, the index still failed to create:
ERROR:  failed to re-find tuple within index tbl_f_point_f_period_excl
HINT:  This may be because of a non-immutable index expression.

(What does this mean?) The index seems to work on an empty table (per your 
example), but not on my populated table, and the HINT seems to indicate that 
period() is not, in fact, immutable, which makes me nervous about using this 
solution. Hopefully someone knows what's going on here.

So I think my other options are to use period data columns (rather than 
start_date and end_date), then no coercion is needed in the EXCLUDE clause; try 
to CAST the date periods to boxes (as you suggested); use a rule, per Vincent's 
suggestion; or not check for overlap as it may be uncommon.

Also, I found Jeff Davis's summary of the exclusion constraint helpful in case 
anyone's interested:
http://thoughts.j-davis.com/2010/09/25/exclusion-constraints-are-generalized-sql-unique/

Thanks, Robert

PS. I don't think the f_point function is necessary. Something like:
... EXCLUDE USING gist (id WITH =, f_period(start_date, end_date) WITH )
seems equivalent to your suggestion:
... EXCLUDE USING gist (f_point(id) WITH ~=, f_period(start_date, end_date) 
WITH )

-Original Message-
From: Filip Rembiałkowski [mailto:filip.rembialkow...@gmail.com] 
Sent: Wednesday, December 22, 2010 8:28 AM
To: McGehee, Robert
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Constraining overlapping date ranges

2010/12/21 McGehee, Robert robert.mcge...@geodecapital.com:
 PostgreSQLers,
 I'm hoping for some help creating a constraint/key on a table such that there 
 are no overlapping ranges of dates for any id.

 Specifically: Using PostgreSQL 9.0.1, I'm creating a name-value pair table as 
 such this:

 CREATE TABLE tbl (id INTEGER, start_date DATE, stop_date DATE, value REAL);

 For a given id, I'd like to enforce that there is only one valid value on a 
 given date. For instance, this would be acceptable:

 id      start_date      stop_date       value
 2       2010-11-01      2010-12-01      3
 2       2010-12-02      2010-12-15      4
 3       2010-10-15      2010-12-15      -3

 But this would not: (notice start_date of line 2 is before stop_date of line 
 1).
 id      start_date      stop_date       value
 2       2010-11-01      2010-12-01      3
 2       2010-11-30      2010-12-15      4
 3       2010-10-15      2010-12-15      -3

 I'd also appreciate it if anyone can provide any indexing hints on this table 
 to optimize queries like:
 SELECT value FROM tbl WHERE id=2 and '2010-12-02' BETWEEN start_date AND 
 stop_date;

 Thanks in advance, and sorry if I overlooked any obvious documentation!



No one has mentioned exclusionn constraints yet... :-)

I have combined it with period contrib (see
http://pgfoundry.org/projects/temporal/) to do what you want.
Note: you don't have to use this contrib; equivalently, you can CAST
date periods to boxes, just make sure the function is injective.

-- index requires immutable function, and for some unknown reason
(anybody?) point and period constructors are not immutable...
CREATE OR REPLACE FUNCTION f_point(integer) RETURNS point LANGUAGE sql AS
'SELECT point($1,$1)' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION f_period(date,date) RETURNS period LANGUAGE sql AS
'SELECT period($1,$2)' IMMUTABLE STRICT;

CREATE TABLE tbl (
id integer NOT NULL,
start_date date NOT NULL,
end_date date,
CONSTRAINT tbl_exclude_overlaps EXCLUDE USING gist ( f_point(id)
WITH ~=, f_period(start_date,end_date) WITH  )
);

INSERT INTO tbl SELECT 1, '2010-01-01', '2010-12-31';
INSERT 0 1
INSERT INTO tbl SELECT 1, '2011-01-01', '2011-03-31';
INSERT 0 1
INSERT INTO tbl SELECT 2, '2010-01-01', '2010-12-21';
INSERT 0 1
INSERT INTO tbl SELECT 2, '2010-12-22', '2010-12-31';
INSERT 0 1
INSERT INTO tbl SELECT 2, '2010-12-25', '2010-12-26';
ERROR:  conflicting key value violates exclusion constraint
tbl_exclude_overlaps
DETAIL:  Key (f_point(id), f_period(start_date, end_date))=((2,2),
[2010-12-25 00:00:00+01, 2010-12-26 00:00:00+01)) conflicts with
existing key (f_point(id), f_period(start_date, end_date))=((2,2),
[2010-12-22 00:00:00+01, 2010-12-31 00:00:00+01)).


greets,
Filip

-- 
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] Cannot unsubscribe

2010-12-22 Thread William Gordon Rutherdale (rutherw)
 -Original Message-
 From: Adrian Klaver [mailto:adrian.kla...@gmail.com]
 Sent: 21 December 2010 20:36
 To: pgsql-general@postgresql.org
 Cc: William Gordon Rutherdale (rutherw)
 Subject: Re: [GENERAL] Cannot unsubscribe
 
 On Tuesday 21 December 2010 4:16:00 pm William Gordon Rutherdale
 (rutherw)
 wrote:
  I attempted to unsubscribe from this list (for the holidays) without
  success.
 
  Could anyone please help me.  I am continuing to get messages from
 the
  list.
 
  I broke open the message header and did as it said for
unsubscribing.
 
  See below for what the majordomo sent back.
 
  -Will
 
   unsub pgsql-general
 
   The unsubscribe command did not succeed.
  
   No e-mail addresses matching
     William Gordon Rutherdale (rutherw) ruth...@cisco.com
   are subscribed to the pgsql-general mailing list.
  
 
  Valid commands processed: 1
  0 succeeded, 0 stalled, and 1 failed.
 
 
  Use the following command:
sessioninfo ea4ce02c75fbad19425a55ff2bd2bc20b17fd794
  to see technical information about this session.
 
 You may want to try the Web link at the bottom of the page and access
 your
 subscription from there. You will need to know the password you where
 issued
 when you joined though.
 
 --
 Adrian Klaver
 adrian.kla...@gmail.com

Unfortunately I haven't a clue what my password is supposed to be.

Clearly something is broken in the system, as it's contradicting itself
by sending me emails but failing to recognise that same email address
when I attempt to unsubscribe.  This is not my fault.

I need to have this problem fixed today.  This is my last day before the
holidays.

Could you please just fix it and get me off the list.

-Will


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

We are using postgresql 8.2.17 on Gentoo

Our postgresql database stopped working with the error
ERROR:  could not open relation 1663/26468499/26470404: No such file or 
directory


After one minute of these errors on every statement run we had what 
looks like a memory failure:
Dec 22 16:37:44 localhost kernel: [279820.425911] postgres invoked 
oom-killer: gfp_mask=0x280da, order=0, oom_adj=0
Dec 22 16:37:44 localhost kernel: [279820.425917] postgres cpuset=/ 
mems_allowed=0
Dec 22 16:37:44 localhost kernel: [279820.425922] Pid: 26209, comm: 
postgres Not tainted 2.6.32-gentoo-r7 #12


We cannot connect to the database using psql as it gives the could not 
open relation error. We ran fsck and did not find any problems. I 
searched through google and found suggestions such as reindex, but we 
can't connect to the db. We also can't take a backup of the database as 
pg_dump gives the same error.


This is our production database and crashed at the end of the day. If 
possible, I would really not like to lose a full days work by restoring 
yesterdays backup.


Thanks
Sim

--
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] could not open relation...No such file or directory

2010-12-22 Thread Vick Khera
On Wed, Dec 22, 2010 at 10:59 AM, Sim Zacks s...@compulab.co.il wrote:
 This is our production database and crashed at the end of the day. If
 possible, I would really not like to lose a full days work by restoring
 yesterdays backup.


So the errors in postgres started after your server crashed?  Sounds
like the server crash caused some file system corruption.

-- 
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] could not accept SSPI security context

2010-12-22 Thread Reto Schöning
ok we moved to VS08 and I can at last experiment with the npgsql code. I
tried forcing kerberos instead of negotiate in the call to
AcquireCredentialsHandle in SSPIHandler.cs. The exception message I then get
in the first call to InitializeSecurityContext() is

The security database on the server does not have a computer account for
this workstation trust relationship

googling that yields AD configuration issues as a possible cause (eg
http://social.technet.microsoft.com/Forums/en-US/itprovistasp/thread/31905c1a-5c25-4426-ac8d-677004c21f5d).
I will check that with our IT. However since from the same machines, psql
and other pg clients can successfully connect using kerberos, an AD issue
seems unlikely to be the (sole) cause.

I also speculated that the CurrentPrincipal on the thread might matter and
made sure that it was the kerberos-authenticated WindowsPrincipal, instead
of the default GenericPrincipal. But that made no difference.

Is there anything else in the code that I could check or try?
Regards,
Reto


2010/12/3 Brar Piening b...@gmx.de

 Passing null instead of empty string for the principal shouldn't make any
 difference as an empty CLR-String should be marshalled to an empty (null
 terminated) C-String.

 The problem could also be in InitializeSecurityContext which happens in
 respnse to AuthenticationGSSContinue.

 If you happen to find out what the problem is - please let me know or wrap
 a patch for the Npgsql development team so that we can fix it.

 I'm sorry that I can't be very helpful in tracking down this issue, but I
 don't have a Windows 2008 Server, or even any other Kerberos-Setup available
 to test it.

 Actually the SSPI-Patch was something I once put out knowing that I'll be
 bogged down by other stuff immediatley afterwards, and it didn't see much
 maintainace since then.
 There are some oversights like

 // TODO: correct exception
 throw new Exception();

 in NpgsqlState.cs and the fact that the Continue method (in SSPIHandler.cs)
 returns the (opaque) secbuffer as ASCII-String (encoded by
 System.Text.Encoding.ASCII.GetString(Byte[])) should even be considered as a
 bug (even though to my knowledge it didn't cause any problems until now).

 In other words - I'd be willing to overhaul the wohle thing if I find a
 good reason to do so (and some time).

 Regards,

 Brar


 On Fri, 3 Dec 2010 06:32:17 +0100, Reto Schöning
 reto.schoen...@gmail.com reto.schoen...@gmail.com wrote:

 thanks, and sorry for my slow responses, I'm bogged down by other stuff. I
 plan to get the source and try some things like
 - force kerberos to see if the reason that NTLM is used is that kerberos
 fails and hope for some hints at the cause of the failure
 - pass null instead of empty string for the principal
 - check out the principal on the calling thread etc.
 and post the results to the list. Could take I week or so until a get to
 that though.
 Regards, Reto

 2010/11/29 Brar Piening b...@gmx.de

 On Mon, 29 Nov 2010 15:27:35 +0100, Reto Schöning 
 reto.schoen...@gmail.com wrote:

 I just heard back from our IT. There's nothing in the logs for this
 connection attempt, but they noted in the Npgsql log that the authentication
 was attempted using NTLM. However our domain controller no longer supports
 NTLM, but only LDAP(s) and kerberos (it's a Windows 2008 server). From the
 docs I understand that with SSPI, pg should try kerberos first and fall back
 to NTLM. This works when connecting from psql. Maybe Npgsql goes straight
 for NTLM, at least when using it the way I do?


 Both are using the Negotiate SSP authentication package

 http://msdn.microsoft.com/en-us/library/aa378748%28v=VS.85%29.aspx

 Npgsql (SSPIHandler.cs):
 int status = AcquireCredentialsHandle(
,
negotiate,
SECPKG_CRED_OUTBOUND,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
ref sspicred,
out expire
 );

 libpq (fe-auth.c):
 /*
  * Send initial SSPI authentication token.
  * If use_negotiate is 0, use kerberos authentication package which is
  * compatible with Unix. If use_negotiate is 1, use the negotiate package
  * which supports both kerberos and NTLM, but is not compatible with Unix.
  */
 r = AcquireCredentialsHandle(NULL,
use_negotiate ? negotiate : kerberos,
SECPKG_CRED_OUTBOUND,
NULL,
NULL,
NULL,
NULL,
conn-sspicred,
 expire);

 It should be a one line patch to force Npgsql into using kerberos but I
  can't see any reason why negotiate should act differently between Npgsql
 and libpq.

 Regards,

 Brar







Re: [GENERAL] could not open relation...No such file or directory

2010-12-22 Thread Adrian Klaver

On 12/22/2010 07:59 AM, Sim Zacks wrote:

We are using postgresql 8.2.17 on Gentoo

Our postgresql database stopped working with the error
ERROR: could not open relation 1663/26468499/26470404: No such file or
directory

After one minute of these errors on every statement run we had what
looks like a memory failure:
Dec 22 16:37:44 localhost kernel: [279820.425911] postgres invoked
oom-killer: gfp_mask=0x280da, order=0, oom_adj=0
Dec 22 16:37:44 localhost kernel: [279820.425917] postgres cpuset=/
mems_allowed=0
Dec 22 16:37:44 localhost kernel: [279820.425922] Pid: 26209, comm:
postgres Not tainted 2.6.32-gentoo-r7 #12

We cannot connect to the database using psql as it gives the could not
open relation error. We ran fsck and did not find any problems. I
searched through google and found suggestions such as reindex, but we
can't connect to the db. We also can't take a backup of the database as
pg_dump gives the same error.


Does the not connect also apply to starting postgres in single user mode?




This is our production database and crashed at the end of the day. If
possible, I would really not like to lose a full days work by restoring
yesterdays backup.

Thanks
Sim




--
Adrian Klaver
adrian.kla...@gmail.com

--
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] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

On 12/22/2010 06:08 PM, Vick Khera wrote:


On Wed, Dec 22, 2010 at 10:59 AM, Sim Zackss...@compulab.co.il  wrote:

This is our production database and crashed at the end of the day. If
possible, I would really not like to lose a full days work by restoring
yesterdays backup.

So the errors in postgres started after your server crashed?  Sounds
like the server crash caused some file system corruption.

No. The errors started and then a minute later the server crashed.

--
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] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

On 12/22/2010 06:28 PM, Adrian Klaver wrote:


On 12/22/2010 07:59 AM, Sim Zacks wrote:

We are using postgresql 8.2.17 on Gentoo

Our postgresql database stopped working with the error
ERROR: could not open relation 1663/26468499/26470404: No such file or
directory

After one minute of these errors on every statement run we had what
looks like a memory failure:
Dec 22 16:37:44 localhost kernel: [279820.425911] postgres invoked
oom-killer: gfp_mask=0x280da, order=0, oom_adj=0
Dec 22 16:37:44 localhost kernel: [279820.425917] postgres cpuset=/
mems_allowed=0
Dec 22 16:37:44 localhost kernel: [279820.425922] Pid: 26209, comm:
postgres Not tainted 2.6.32-gentoo-r7 #12

We cannot connect to the database using psql as it gives the could not
open relation error. We ran fsck and did not find any problems. I
searched through google and found suggestions such as reindex, but we
can't connect to the db. We also can't take a backup of the database as
pg_dump gives the same error.


Does the not connect also apply to starting postgres in single user mode?

Same error with single user mode.
postgres --single -D /var/lib/postgresql/8.2/data clstock
FATAL:  could not open relation 1663/26468499/1259: No such file or 
directory






This is our production database and crashed at the end of the day. If
possible, I would really not like to lose a full days work by restoring
yesterdays backup.

Thanks
Sim







--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] extra TARGETENTRY when group by function( col )?

2010-12-22 Thread Craig Harris
Given:

 

create table t1 ( c1 timestamp without time zone, c2 int );

explain verbose select to_char ( c1, 'whatever' ) from t1
group by to_char ( c1, 'whatever' );

 

does any one know why the SEQSCAN node has TWO TARGETENTRYs?

 

Why do we project c1 as well as to_char( c1 . ) ?

 

---

 

For cases where we compute an aggregate, such as:

 

select min(c1), to_char(c1,.) from t1 group by to_char( c1,.)

 

it would make (some kind of) sense to project out c1.

 

But can't the planner/optimizer distinguish these cases on the basis that
'min' is an aggregate function and 'to_char' is not?

 

The planner seems to be computing a minimal target list of columns (no
expressions) first.  Guess I'm asking why it isn't replaced.



Re: [GENERAL] could not open relation...No such file or directory

2010-12-22 Thread Adrian Klaver

On 12/22/2010 08:37 AM, Sim Zacks wrote:

On 12/22/2010 06:28 PM, Adrian Klaver wrote:


On 12/22/2010 07:59 AM, Sim Zacks wrote:

We are using postgresql 8.2.17 on Gentoo

Our postgresql database stopped working with the error
ERROR: could not open relation 1663/26468499/26470404: No such file or
directory

After one minute of these errors on every statement run we had what
looks like a memory failure:
Dec 22 16:37:44 localhost kernel: [279820.425911] postgres invoked
oom-killer: gfp_mask=0x280da, order=0, oom_adj=0
Dec 22 16:37:44 localhost kernel: [279820.425917] postgres cpuset=/
mems_allowed=0
Dec 22 16:37:44 localhost kernel: [279820.425922] Pid: 26209, comm:
postgres Not tainted 2.6.32-gentoo-r7 #12

We cannot connect to the database using psql as it gives the could not
open relation error. We ran fsck and did not find any problems. I
searched through google and found suggestions such as reindex, but we
can't connect to the db. We also can't take a backup of the database as
pg_dump gives the same error.


Does the not connect also apply to starting postgres in single user mode?

Same error with single user mode.
postgres --single -D /var/lib/postgresql/8.2/data clstock
FATAL: could not open relation 1663/26468499/1259: No such file or
directory


Well it is failing on a different relation. Is the FATAL message 
correct, are the relations shown in fact not on the file system?








This is our production database and crashed at the end of the day. If
possible, I would really not like to lose a full days work by restoring
yesterdays backup.

Thanks
Sim










--
Adrian Klaver
adrian.kla...@gmail.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Error when using phpPgAdmin

2010-12-22 Thread Adam Bruss
Hello and thanks for this great application named pgql.

I've setup pg on a windows machine and have installed phppgadmin. The 
phppgadmin php application comes up correctly in a browser but I get an error 
message when viewing the databases. The apache log shows this:

[Wed Dec 22 10:27:34 2010] [error] [client 127.0.0.1] PHP Fatal error:  Call 
to a member function recordCount() on a non-object in C:\\Program Files 
(x86)\\PostgreSQL\\EnterpriseDB-ApachePhp\\apache\\www\\phpPgAdmin\\classes\\Misc.phpfile:///\\PostgreSQL\EnterpriseDB-ApachePhp\apache\www\phpPgAdmin\classes\Misc.php
 on line 1805, referer: http://localhost:81/phpPgAdmin/browser.php;

And the webpage shows this:

SQL error:
ERROR:  could not stat file base/16396/16397: Permission denied
In statement:
SELECT pdb.datname AS datname, pr.rolname AS datowner, 
pg_encoding_to_char(encoding) AS datencoding,
   (SELECT description FROM pg_catalog.pg_shdescription pd 
WHERE pdb.oid=pd.objoid) AS datcomment,
   (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE 
pt.oid=pdb.dattablespace) AS tablespace,

   CASE WHEN pg_catalog.has_database_privilege(current_user, pdb.oid, 'CONNECT')

THEN 
pg_catalog.pg_database_size(pdb.oid)

ELSE NULL END as dbsize
FROM pg_catalog.pg_database pdb LEFT JOIN pg_catalog.pg_roles 
pr ON (pdb.datdba = pr.oid)
WHERE true
 AND NOT pdb.datistemplate

ORDER BY pdb.datname

I'm running on Windows 7 x64.

On a side note I've been using the pgql command line tool and pgadmin 3 for a 
few days without any problems.

Thanks,
Adam

Adam Bruss
Development Engineer
AWR Corporation/Simulation Technology  Applied Research
11520 N. Port Washington Rd., Suite 201
Mequon, WI  53092  USA
P: 1.262.240.0291 x104
F: 1.262.240.0294
E: abr...@awrcorp.com
W: http://www.awrcorp.com



Re: [GENERAL] extra TARGETENTRY when group by function( col )?

2010-12-22 Thread Tom Lane
Craig Harris har...@summereyes.com writes:
 does any one know why the SEQSCAN node has TWO TARGETENTRYs?

It doesn't stop to notice that the Var is not referenced by any upper
nodes in this particular scenario.

regards, tom lane

-- 
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] could not open relation...No such file or directory

2010-12-22 Thread Tom Lane
Sim Zacks s...@compulab.co.il writes:
 Our postgresql database stopped working with the error
 ERROR: could not open relation 1663/26468499/26470404: No such file or
 directory
 Does the not connect also apply to starting postgres in single user mode?
 Same error with single user mode.
 postgres --single -D /var/lib/postgresql/8.2/data clstock
 FATAL:  could not open relation 1663/26468499/1259: No such file or 
 directory

I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
all?

regards, tom lane

-- 
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] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Merlin Moncure
On Wed, Dec 22, 2010 at 11:38 AM, Kelly Burkhart
kelly.burkh...@gmail.com wrote:
 On Wed, Dec 22, 2010 at 10:19 AM, Merlin Moncure mmonc...@gmail.com wrote:
 have you ruled out sending all the data you need to send into say, a
 plpgsal function and doing the work there?


 Not sure that would do what they need, which is get a list of users,
 get a list of accounts, get perhaps several other lists of other
 things to populate gui elements (mostly small queries).  To do this
 within a stored procedure, the procedure would either have to return
 multiple PGresult objects with different columns (is that possible?)
 or we'd have to shoehorn everything into one result set with some kind
 of indicator on each row to indicate what kind of row it is.  The
 second option is (to me anyway) clearly inferior to just sending a
 list of queries then reaping their PGresults as they come in.

it is completely possible.

create type account_t as row(id int, name text);

create or replace function app_login(
  accounts out account_t[]
  users out user_t[]) returns record as
$$
begin
  select array(select id, name from account into accounts);
...

end;
$$ language plpgsql;

arrays come back over libpq as text, unless you use libpqtypes (which
i co-wrote) :-).

http://libpqtypes.esilo.com/man3/pqt-composites.html

merlin

-- 
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] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

On 12/22/2010 06:45 PM, Adrian Klaver wrote:


On 12/22/2010 08:37 AM, Sim Zacks wrote:

On 12/22/2010 06:28 PM, Adrian Klaver wrote:


On 12/22/2010 07:59 AM, Sim Zacks wrote:

We are using postgresql 8.2.17 on Gentoo

Our postgresql database stopped working with the error
ERROR: could not open relation 1663/26468499/26470404: No such file or
directory

After one minute of these errors on every statement run we had what
looks like a memory failure:
Dec 22 16:37:44 localhost kernel: [279820.425911] postgres invoked
oom-killer: gfp_mask=0x280da, order=0, oom_adj=0
Dec 22 16:37:44 localhost kernel: [279820.425917] postgres cpuset=/
mems_allowed=0
Dec 22 16:37:44 localhost kernel: [279820.425922] Pid: 26209, comm:
postgres Not tainted 2.6.32-gentoo-r7 #12

We cannot connect to the database using psql as it gives the could not
open relation error. We ran fsck and did not find any problems. I
searched through google and found suggestions such as reindex, but we
can't connect to the db. We also can't take a backup of the
database as
pg_dump gives the same error.


Does the not connect also apply to starting postgres in single user
mode?

Same error with single user mode.
postgres --single -D /var/lib/postgresql/8.2/data clstock
FATAL: could not open relation 1663/26468499/1259: No such file or
directory


Well it is failing on a different relation. Is the FATAL message
correct, are the relations shown in fact not on the file system?
Throughout the log, I noticed a bunch of different relations that are 
missing.

It seems to me that they are not in the file system.
data/base/26468499 exists with a large number of files, but the ones it 
mentions are not there.








This is our production database and crashed at the end of the day. If
possible, I would really not like to lose a full days work by
restoring
yesterdays backup.

Thanks
Sim













--
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] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

On 12/22/2010 07:03 PM, Tom Lane wrote:


Sim Zackss...@compulab.co.il  writes:

Our postgresql database stopped working with the error
ERROR: could not open relation 1663/26468499/26470404: No such file or
directory

Does the not connect also apply to starting postgres in single user mode?

Same error with single user mode.
postgres --single -D /var/lib/postgresql/8.2/data clstock
FATAL:  could not open relation 1663/26468499/1259: No such file or
directory

I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
all?

regards, tom lane
/var/lib/postgresql/8.2/data/base/26468499 does exist, and there are 
1212 files in it, but so far all the relationships that I have seen in 
the error logs are not in the directory.


--
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] could not open relation...No such file or directory

2010-12-22 Thread Adrian Klaver

On 12/22/2010 09:03 AM, Tom Lane wrote:

Sim Zackss...@compulab.co.il  writes:

Our postgresql database stopped working with the error
ERROR: could not open relation 1663/26468499/26470404: No such file or
directory

Does the not connect also apply to starting postgres in single user mode?

Same error with single user mode.
postgres --single -D /var/lib/postgresql/8.2/data clstock
FATAL:  could not open relation 1663/26468499/1259: No such file or
directory


I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
all?

regards, tom lane



Alright I am going to show my ignorance here, but why would it not be?
$PGDATA/base/1663/26468499

--
Adrian Klaver
adrian.kla...@gmail.com

--
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] could not open relation...No such file or directory

2010-12-22 Thread Tom Lane
Sim Zacks s...@compulab.co.il writes:
 FATAL:  could not open relation 1663/26468499/1259: No such file or
 directory

 I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
 all?

 /var/lib/postgresql/8.2/data/base/26468499 does exist, and there are 
 1212 files in it, but so far all the relationships that I have seen in 
 the error logs are not in the directory.

Well, 1259 is pg_class, so if you've lost that then this database is
toast.  I think your filesystem must've had a hiccup.

regards, tom lane

-- 
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] Table inheritance foreign key problem

2010-12-22 Thread David Fetter
On Wed, Dec 22, 2010 at 12:32:44AM -0500, Andy Chambers wrote:
 Hi,
 
 One of the caveats described in the documentation for table
 inheritance is that foreign key constraints cannot cover the case
 where you want to check that a value is found somewhere in a table
 or in that table's descendants.  It says there is no good
 workaround for this.

For some values of, good, there actually is.

http://people.planetpostgresql.org/dfetter/index.php?/archives/51-Partitioning-Is-Such-Sweet-Sorrow.html
http://people.planetpostgresql.org/dfetter/index.php?/archives/59-Partitioning-Glances.html

Cheers,
David (hoping PostgreSQL will be able to infer how to automate this some day).
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

-- 
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] Cannot unsubscribe

2010-12-22 Thread Greg Sabino Mullane

-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160


William Gordon Rutherdale (rutherw) ruth...@cisco.com wrote:

 Clearly something is broken in the system, as it's contradicting itself
 by sending me emails but failing to recognise that same email address
 when I attempt to unsubscribe.

I confirmed that ruth...@cisco.com is NOT subscribed to pgsql-general. 
Which means you were able to unsubscribe after all, or are subscribed 
with a separate address, perhaps with a forward to the cisco.com 
address. The headers from your pgsql-general email should help you 
figure out what's going on. Feel free to forward me those headers 
(offlist) and I'll try to get you unsubscribed.

- -- 
Greg Sabino Mullane g...@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201012221216
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-BEGIN PGP SIGNATURE-

iEYEAREDAAYFAk0SMn0ACgkQvJuQZxSWSsjahACgr4SOZIaBU0mQ5mULBhFoWRRy
VC0AoNMl7V+fU1KqHff7LqRC8ZztpdFh
=/xCc
-END PGP SIGNATURE-



-- 
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] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

On 12/22/2010 07:20 PM, Tom Lane wrote:

Sim Zackss...@compulab.co.il  writes:

FATAL:  could not open relation 1663/26468499/1259: No such file or
directory

I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
all?

/var/lib/postgresql/8.2/data/base/26468499 does exist, and there are
1212 files in it, but so far all the relationships that I have seen in
the error logs are not in the directory.

Well, 1259 is pg_class, so if you've lost that then this database is
toast.  I think your filesystem must've had a hiccup.

regards, tom lane


Is there any way I can see the pg_class table so that I know which 
relations are missing, if I have a list of all the relations that are 
not there?

Or better, is there a way I can dump what is there?

--
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] could not open relation...No such file or directory

2010-12-22 Thread Sim Zacks

On 12/22/2010 07:20 PM, Tom Lane wrote:


Sim Zackss...@compulab.co.il  writes:

FATAL:  could not open relation 1663/26468499/1259: No such file or
directory

I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
all?

/var/lib/postgresql/8.2/data/base/26468499 does exist, and there are
1212 files in it, but so far all the relationships that I have seen in
the error logs are not in the directory.

Well, 1259 is pg_class, so if you've lost that then this database is
toast.  I think your filesystem must've had a hiccup.

regards, tom lane
In my log file there are 13 files that can't be open and 3 of those 
actually exist, the rest do not.



--
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] could not open relation...No such file or directory

2010-12-22 Thread Tom Lane
Adrian Klaver adrian.kla...@gmail.com writes:
 On 12/22/2010 09:03 AM, Tom Lane wrote:
 I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
 all?

 Alright I am going to show my ignorance here, but why would it not be?
 $PGDATA/base/1663/26468499

1663 is the pg_default tablespace, which refers to $PGDATA/base
(hardwired knowledge in the file-path-construction code).  See
http://developer.postgresql.org/pgdocs/postgres/storage-file-layout.html

regards, tom lane

-- 
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] How to use pgbouncer

2010-12-22 Thread Andreas Kretschmer
Filip Rembiałkowski filip.rembialkow...@gmail.com wrote:

 2010/12/21 Andreas Kretschmer akretsch...@spamfence.net:
 
  I'm looking for a solution to split read and write access to different
  servers (streaming replication, you know ...). Can i do that with
  pgpool? (setting backend_weightX=0 or 1)? I have read the doc, but i'm
  not sure if pgpool the right solution, maybe you can enlighten me?
  (or someone else ...)
 
 did you see 
 http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#master_slave_mode
 ? I think it answers your question :-)

Now, yes ;-)

Thx.



 
 warning:
 it works by detecting which queries are read-only, which does not
 always work out of the box.
 you will sometimes have to modify driver settings or worse, modify SQL
 queries including hints for pgpool.
 
 see:
 http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#restriction
 http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#white_function_list
 http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#black_function_list

Thank you.



Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.  (Linus Torvalds)
If I was god, I would recompile penguin with --enable-fly.   (unknown)
Kaufbach, Saxony, Germany, Europe.  N 51.05082°, E 13.56889°

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Root user commands

2010-12-22 Thread Bob Pawley
Hi

I am attempting to see if my Postgresql installation is running.

I’ve found this -
[root user only] ./database_service.pl status

I don’t understand what is meant by root user.

I also don’t know how “./database_service.pl status” is used.

Bob



Re: [GENERAL] could not accept SSPI security context

2010-12-22 Thread Brar Piening

 Original Message  
Subject: Re: [GENERAL] could not accept SSPI security context
From: Reto Schöning reto.schoen...@gmail.com
To: Brar Piening b...@gmx.de
Date: 22.12.2010 17:08

The security database on the server does not have a computer account 
for this workstation trust relationship

[...]
Is there anything else in the code that I could check or try?



Did you make sure that all connection parameters are the same between 
libpq clients (psql, PgAdmin, ...) and Npgsql?


Also on my computer PgAdmin fails to connect if I try to connect to 
localhost instead of 127.0.0.1 via SSPI while connecting (some test 
app) via Npgsql will work (by internally using the ip addresses in 
Socket.RemoteEndPoint.Address instead of the host name).
This could lead to the fact that a Npgsql program uses a different 
Kerberos service principal than you might think as it uses the first 
working ip address from Dns.GetHostAddresses as hostname part.
What bothers me about this is that if 
http://www.postgresql.org/docs/current/static/auth-methods.html#KERBEROS-AUTH 
is correct by stating that The name of the service principal is 
/servicename///hostname/@/realm/.  and /hostname/ is the fully 
qualified host name of the server machine. connecting via host name 
should work in principle while it doesn't on my machine (actually using 
NTLM).


One other thing that comes to mind is the fact that Npgsql is currently 
hardcoded to use POSTGRES as Kerberos service name while in libpq this 
can be changed as a compile time option, a server configuration 
parameter and a connection parameter setting.
Still this is an unlikely cause if you didn't fiddle around with this in 
psql as the PostgreSQL docs state:  In most environments, this 
parameter never needs to be changed. However, it is necessary when 
supporting multiple PostgreSQL installations on the same host. Some 
Kerberos implementations might also require a different service name, 
such as Microsoft Active Directory which requires the service name to be 
in upper case (POSTGRES). 


Sorry for those pretty random amateurish guesses but I've got zero 
Kerberos experience and not even a kerberos setup to test with.


Best Regards,

Brar


Re: [GENERAL] could not open relation...No such file or directory

2010-12-22 Thread Adrian Klaver

On 12/22/2010 10:41 AM, Tom Lane wrote:

Adrian Klaveradrian.kla...@gmail.com  writes:

On 12/22/2010 09:03 AM, Tom Lane wrote:

I begin to wonder if the subdirectory $PGDATA/base/26468499 is there at
all?



Alright I am going to show my ignorance here, but why would it not be?
$PGDATA/base/1663/26468499


1663 is the pg_default tablespace, which refers to $PGDATA/base
(hardwired knowledge in the file-path-construction code).  See
http://developer.postgresql.org/pgdocs/postgres/storage-file-layout.html

regards, tom lane


Slap forehead Remember tablespaces. Thanks.

--
Adrian Klaver
adrian.kla...@gmail.com

--
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] Root user commands

2010-12-22 Thread Leif Biberg Kristensen
On Wednesday 22. December 2010 20.03.23 Bob Pawley wrote:
 Hi
 
 I am attempting to see if my Postgresql installation is running.
 
 I’ve found this -
 [root user only] ./database_service.pl status
 
 I don’t understand what is meant by root user.
 
 I also don’t know how “./database_service.pl status” is used.
 
 Bob

You don't tell where you found this information.

If you don't know what a root user is, you're probably on Windows. On 
*nix systems, root is the privileged user who can do all the things a 
normal user isn't allowed to do, like modifying system files.

The 'database_service.pl' is a Perl script. Perl is a fairly default 
installation on *nix systems, there also exist builds for Windows. I 
used the Komodo flavor way back when.

regards,
Leif

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] copy from problem

2010-12-22 Thread Mark Watson
Hello all,
(Postgres 8.4.6 Windows)
I am stumped as to why I cannot import this using copy from within pgadmin
(the following table is created in an existing database with an encoding of
WIN1252 and the Postgres server_encoding is UTF8) :
CREATE TABLE test
(
  col_descr text
)
WITH (
  OIDS=FALSE
);
ALTER TABLE test OWNER TO postgres;
set client_encoding = 'WIN1252';
COPY test FROM 'C:\\pgtemp\\test.txt' with  delimiter as '|' csv;
select * from test;
--- col_descr
-- 
-- (empty row)

The file test.txt contains 1 line of 2 characters: éÉ  (acute accented
lowercase and uppercase e, hex(E9C9), valid win1252 characters.

Any help would be appreciated.
Mark


-- 
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] copy from problem

2010-12-22 Thread Adrian Klaver
On Wednesday 22 December 2010 12:34:58 pm Mark Watson wrote:
 Hello all,
 (Postgres 8.4.6 Windows)
 I am stumped as to why I cannot import this using copy from within pgadmin
 (the following table is created in an existing database with an encoding of
 WIN1252 and the Postgres server_encoding is UTF8) :
 CREATE TABLE test
 (
   col_descr text
 )
 WITH (
   OIDS=FALSE
 );
 ALTER TABLE test OWNER TO postgres;
 set client_encoding = 'WIN1252';
 COPY test FROM 'C:\\pgtemp\\test.txt' with  delimiter as '|' csv;
 select * from test;
 --- col_descr
 -- 
 -- (empty row)

 The file test.txt contains 1 line of 2 characters: éÉ  (acute accented
 lowercase and uppercase e, hex(E9C9), valid win1252 characters.

 Any help would be appreciated.
 Mark

Is there anything in the database logs? Are the two characters separated by 
'|'? 

-- 
Adrian Klaver
adrian.kla...@gmail.com

-- 
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] copy from problem

2010-12-22 Thread Guillaume Lelarge
Le 22/12/2010 21:34, Mark Watson a écrit :
 Hello all,
 (Postgres 8.4.6 Windows)
 I am stumped as to why I cannot import this using copy from within pgadmin
 (the following table is created in an existing database with an encoding of
 WIN1252 and the Postgres server_encoding is UTF8) :
 CREATE TABLE test
 (
   col_descr text
 )
 WITH (
   OIDS=FALSE
 );
 ALTER TABLE test OWNER TO postgres;
 set client_encoding = 'WIN1252';
 COPY test FROM 'C:\\pgtemp\\test.txt' with  delimiter as '|' csv;
 select * from test;
 --- col_descr
 -- 
 -- (empty row)
 
 The file test.txt contains 1 line of 2 characters: éÉ  (acute accented
 lowercase and uppercase e, hex(E9C9), valid win1252 characters.
 
 Any help would be appreciated.

It would be so much easier if you told us your error message.


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general