[GENERAL] Looking for a good ERD Tool

2005-07-06 Thread Rob Brenart
I'm looking for a good ERD tool that's designed to work with 
PostgreSQL... currently I use the one found here 
http://www.fabforce.net/dbdesigner4/index.php for MySQL, and I just 
create the actual tables and such by hand... kinda of a kludge, and I 
lose all the reverse engineering benefits... but cest'le'vie.


Anyway, would like to find a similar tool specifically designed for 
PostgreSQL... does one exist or is it a futile search?


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Seg fault in postgres 7.4.7?

2005-07-06 Thread Michael Fuhr
On Wed, Jul 06, 2005 at 06:55:09PM -0700, Akash Garg wrote:
> This is Suse Enterprise 9.0 running on a quad Opteron Newisys machine.
>  It has 32 gb of RAM.  We didn't do anything to fancy with the setup
> of the OS or postgres.
> 
> No core dump is available.

Where did you look for a core dump?  Do you have a resource limit
or other setting that prevents them?

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [GENERAL] About unsigned smallint?

2005-07-06 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> On Wed, Jul 06, 2005 at 11:30:52PM +0200, Dawid Kuroczko wrote:
>> If you ask here, you'll probably get a good explanation why there
>> aren't unsinged types.

> Yeah, they are against the SQL standard apparently;

Not so much "against it" as "not in it" ... which means that if you want
such a feature, you need to actively convince people of its merits.

> and we've got enough
> problems with cross-datatype coercion that there's not much interest in
> making it worse by adding more types.

That was the main reason for rejecting such proposals a few releases ago.
It's possible that our subsequent cleanups in the coercion mechanisms
would make this a feasible idea now.  But I haven't investigated
closely, and I don't believe anyone else has either.

The short answer is definitely that it would take more work than anyone
has so far cared to commit.

regards, tom lane

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] ERROR: cache lookup failed for relation 438095645

2005-07-06 Thread Tom Lane
Joe Markwardt <[EMAIL PROTECTED]> writes:
> On Wed, 2005-07-06 at 14:04 -0400, Tom Lane wrote:
>> They appear to be triggers for a foreign-key constraint between 
>> pl_inventory_analyzer_files_table and pl02_status_table ... so I guess
>> the question is what happened to the latter?

> I'm not sure. As far as I can tell nothing has happened to the
> pl02_status_table, nor should anything have happened to it recently.

Well, that's just plain bizarre...

The next thing to check is whether the OID mentioned in pg_trigger
(which I forgot already) is the same as the OID shown in pg_class, ie
select oid from pg_class where relname = 'pl02_status_table'.  I can
think of a few different possible pathologies here, but there's no point
speculating in advance of the data.

regards, tom lane

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [GENERAL] Adding miscadmin.h generates errors ?

2005-07-06 Thread Michael Fuhr
On Wed, Jul 06, 2005 at 02:51:53PM -0700, Otto Blomqvist wrote:
> After adding miscadmin.h to my source I get "some" errors, shown below. I'm
> sure its something simple like adding a flag or similar, but I'v spent hours
> on this now. Im running Fedora 3 and Postgres 8.0.3. GCC 3.4.3 20050227.

If you're writing server-side code then you should be including
postgres.h before any other headers.  See "Writing Code" in the
"C-Language Functions" section of the "Extending SQL" chapter of
the documentation for details.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] Adding miscadmin.h generates errors ?

2005-07-06 Thread Alvaro Herrera
On Wed, Jul 06, 2005 at 02:51:53PM -0700, Otto Blomqvist wrote:
> After adding miscadmin.h to my source I get "some" errors, shown below. I'm
> sure its something simple like adding a flag or similar, but I'v spent hours
> on this now. Im running Fedora 3 and Postgres 8.0.3. GCC 3.4.3 20050227.

Do you include c.h before miscadmin.h?  It seems to be required.
(The first error seems to be related to DLL_IMPORT).

-- 
Alvaro Herrera ()
"You knock on that door or the sun will be shining on places inside you
that the sun doesn't usually shine" (en Death: "The High Cost of Living")

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread felix
On Wed, Jul 06, 2005 at 05:44:44PM -0400, Bruce Momjian wrote:
> [EMAIL PROTECTED] wrote:
> > 
> > Could a corrupt db cause these mood swings?  And if so, would that
> > persist even across dropdb / creatdb?
> 
> Yes, that is possible, but usually it would fail consistently.  Have you
> run memtest and disk diagnostics?

I moved the disks to a new machine, same problem, which doesn't rule
out disk problems.  We were getting a second machine ready for testing
this problem, but my boss has decided to upgrade to 8.0.3 tonight for
himself, and probably very soon after for the rest of us, and the
problem is in the work mood right now, so we will no doubt follow the
general principle of changing many things at once to make tracking
things down more fun :-)

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman & rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] About unsigned smallint?

2005-07-06 Thread Alvaro Herrera
On Wed, Jul 06, 2005 at 11:30:52PM +0200, Dawid Kuroczko wrote:

> If you ask here, you'll probably get a good explanation why there
> aren't unsinged types.  My guess is that unsigned types add
> complexity which is not really judged by their usefullness, but
> thats only a guess.

Yeah, they are against the SQL standard apparently; and we've got enough
problems with cross-datatype coercion that there's not much interest in
making it worse by adding more types.

-- 
Alvaro Herrera ()
"Some men are heterosexual, and some are bisexual, and some
men don't think about sex at all... they become lawyers" (Woody Allen)

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[GENERAL] Adding miscadmin.h generates errors ?

2005-07-06 Thread Otto Blomqvist
After adding miscadmin.h to my source I get "some" errors, shown below. I'm
sure its something simple like adding a flag or similar, but I'v spent hours
on this now. Im running Fedora 3 and Postgres 8.0.3. GCC 3.4.3 20050227.

Any ideas ?

Thanks
/Otto Blomqvist

gcc -Wall -c commfunct.c
In file included from commfunct.c:62:
miscadmin.h:67: error: syntax error before "volatile"
miscadmin.h:67: warning: type defaults to `int' in declaration of
`InterruptPending'
miscadmin.h:67: warning: data definition has no type or storage class
miscadmin.h:68: error: syntax error before "QueryCancelPending"
miscadmin.h:68: warning: type defaults to `int' in declaration of
`QueryCancelPending'
miscadmin.h:68: warning: data definition has no type or storage class
miscadmin.h:69: error: syntax error before "ProcDiePending"
miscadmin.h:69: warning: type defaults to `int' in declaration of
`ProcDiePending'
miscadmin.h:69: warning: data definition has no type or storage class
miscadmin.h:72: error: syntax error before "ImmediateInterruptOK"
miscadmin.h:72: warning: type defaults to `int' in declaration of
`ImmediateInterruptOK'
miscadmin.h:72: warning: data definition has no type or storage class
miscadmin.h:73: error: syntax error before "InterruptHoldoffCount"
miscadmin.h:73: warning: type defaults to `int' in declaration of
`InterruptHoldoffCount'
miscadmin.h:73: warning: data definition has no type or storage class
miscadmin.h:74: error: syntax error before "CritSectionCount"
miscadmin.h:74: warning: type defaults to `int' in declaration of
`CritSectionCount'
miscadmin.h:74: warning: data definition has no type or storage class
miscadmin.h:124: error: syntax error before "IsPostmasterEnvironment"
miscadmin.h:124: warning: type defaults to `int' in declaration of
`IsPostmasterEnvironment'
miscadmin.h:124: warning: data definition has no type or storage class
miscadmin.h:125: error: syntax error before "IsUnderPostmaster"
miscadmin.h:125: warning: type defaults to `int' in declaration of
`IsUnderPostmaster'
miscadmin.h:125: warning: data definition has no type or storage class
miscadmin.h:127: error: syntax error before "ExitOnAnyError"
miscadmin.h:127: warning: type defaults to `int' in declaration of
`ExitOnAnyError'
miscadmin.h:127: warning: data definition has no type or storage class
miscadmin.h:131: error: syntax error before "int"
miscadmin.h:134: error: syntax error before "int"
miscadmin.h:139: error: syntax error before "char"
miscadmin.h:151: error: syntax error before "Oid"
miscadmin.h:151: warning: type defaults to `int' in declaration of
`MyDatabaseId'
miscadmin.h:151: warning: data definition has no type or storage class
miscadmin.h:153: error: syntax error before "Oid"
miscadmin.h:153: warning: type defaults to `int' in declaration of
`MyDatabaseTableSpace'
miscadmin.h:153: warning: data definition has no type or storage class
miscadmin.h:197: error: syntax error before "HasCTZSet"
miscadmin.h:197: warning: type defaults to `int' in declaration of
`HasCTZSet'
miscadmin.h:197: warning: data definition has no type or storage class
miscadmin.h:202: error: syntax error before "enableFsync"
miscadmin.h:202: warning: type defaults to `int' in declaration of
`enableFsync'
miscadmin.h:202: warning: data definition has no type or storage class
miscadmin.h:203: error: syntax error before "allowSystemTableMods"
miscadmin.h:203: warning: type defaults to `int' in declaration of
`allowSystemTableMods'
miscadmin.h:203: warning: data definition has no type or storage class
miscadmin.h:204: error: syntax error before "int"
miscadmin.h:205: error: syntax error before "int"
miscadmin.h:214: error: syntax error before "VacuumCostActive"
miscadmin.h:214: warning: type defaults to `int' in declaration of
`VacuumCostActive'
miscadmin.h:214: warning: data definition has no type or storage class
miscadmin.h:229: error: syntax error before "Oid"
miscadmin.h:234: error: syntax error before "userid"
miscadmin.h:235: error: syntax error before "GetUserId"
miscadmin.h:235: warning: type defaults to `int' in declaration of
`GetUserId'
miscadmin.h:235: warning: data definition has no type or storage class
miscadmin.h:236: error: syntax error before "userid"
miscadmin.h:237: error: syntax error before "GetSessionUserId"
miscadmin.h:237: warning: type defaults to `int' in declaration of
`GetSessionUserId'
miscadmin.h:237: warning: data definition has no type or storage class
miscadmin.h:238: error: syntax error before "userid"
miscadmin.h:241: error: syntax error before "userid"
miscadmin.h:247: error: syntax error before "superuser"
miscadmin.h:247: warning: type defaults to `int' in declaration of
`superuser'
miscadmin.h:247: warning: data definition has no type or storage class
miscadmin.h:248: error: syntax error before "superuser_arg"
miscadmin.h:248: error: syntax error before "userid"
miscadmin.h:248: warning: type defaults to `int' in declaration of
`superuser_arg'
miscadmin.h:248: warning: data definition has no type or storage clas

Re: [GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread Bruce Momjian
[EMAIL PROTECTED] wrote:
> > Bruce Momjian  writes:
> > > This message is from the backend exiting abruptly.  Is isn't an "ERROR"
> > > as we define it for logging purposes.  That's why there is nothing in
> > > the logs.
> > 
> > Nonetheless I'd expect there to be at least a postmaster complaint about
> > a crashed backend --- assuming that that's what's going on.  Do the
> > other active connections get forcibly closed when this happens?
> 
> Haven't had any others open, it's a dev system.  But I'll try leaving
> a psql session open.  Right now it's gotten itself into the mood of
> always working, so it might have to wait a while.
> 
> Could a corrupt db cause these mood swings?  And if so, would that
> persist even across dropdb / creatdb?

Yes, that is possible, but usually it would fail consistently.  Have you
run memtest and disk diagnostics?

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] About unsigned smallint?

2005-07-06 Thread Dawid Kuroczko
On 7/6/05, Ying Lu <[EMAIL PROTECTED]> wrote:
> Greetings,
> 
> Can I know whether postgreSQL 8.0 supports unsigned smallint please? I
> looked at the doc, it seems that OID is unsigned interger. While I was
> trying to create a simple table as:
>   create table test (id unsigned smallint);
>  or
>   create table test (id smallint unsigned);
> 
> It seems that postgreSQL did not support unsigned integer?

Well, PostgreSQL doesn't have "unsigned" types, unless you create
your own.  If you want to have unsigned type, you can add a check
constraint or, even better, create a domain:

CREATE DOMAIN usmallint AS smallint CHECK (VALUE >= 0);

...while this gives you unsinged smallint type, its probably not
what you wanted.  If you wanted a type which takes two bytes of
storage and stores values from 0 to 65535 then, well... its not it.

If you ask here, you'll probably get a good explanation why there
aren't unsinged types.  My guess is that unsigned types add
complexity which is not really judged by their usefullness, but
thats only a guess.

If you need unsigned-like type for data consistency reasons, just
CREATE DOMAIN as shown above.

  Regards,
  Dawid

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] can't drop sequence even though table is gone

2005-07-06 Thread Scott Marlowe
On Wed, 2005-07-06 at 15:54, Kevin Murphy wrote:
> I'm using PG 8.0.3 on Mac OS X 10.4.1.
> 
> I've dropped some tables that had associated sequences, but I am unable 
> to drop the sequences.  I haven't noticed any errors or crashes.  It 
> will be easy to rebuild the whole database.  I'm just reporting this 
> because it seemed unusual.
> 
> => \ds
> List of relations
>  Schema | Name |   Type   | Owner
> +--+--+---
> public | seq_SML_sources_id   | sequence | fable
> public | seq_SML_symbols_id   | sequence | fable
> public | seq_TaggedEntities_id| sequence | fable
> 
> 
> => drop sequence seq_SML_sources_id;
> ERROR:  sequence "seq_sml_sources_id" does not exist


Notice the error message says seq_sml_sources_id doesn't exist.  And it
doesn't.  The sequence is named seq_SML_sources_id.  You need to quote
it to delete it, since postgresql folds case (to lower case) with
unquoted identifiers.

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] ms-sql OUTPUT equivalent

2005-07-06 Thread Douglas McNaught
Clark Allan <[EMAIL PROTECTED]> writes:

> Is there an equivelent to the OUTPUT parameter in MS-SQL?

Not in the current release, but the upcoming 8.1 release will have it.

-Doug

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] can't drop sequence even though table is gone

2005-07-06 Thread Douglas McNaught
Kevin Murphy <[EMAIL PROTECTED]> writes:

>  Schema | Name |   Type   | Owner
> +--+--+---
> public | seq_SML_sources_id   | sequence | fable
> public | seq_SML_symbols_id   | sequence | fable
> public | seq_TaggedEntities_id| sequence | fable
>
>
> => drop sequence seq_SML_sources_id;
> ERROR:  sequence "seq_sml_sources_id" does not exist

Your sequence name is mixed case, so you need to double quote it to
avoid case folding:

drop sequence "seq_SML_sources_id";

-Doug

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] can't drop sequence even though table is gone

2005-07-06 Thread Kevin Murphy

I'm using PG 8.0.3 on Mac OS X 10.4.1.

I've dropped some tables that had associated sequences, but I am unable 
to drop the sequences.  I haven't noticed any errors or crashes.  It 
will be easy to rebuild the whole database.  I'm just reporting this 
because it seemed unusual.


=> \ds
   List of relations
Schema | Name |   Type   | Owner
+--+--+---
public | seq_SML_sources_id   | sequence | fable
public | seq_SML_symbols_id   | sequence | fable
public | seq_TaggedEntities_id| sequence | fable


=> drop sequence seq_SML_sources_id;
ERROR:  sequence "seq_sml_sources_id" does not exist


=> select * from pg_class where relname = 'seq_SML_sources_id';
 relname   | relnamespace | reltype  | relowner | relam | 
relfilenode | reltablespace | relpages | reltuples | reltoastrelid | 
reltoastidxid | relhasindex | relisshared | relkind | relnatts | 
relchecks | reltriggers | relukeys | relfkeys | relrefs | relhasoids | 
relhaspkey | relhasrules | relhassubclass | relacl

+--+--+--+---+-+---+--+---+---+---+-+-+-+--+---+-+--+--+-+++-++
seq_SML_sources_id | 2200 | 12237018 |  100 | 0 |
12237017 | 0 |1 | 1 | 0 
| 0 | f   | f   | S   |9 
| 0 |   0 |0 |0 |   0 | f  | 
f  | f   | f  |



Thanks,
Kevin Murphy


---(end of broadcast)---
TIP 6: Have you searched our list archives?

  http://archives.postgresql.org


[GENERAL] About unsigned smallint?

2005-07-06 Thread Ying Lu

Greetings,

Can I know whether postgreSQL 8.0 supports unsigned smallint please? I 
looked at the doc, it seems that OID is unsigned interger. While I was 
trying to create a simple table as:

 create table test (id unsigned smallint);
or 
 create table test (id smallint unsigned);


It seems that postgreSQL did not support unsigned integer?

Thanks a lot,
Emi

---(end of broadcast)---
TIP 6: Have you searched our list archives?

  http://archives.postgresql.org


[GENERAL] ms-sql OUTPUT equivalent

2005-07-06 Thread Clark Allan
Is there an equivelent to the OUTPUT parameter in MS-SQL?
here is an example:

CREATE PROCEDURE GetPagedList( @CurrentPage   tinyint, @PageSize   tinyint, @TotalRecords   int OUTPUT,)ASSet NoCount On-- ...some code here...-- Return the total number of records available as an output parameter
Select @TotalRecords = Count(*) From tblemp

GO---I am using the Npgsql data provider in a .net app, and have noticed you can set the Parameter direction to be outputeg "NpgsqlParameter.Direction
 = ParameterDirection.Output"Is this just a case of npgsql getting ahead of pg?
ThanksClark


Re: [GENERAL] current_user inside SECURITY DEFINER function?

2005-07-06 Thread Stephen Frost
* Peter Eisentraut ([EMAIL PROTECTED]) wrote:
> Stephen Frost wrote:
> > * Richard Hayward ([EMAIL PROTECTED]) wrote:
> > > Is there any way of getting the user?
> >
> > You might try session_user.  8.1 will hopefully clean this up some.
> 
> Why would it?  This is SQL standard behavior that should not be changed.

It'll match the SQL spec, I'm not sure it does now, that was more of my
point than anything else. :)

Stephen


signature.asc
Description: Digital signature


Re: [GENERAL] ERROR: cache lookup failed for relation 438095645

2005-07-06 Thread Joe Markwardt
On Wed, 2005-07-06 at 14:04 -0400, Tom Lane wrote:
> Joe Markwardt <[EMAIL PROTECTED]> writes:
> >>> I am getting this error "ERROR:  cache lookup failed for relation
> >>> 438095645" when i try to run "drop table
> >>> pl_inventory_analyzer_files_table ;" from psql on the database server.
> >> 
> >> Look through the system catalogs to see where that OID appears.
> 
> > I found the attached entries in the pg_trigger table, but I'm not quite
> > sure how to read them, or what to do about them.
> 
> They appear to be triggers for a foreign-key constraint between 
> pl_inventory_analyzer_files_table and pl02_status_table ... so I guess
> the question is what happened to the latter?
> 

I'm not sure. As far as I can tell nothing has happened to the
pl02_status_table, nor should anything have happened to it recently.
Its just a lookup table relating status ID's to descriptive names, and
it only has about 8 records in it, and the last change was several
months ago.  I've attached the \d output of both tables, and everything
appears kosher to me.  Is there something in particular I should look
for?  

Thanks
Joe

>   regards, tom lane
> 
> ---(end of broadcast)---
> TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to [EMAIL PROTECTED] so that your
>message can get through to the mailing list cleanly
> 
pl=# \d pl_inventory_analyzer_files_table
  Table "public.pl_inventory_analyzer_files_table"
Column |Type |  
   Modifiers
---+-+---
 file_id   | integer | not null default 
nextval('public.pl_inventory_evaluator_files_file_id_seq'::text)
 name  | character varying(150)  | not null
 status_id | integer |
 date_uploaded | timestamp without time zone | default now()
 zip   | boolean | not null default true
 search_types  | character varying(20)   | not null
 delimited_by  | character varying(10)   | not null default 
'TAB'::character varying
 uid   | integer |
 stored_name   | character varying(150)  | not null
   
Indexes:
"pl_inventory_evaluator_files_pkey" primary key, btree (file_id)

Foreign-key constraints:
"$1" FOREIGN KEY (status_id) REFERENCES pl02_status_table(status_id)
"$2" FOREIGN KEY (uid) REFERENCES pl02_user_login_table(uid)

pl=# \d pl02_status_table
   Table "public.pl02_status_table"
   Column|  Type  |Modifiers
-++-
 status_id   | integer| not null default 
nextval('status_id_seq'::text)
 description | character varying(256) |

Indexes:
"status_id_pkey" unique, btree (status_id)

Triggers:
"_T1_denyaccess_51" BEFORE INSERT OR DELETE OR UPDATE ON 
pl02_status_table FOR EACH ROW EXECUTE PROCEDURE "_T1".denyaccess('_T1')

pl=#
 

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] current_user inside SECURITY DEFINER function?

2005-07-06 Thread Peter Eisentraut
Stephen Frost wrote:
> * Richard Hayward ([EMAIL PROTECTED]) wrote:
> > Is there any way of getting the user?
>
> You might try session_user.  8.1 will hopefully clean this up some.

Why would it?  This is SQL standard behavior that should not be changed.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread felix
On Wed, Jul 06, 2005 at 03:10:40PM -0400, Tom Lane wrote:
> > [EMAIL PROTECTED] wrote:
> >> This is a SOAP server, Apache with mod_perl, connecting to Postgres
> >> via DBI/DBD::Pg.  Sometimes it gets in a mood, for want of a better
> >> term, where a specific SQL statement fails with the good ole message
> >> "server closed the connection unexpectedly".  It will fail like this
> 
> The specific statement being what exactly?

select it.id, it.it_class_id, it.it_code_version_id,
it.it_data_version, it.note, it_class.class, it_class.id,
it_code_version.version, it_code_version.id, it_class.id,
it_code_version.id from it join it_class on (it_class.id =
it.it_class_id) join it_code_version on (it_code_version.id =
it.it_code_version_id) where class = ? AND version = ? AND
it_data_version > ?

> Bruce Momjian  writes:
> > This message is from the backend exiting abruptly.  Is isn't an "ERROR"
> > as we define it for logging purposes.  That's why there is nothing in
> > the logs.
> 
> Nonetheless I'd expect there to be at least a postmaster complaint about
> a crashed backend --- assuming that that's what's going on.  Do the
> other active connections get forcibly closed when this happens?

Haven't had any others open, it's a dev system.  But I'll try leaving
a psql session open.  Right now it's gotten itself into the mood of
always working, so it might have to wait a while.

Could a corrupt db cause these mood swings?  And if so, would that
persist even across dropdb / creatdb?

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman & rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread felix
On Wed, Jul 06, 2005 at 02:32:31PM -0400, Bruce Momjian wrote:
> 
> This message is from the backend exiting abruptly.  Is isn't an "ERROR"
> as we define it for logging purposes.  That's why there is nothing in
> the logs.  I recommend turning on log_statement which prints before the
> query is run.

I hadn't thought of the error that way.  I do have query logging on,
and if I run that query directly, it finds the data I'd expect.  It's
a small table, or really three of them, all small for the time being.

select it.id, it.it_class_id, it.it_code_version_id,
it.it_data_version, it.note, it_class.class, it_class.id,
it_code_version.version, it_code_version.id, it_class.id,
it_code_version.id from it join it_class on (it_class.id =
it.it_class_id) join it_code_version on (it_code_version.id =
it.it_code_version_id) where class = ? AND version = ? AND
it_data_version > ?

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman & rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] Scripting Functions to Separate Files

2005-07-06 Thread Tino Wildenhain
Am Mittwoch, den 06.07.2005, 11:35 -0700 schrieb Mike Fahrenkrog:
> Hi, 
> Does anyone know an efficient way to script database objects
> (preferably all objects, but particularly functions) to separate
> files? I would like to have a separate file for each object, so that I
> can easily add them to source control.
> 
Yes, you simply use a text editor and write the files.
You use psql yourdb http://www.postgresql.org/docs/faq


Re: [GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread Tom Lane
> [EMAIL PROTECTED] wrote:
>> This is a SOAP server, Apache with mod_perl, connecting to Postgres
>> via DBI/DBD::Pg.  Sometimes it gets in a mood, for want of a better
>> term, where a specific SQL statement fails with the good ole message
>> "server closed the connection unexpectedly".  It will fail like this

The specific statement being what exactly?

Bruce Momjian  writes:
> This message is from the backend exiting abruptly.  Is isn't an "ERROR"
> as we define it for logging purposes.  That's why there is nothing in
> the logs.

Nonetheless I'd expect there to be at least a postmaster complaint about
a crashed backend --- assuming that that's what's going on.  Do the
other active connections get forcibly closed when this happens?

regards, tom lane

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] Transaction id wraparound questions

2005-07-06 Thread Tom Lane
Marc Munro <[EMAIL PROTECTED]> writes:
> A recent vacuum of the entire database gave us the dreaded
> "You may have already suffered transaction-wraparound data loss."
> warning.

If you have in fact been vacuuming *every* table including all the
system catalogs, then you don't need to panic; this message just
indicates that the system doesn't know you're safe.

On the other hand, if you haven't ...

> 2) Will a full database vacuum fix the problem?

If it's fixable.  I would recommend that you do this IMMEDIATELY,
rather than dithering, as every transaction you execute is taking
you one step closer to disaster.

> 3) Can it make things worse?
> 4) Other than dump and restore, what options do we have?

If you can conveniently take a full dump, that might give you some
measure of protection, but I'm not sure.  I think that if there is
anything that's already wrapped around, pg_dump will not see it :-(

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[GENERAL] Transaction id wraparound questions

2005-07-06 Thread Marc Munro
It seems that we have not been vacuuming our production database
properly.  We have been explicitly vacuuming all tables individually but
have not vacuumed the entire database.

A recent vacuum of the entire database gave us the dreaded 
"You may have already suffered transaction-wraparound data loss."
warning.

We have so far encountered no problems but I am wondering about the
safest course of action right now.  We cannot easily take an outage to
perform a full dump and restore.  

Questions:
1) What is likely to happen if we encounter transaction id wraparound?
2) Will a full database vacuum fix the problem?
3) Can it make things worse?
4) Other than dump and restore, what options do we have?
 
Information:
This query:
select datname, datvacuumxid, datfrozenxid from pg_database;

returns this:
"Production",1173213507,2246955329 
"template1",  938856359, 938856359 
"template0",427,   427

All responses welcomed.
__
Marc Munro


signature.asc
Description: This is a digitally signed message part


[GENERAL] Scripting Functions to Separate Files

2005-07-06 Thread Mike Fahrenkrog
Title: Scripting Functions to Separate Files






Hi, 

Does anyone know an efficient way to script database objects (preferably all objects, but particularly functions) to separate files? I would like to have a separate file for each object, so that I can easily add them to source control.

Thanks,
--Mike 







Re: [GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread Bruce Momjian
[EMAIL PROTECTED] wrote:
> I hate to post as vague a description as this, but I don't think the
> devil is in the details this time.  I may be wrong ...
> 
> This project is running 7.3.2 on a RedHat 9 system.  We plan to
> upgrade in a few weeks to Fedora Core and Postgres 8, so maybe this
> problem is not worth wasting too much time on, right now.
> 
> This is a SOAP server, Apache with mod_perl, connecting to Postgres
> via DBI/DBD::Pg.  Sometimes it gets in a mood, for want of a better
> term, where a specific SQL statement fails with the good ole message
> "server closed the connection unexpectedly".  It will fail like this

This message is from the backend exiting abruptly.  Is isn't an "ERROR"
as we define it for logging purposes.  That's why there is nothing in
the logs.  I recommend turning on log_statement which prints before the
query is run.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[GENERAL] 7.3.2 closing connections, sometimes

2005-07-06 Thread felix
I hate to post as vague a description as this, but I don't think the
devil is in the details this time.  I may be wrong ...

This project is running 7.3.2 on a RedHat 9 system.  We plan to
upgrade in a few weeks to Fedora Core and Postgres 8, so maybe this
problem is not worth wasting too much time on, right now.

This is a SOAP server, Apache with mod_perl, connecting to Postgres
via DBI/DBD::Pg.  Sometimes it gets in a mood, for want of a better
term, where a specific SQL statement fails with the good ole message
"server closed the connection unexpectedly".  It will fail like this
for several hours, then suddenly start working again.  The SQL that it
fails on works perfectly in psql; it always returns the exact data
expected.  It's a small table of perhaps a dozen lines, and does not
change very often.  I would suspect hardware except that a new machine
behaves just the same.

One of the puzzles is that nothing shows up in the log.  The log is
configured thusly:

server_min_messages = notice
client_min_messages = notice
log_min_error_statement = error

And yet only the only messages that show up are start and stop.  I
changed log_min_error_statement to notice like the others, and it
hasn't failed since, but I doubt this is the cause, because it has
gone thru these mood swings before without having changed the log
level.  It's not the soap server disconnecting from the SOAP client,
because the server continues to log things.

Did 7.3.2 have any problems that might cause random disconnects, or
diconnects for some obscure but documented reason?  Google found some,
but none of them apply here, as far as I can tell.

Or are there useful changes to logging that might track this down?
Strace generated about 50MB of log file, too much for me!

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman & rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] ERROR: cache lookup failed for relation 438095645

2005-07-06 Thread Tom Lane
Joe Markwardt <[EMAIL PROTECTED]> writes:
>>> I am getting this error "ERROR:  cache lookup failed for relation
>>> 438095645" when i try to run "drop table
>>> pl_inventory_analyzer_files_table ;" from psql on the database server.
>> 
>> Look through the system catalogs to see where that OID appears.

>   I found the attached entries in the pg_trigger table, but I'm not quite
> sure how to read them, or what to do about them.

They appear to be triggers for a foreign-key constraint between 
pl_inventory_analyzer_files_table and pl02_status_table ... so I guess
the question is what happened to the latter?

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] ERROR: cache lookup failed for relation 438095645

2005-07-06 Thread Joe Markwardt
On Wed, 2005-07-06 at 11:20 -0400, Tom Lane wrote:
> Joe Markwardt <[EMAIL PROTECTED]> writes:
> > I am getting this error "ERROR:  cache lookup failed for relation
> > 438095645" when i try to run "drop table
> > pl_inventory_analyzer_files_table ;" from psql on the database server.
> 
> Look through the system catalogs to see where that OID appears.
> pg_index.indexrelid, pg_trigger.tgconstrrelid, pg_depend.objid,
> pg_depend.refobjid are likely places.
> 
>   regards, tom lane
> 
Tom,
I found the attached entries in the pg_trigger table, but I'm not quite
sure how to read them, or what to do about them.

Thanks
Joe 



> ---(end of broadcast)---
> TIP 4: Don't 'kill -9' the postmaster
> 
  tgrelid  | tgname | tgfoid | tgtype | tgenabled | 
tgisconstraint | tgconstrname | tgconstrrelid | tgdeferrable | tginitdeferred | 
tgnargs | tgattr |  tgargs  
 
---++++---++--+---+--++-++---
 438095645 | RI_ConstraintTrigger_438095995 |   1654 |  9 | t | t   
   | $1   | 438095488 | f| f  | 
  6 || 
$1\000pl_inventory_analyzer_files_table\000pl02_status_table\000UNSPECIFIED\000status_id\000status_id\000
 438095645 | RI_ConstraintTrigger_438095996 |   1655 | 17 | t | t   
   | $1   | 438095488 | f| f  | 
  6 || 
$1\000pl_inventory_analyzer_files_table\000pl02_status_table\000UNSPECIFIED\000status_id\000status_id\000
 438095645 | RI_ConstraintTrigger_438096079 |   1654 |  9 | t | t   
   | status_id_fk | 438094722 | f| f  | 
  6 || 
status_id_fk\000pl02_rfq_table\000pl02_status_table\000UNSPECIFIED\000status_id\000status_id\000
 438095645 | RI_ConstraintTrigger_438096080 |   1655 | 17 | t | t   
   | status_id_fk | 438094722 | f| f  | 
  6 || 
status_id_fk\000pl02_rfq_table\000pl02_status_table\000UNSPECIFIED\000status_id\000status_id\000
 438095645 | RI_ConstraintTrigger_694764779 |   1654 |  9 | t | t   
   | $3   | 694764764 | f| f  | 
  6 || 
$3\000pl_batch_search_table\000pl02_status_table\000UNSPECIFIED\000status\000status_id\000
 438095645 | RI_ConstraintTrigger_694764780 |   1655 | 17 | t | t   
   | $3   | 694764764 | f| f  | 
  6 || 
$3\000pl_batch_search_table\000pl02_status_table\000UNSPECIFIED\000status\000status_id\000
(6 rows)


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] Pl/PgsSQL array

2005-07-06 Thread Ben-Nes Yonatan

Richard Huxton wrote:

Ben-Nes Yonatan wrote:


Hi all,

Can anyone tell me if Pl/PgSQL can support a multi dimensional array 
(of up to 5 levels top I guess) with about 100,000 values?

and does it stress the system too much?



I can't imagine it being wonderful - you probably want a different 
procedural language. Or a different approach come to think of it - can I 
ask what you are using 5D arrays with 100,000 values for?




Indeed you can my good sir :)

Im going to insert into one table a list of about 3.5 million products 
each day, thouse products also contain data about their own categories.


Now I receive all of this data every day and I need to delete all of the 
previous data each time and insert the new one.
In order to create the category table (tree table) I want to create an 
array out of the categories information at the products and then insert 
it into the the categories table (the tree :)).


I also thought about retrieving the data from the products table and 
inserting it first into a temporary table and from that information 
create the categories table (tree :)), but I prefer to save the next 
selects from that table and just create an array.


Maybe you or anyone else got a better idea?

Thanks again!

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] Pl/PgsSQL array

2005-07-06 Thread Richard Huxton

Ben-Nes Yonatan wrote:

Hi all,

Can anyone tell me if Pl/PgSQL can support a multi dimensional array (of 
up to 5 levels top I guess) with about 100,000 values?

and does it stress the system too much?


I can't imagine it being wonderful - you probably want a different 
procedural language. Or a different approach come to think of it - can I 
ask what you are using 5D arrays with 100,000 values for?


--
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


Re: [GENERAL] Custom C function shutdown-signaling

2005-07-06 Thread Otto Blomqvist
Once again Tom comes threw and saves the day...!

Thanks Tom !

/Otto Blomqvist



"Tom Lane" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Otto Blomqvist" <[EMAIL PROTECTED]> writes:
> > How do I signal a custom C function that the Postmaster wants to shut
down ?
>
> Do "CHECK_FOR_INTERRUPTS();" at a suitable spot in the C function's main
> loop.
>
> regards, tom lane
>
> ---(end of broadcast)---
> TIP 8: explain analyze is your friend
>



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] ERROR: cache lookup failed for relation 438095645

2005-07-06 Thread Tom Lane
Joe Markwardt <[EMAIL PROTECTED]> writes:
>   I am getting this error "ERROR:  cache lookup failed for relation
> 438095645" when i try to run "drop table
> pl_inventory_analyzer_files_table ;" from psql on the database server.

Look through the system catalogs to see where that OID appears.
pg_index.indexrelid, pg_trigger.tgconstrrelid, pg_depend.objid,
pg_depend.refobjid are likely places.

regards, tom lane

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[GENERAL] ERROR: cache lookup failed for relation 438095645

2005-07-06 Thread Joe Markwardt
Hey list,
I am getting this error "ERROR:  cache lookup failed for relation
438095645" when i try to run "drop table
pl_inventory_analyzer_files_table ;" from psql on the database server.
I've already REINDEX'd the database system tables, and all the indexes
on that table, and on all the indexes on any tables referenced by
foreign keys.  OS and Version info below, more info available upon
request. Does anyone have any suggestions on how to fix this?

Thanks, 
Joe

select version();
  version

 PostgreSQL 7.4.6 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC)
3.2.2 (SuSE Linux)
(1 row)

uname -a
Linux mammon 2.4.21-273-smp #1 SMP Mon Jan 17 12:31:48 UTC 2005 x86_64
unknown




---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [GENERAL] Seg fault in postgres 7.4.7?

2005-07-06 Thread Alvaro Herrera
On Tue, Jul 05, 2005 at 09:58:12PM -0700, Akash Garg wrote:
> My postgres 7.4.7 installation crashed on its own today -- here is the
> error log:
> 
> ERROR:  duplicate key violates unique constraint "toolbar_pkey"
> LOG:  server process (PID 22753) was terminated by signal 11
> LOG:  terminating any other active server processes
> WARNING:  terminating connection because of crash of another server process
> DETAIL:  The postmaster has commanded this server process to roll back
> the current transaction and exit, because another server process
> exited abnormally and possibly corrupted shared memory.
> 
> Is this a known bug?

No.  Do you have a core dump?  Do you have any C functions, or triggers,
or anything unusual?

-- 
Alvaro Herrera ()
Officer Krupke, what are we to do?
Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] current_user inside SECURITY DEFINER function?

2005-07-06 Thread Adam Witney

I think you want to use session_user instead

Adam


> Is there any way to get the name of the current user inside a PL/pgSQL
> function that is defined with security definer?
> 
> current_user gives the name of the user who created the function.
> 
> The reason I want this is that I intend to use functions to maintain
> security, like this:
> 
> userA has only select permission on myTable.
> 
> The only way userA can insert to myTable is by providing parameters
> for and executing myFunction.
> 
> myFunction was created by user postgres who does have insert
> permission on myTable. However the code inside myFunction needs to do
> different things, depending on who called it.
> 
> Is there any way of getting the user?
> 
> regards
> Richard
> 
> 
> ---(end of broadcast)---
> TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] current_user inside SECURITY DEFINER function?

2005-07-06 Thread Stephan Szabo
On Tue, 5 Jul 2005, Richard Hayward wrote:

> Is there any way to get the name of the current user inside a PL/pgSQL
> function that is defined with security definer?

IIRC, SESSION_USER should give the original user.

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [GENERAL] current_user inside SECURITY DEFINER function?

2005-07-06 Thread Stephen Frost
* Richard Hayward ([EMAIL PROTECTED]) wrote:
> Is there any way of getting the user?

You might try session_user.  8.1 will hopefully clean this up some.

Thanks,

Stephen


signature.asc
Description: Digital signature


Re: [GENERAL] Seg fault in postgres 7.4.7?

2005-07-06 Thread Michael Fuhr
On Wed, Jul 06, 2005 at 09:20:34AM +0100, Richard Huxton wrote:
> 
> Can't see anything there, so if it's a bug in the 7.4 series, you're the 
> first to discover it. There might be something unusual about your 
> installation. Can you give details (did you install from source/package, 
> what OS, what OS version, character set, locale, any patches/add-on 
> modules).

Did you get a core dump?  If so then it might be useful to see a
stack trace from it.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[GENERAL] Pl/PgsSQL array

2005-07-06 Thread Ben-Nes Yonatan

Hi all,

Can anyone tell me if Pl/PgSQL can support a multi dimensional array (of 
up to 5 levels top I guess) with about 100,000 values?

and does it stress the system too much?

Thanks!
Ben-Nes Yonatan
Canaan Surfing ltd.

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [GENERAL] PostgreSQL sequence within function

2005-07-06 Thread Clark Allan
I figured it out... the problem was calling nextval("seq") with double quotes.
 
Normally, you would do "select nextval('seq')".  From within a function, calling nextval with single quotes around the argument, causes a syntax error.
 
SOLUTION:
you need to use "backslash escape" sequences around the sequence argument... example below---

CREATE FUNCTION sp_slide_create(int4) RETURNS int4 AS'DECLAREaScriptID ALIAS FOR $1;seqID int4 := nextval(\'genseq\'); -- the magic is hereBEGIN
INSERT INTO tblslides (slideid) VALUES (seqID);RETURN seqID;END;'LANGUAGE 'plpgsql' VOLATILE;
---
Maybe this is an obvious solution, but i really think there should be something in the documentation about this (...pgsql-docs CC'ed)ThanksClark Allan
On 7/5/05, Tony Caduto <[EMAIL PROTECTED]> wrote:
Try this version of your function.I don't think you can assign a value to a variable in the declaration
section with the return value of a function.CREATE OR REPLACE FUNCTION sp_slide_create(int4, bool, bool, bool,varchar, text, varchar, varchar, int4)RETURNS int4 AS'DECLAREaScriptID ALIAS FOR $1;
aAllowDGP ALIAS FOR $2;aAllowDGO ALIAS FOR $3;aWaitForSlideFinish ALIAS FOR $4;aTitle ALIAS FOR $5;aText ALIAS FOR $6;aFlashFileDGP ALIAS FOR $7;aFlashFileDGO ALIAS FOR $8;aSlideType ALIAS FOR $9;
seqID int4;BEGIN seqID = nextval("seqslideid");INSERT INTO tblslides(slideid, scriptID, allowdgp, allowdgo, waitforslidefinish, title,text, flashfiledgp, flashfiledgo, slidetype)
VALUES(seqID, aScriptID, aAllowDGP, aAllowDGO, aWaitForSlideFinish, aTitle,aText, aFlashFileDGP, aFlashFileDGO, aSlideType);RETURN seqID;END;'LANGUAGE 'plpgsql' VOLATILE;Clark Allan wrote:
> Thanks for the help Tony,> But im still having some trouble.>


Re: [GENERAL] template1 problems

2005-07-06 Thread Patrick . FICHE
Tom Lane recently pointed one excellent article dealing with this problem...
http://techdocs.postgresql.org/techdocs/pgsqladventuresep1.php

Regards,
Patrick


--- 
Patrick Fiche 
email : [EMAIL PROTECTED] 
tél : 01 69 29 36 18 

--- 




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Sim Zacks
Sent: mercredi 6 juillet 2005 16:06
To: pgsql-general@postgresql.org
Subject: [GENERAL] template1 problems


Postgresql 8.0 Linux. using PGAdmin III 1.2 client

I accidentally did a restore of my database into template1. I thought the
best way to reverse it would be to drop the database and make a new one with
template0 as the template. But it didn't like that because template1 is a
system database so I can't drop it.

Is there a better way of fixing this then going through and deleting all the
objects one at a time?

Thanks
Sim



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[GENERAL] current_user inside SECURITY DEFINER function?

2005-07-06 Thread Richard Hayward
Is there any way to get the name of the current user inside a PL/pgSQL
function that is defined with security definer?

current_user gives the name of the user who created the function.

The reason I want this is that I intend to use functions to maintain
security, like this: 

userA has only select permission on myTable.

The only way userA can insert to myTable is by providing parameters
for and executing myFunction.

myFunction was created by user postgres who does have insert
permission on myTable. However the code inside myFunction needs to do
different things, depending on who called it.

Is there any way of getting the user?

regards
Richard
 

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[GENERAL] suggestion for diagnostics (errors)

2005-07-06 Thread Nikolay Samokhvalov
Consider following SQL: 
**
select femail, min(fid) AS main_id, count(fid) AS countids
from users
where count(fid) > 1
group by femail
**

Of course, postgreSQL produce error for such wrong statement:
SQL error:
ERROR:  aggregates not allowed in WHERE clause
I think it would be much better if DBMS will provide us some kind of suggestions, e.g.:
SQL error:

ERROR:  aggregates not allowed in WHERE clause. Consider using HAVING clause.


-- Best regards,Nikolay


Re: [GENERAL] PostgreSQL sequence within function

2005-07-06 Thread Clark Allan
Thanks for the help Tony,
But im still having some trouble.
 
Here is the exact function
---
CREATE OR REPLACE FUNCTION sp_slide_create(int4, bool, bool, bool, varchar, text, varchar, varchar, int4)RETURNS int4 AS'DECLARE aScriptID ALIAS FOR $1; aAllowDGP ALIAS FOR $2; aAllowDGO ALIAS FOR $3;
 aWaitForSlideFinish ALIAS FOR $4; aTitle ALIAS FOR $5; aText ALIAS FOR $6; aFlashFileDGP ALIAS FOR $7; aFlashFileDGO ALIAS FOR $8; aSlideType ALIAS FOR $9;  seqID int4 := nextval("seqslideid");
 BEGIN INSERT INTO tblslides (slideid, scriptID, allowdgp, allowdgo, waitforslidefinish, title, text, flashfiledgp, flashfiledgo, slidetype) VALUES (seqID, aScriptID, aAllowDGP, aAllowDGO, aWaitForSlideFinish, aTitle, aText, aFlashFileDGP, aFlashFileDGO, aSlideType);

 RETURN seqID;END;'
LANGUAGE 'plpgsql' VOLATILE;
---
 
I can get the code above to fire no problem.  However, when i run the following i get an error.
 
--
select sp_slide_create(88, true, true, true, 'varcharOne', 'textOne', 'varcharTwo', 'varcharThree', 2);
 
ERROR:  column "seqslideid" does not existCONTEXT:  PL/pgSQL function "sp_slide_create" line 14 at block variables initialization
--
 
Thanks for the help 
On 6/30/05, Tony Caduto <[EMAIL PROTECTED]> wrote: 
All you where really mising was a semi colon afer nextval('myseq') andthe begin end.CREATE or REPLACE FUNCTION getSeq()
RETURNS int AS$$beginRETURN nextval('myseq');end;$$LANGUAGE 'plpgsql';Clark Allan wrote:>-->CREATE FUNCTION getSeq()>RETURNS int AS'
>RETURN nextval('myseq')>'LANGUAGE 'plpgsql';>-->>Thanks for the help>Clark>>


[GENERAL] template1 problems

2005-07-06 Thread Sim Zacks
Postgresql 8.0 Linux. using PGAdmin III 1.2 client

I accidentally did a restore of my database into template1. I thought the
best way to reverse it would be to drop the database and make a new one with
template0 as the template. But it didn't like that because template1 is a
system database so I can't drop it.

Is there a better way of fixing this then going through and deleting all the
objects one at a time?

Thanks
Sim



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] double entries into database when using IE

2005-07-06 Thread D A GERM
Thank you all. 


I changed the type to button and added the onClick="return(myFunction())".

I did some tests this morning and the double posts seem to stop.

The duplicate entries were a thousandth to a ten thousandth off in the 
time stamp, but now there's only the one entry as should be.


Thank you again.

David Gagnon wrote:






[EMAIL PROTECTED] wrote:


Hi,

If a web page has  JavaScript called on a submit button, like
'onClick="someFunction();", and the function does some stuff, then does a
form.submit(), and DOES NOT REMEMBER TO RETURN FALSE, then the browser is
supposed to go ahead and submit the form.  So, something like that could
possibly happen, but only if the JavaScript is incorrectly written, as far
as I know.   Although, once a submit is done, it would be a gray area as to
whether the form data would still be available for the second submit.
 



I think this thread discuss the problem .. like they say I started 
having the problem with some version of IE6 but not IE5.

http://forums.devshed.com/showthread.php?t=50160&page=1&pp=15
http://www.tfug.org/pipermail/tfug/2004-October/007785.html

They don't give the answer but when they talk

here is what it might be:

onClick="javascript:submitit();">


if you use javascript to submit the form

do not use a button type of submit.it will submit twice

correct code

onClick="javascript:submitit();">


Like SCassidy said .. maybe returing FALSE will solve the problem .. 
but I remember having tried this without success...


It's all what I know :-)




I use JavaScript in forms all the time to interact with a PostgreSQL
database, and don't have any issues like this with debugged code, using
IE6.

Susan



  
  David Gagnon
 <[EMAIL PROTECTED]>   To:   D A GERM <[EMAIL PROTECTED]>   
  Sent by:  cc:   Postgresql-General
Subject:  Re: [GENERAL] double entries into database when using IE
  
 [EMAIL PROTECTED] |---|
 tgresql.org | [ ] Expand Groups |
 |---|
  
  07/05/2005 02:24
 PM   
  
  





Hi,

I have seen IE posting request twice to the server when you post using a
button that use javascript.  Per example, if you have a submit button
and call a javascript that actually post the form... IE will still do
the post attached to the submit button.  So you will have 2 submits
It's stupid but it's true.

It's happen on some version of IE6 I think .. not all for what I remember.

You can search the web for the solution ... I don't remember what I did
or if I actually did something to solve the problem.

/David

P.S.: This is quite OT for the postgresql mailing list .. you don't think ?

 D A GERM wrote:

 


I am having a problem when a browser dumps data into a table.
When the browser is Firefox , it works perfect; when the browser is
IE, it dumps 2 entries into the table just thousandths of a second apart.

What could be causing this? Is this an issue with IE, Apache or Postgres.

Thanks in advance for any help.

   




---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster







--
See our award-winning line of tape and disk-based
backup & recovery solutions at http://www.overlandstorage.com
--


---

Re: [GENERAL] Seg fault in postgres 7.4.7?

2005-07-06 Thread Richard Huxton

Akash Garg wrote:

My postgres 7.4.7 installation crashed on its own today -- here is the
error log:

ERROR:  duplicate key violates unique constraint "toolbar_pkey"
LOG:  server process (PID 22753) was terminated by signal 11
LOG:  terminating any other active server processes
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back
the current transaction and exit, because another server process
exited abnormally and possibly corrupted shared memory.

Is this a known bug?


Well - a sig-11 (segment violation/fault) is generally caused by 
dereferencing a pointer that is corrupted. So, it could be:

 1. Hardware fault
 2. Data corruption (of the index, caused by a previous crash)
 3. Programming error.

It's probably worth running one of the "memtest" tools to check you 
don't have a fault with your RAM chips. It could also be a fault in your 
disk controller/drives, but that's harder to test for (unless you're 
seeing disk errors).


Before that though, make sure your backups are good (it doesn't hurt to 
be over-cautious). Re-index (see REINDEX command in manuals) the index 
in question, that can't hurt either if you've had a power-failure or 
similar in the past.


OK - if you've ruled out memory problems and not had a crash then it 
might be a bug in 7.4.7. I've searched the "bugs" mailing list for the 
last 6 months at http://archives.postgresql.org/


Can't see anything there, so if it's a bug in the 7.4 series, you're the 
first to discover it. There might be something unusual about your 
installation. Can you give details (did you install from source/package, 
what OS, what OS version, character set, locale, any patches/add-on 
modules).


--
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 6: Have you searched our list archives?

  http://archives.postgresql.org