[ADMIN] Having problem with postgresql configuration (template1 doesn't exist)?

2005-02-20 Thread Vinicius
Hello,
I'm having problem with the configuration of postgresql. Can anybody 
help me, please?

I did do the followings steps as explained in the section "16.2. 
Creating a Database Cluster" of the "PostgreSQL 7.4.7 Documentation":

"root# mkdir /usr/local/pgsql/data
root# chown postgres /usr/local/pgsql/data
root# su postgres
postgres$ initdb -D /usr/local/pgsql/data"
then shows:
"fixing permissions on existing directory /usr/local/pgsql/data... ok
creating directory /usr/local/pgsql/data/base... ok
creating directory /usr/local/pgsql/data/global... ok
creating directory /usr/local/pgsql/data/pg_xlog... ok
creating directory /usr/local/pgsql/data/pg_clog... ok
selecting default max_connections... 10
selecting default shared_buffers... 50
creating configuration files... ok
creating template1 database in /usr/local/pgsql/data/base/1...
initdb: failed"
the file /var/log/messages shows:
"Feb 20 02:01:38 ronin kernel: audit(1108875698.227:0): avc:  denied  { 
write } for  pid=8229 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin last message repeated 36 times
Feb 20 02:01:38 ronin kernel: audit(1108875698.228:0): avc:  denied  { 
write } for  pid=8229 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin last message repeated 47 times
Feb 20 02:01:38 ronin kernel: audit(1108875698.229:0): avc:  denied  { 
write } for  pid=8229 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin last message repeated 16 times
Feb 20 02:01:38 ronin kernel: audit(1108875698.435:0): avc:  denied  { 
write } for  pid=8305 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin kernel: audit(1108875698.436:0): avc:  denied  { 
write } for  pid=8305 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin last message repeated 39 times
Feb 20 02:01:38 ronin kernel: audit(1108875698.437:0): avc:  denied  { 
write } for  pid=8305 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin last message repeated 46 times
Feb 20 02:01:38 ronin kernel: audit(1108875698.438:0): avc:  denied  { 
write } for  pid=8305 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir
Feb 20 02:01:38 ronin last message repeated 13 times
Feb 20 02:01:52 ronin su(pam_unix)[8056]: session closed for user postgres"

I have:
kernel-2.6.10-1.766_FC3
libselinux-1.19.1-8
libselinux-devel-1.19.1-8
selinux-policy-targeted-1.17.30-2.80
postgresql-7.4.7-1.FC3.2
postgresql-libs-7.4.7-1.FC3.2
postgresql-server-7.4.7-1.FC3.2
TIA,
Vinicius.
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [ADMIN] Having problem with postgresql configuration (template1 doesn't exist)?

2005-02-20 Thread Tom Lane
Vinicius <[EMAIL PROTECTED]> writes:
> postgres$ initdb -D /usr/local/pgsql/data"

> the file /var/log/messages shows:
> "Feb 20 02:01:38 ronin kernel: audit(1108875698.227:0): avc:  denied  { 
> write } for  pid=8229 exe=/usr/bin/postgres name=data
> dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
> tcontext=root:object_r:usr_t tclass=dir

You can't put the data directory in a nonstandard place under SELinux
unless you modify the security policy to allow the postgres daemon to
write in that nonstandard place.  The normal behavior of
selinux-policy-targeted is to confine postgres to /var/lib/pgsql.

So: (1) use /var/lib/pgsql/data, (2) modify the policy, or (3)
disable SELinux enforcement.

BTW, since you are using the RPMs, why are you bothering with manual
database setup?  "sudo /sbin/service postgresql start" is all you
need to do.

regards, tom lane

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


Re: [ADMIN] Having problem with postgresql configuration (template1 doesn't

2005-02-20 Thread Vinicius
Tom Lane escreveu:
Vinicius <[EMAIL PROTECTED]> writes:
postgres$ initdb -D /usr/local/pgsql/data"

the file /var/log/messages shows:
"Feb 20 02:01:38 ronin kernel: audit(1108875698.227:0): avc:  denied  { 
write } for  pid=8229 exe=/usr/bin/postgres name=data
dev=dm-0 ino=1687533 scontext=user_u:system_r:postgresql_t 
tcontext=root:object_r:usr_t tclass=dir

You can't put the data directory in a nonstandard place under SELinux
unless you modify the security policy to allow the postgres daemon to
write in that nonstandard place.  The normal behavior of
selinux-policy-targeted is to confine postgres to /var/lib/pgsql.
So: (1) use /var/lib/pgsql/data, (2) modify the policy, or (3)
disable SELinux enforcement.
BTW, since you are using the RPMs, why are you bothering with manual
database setup?  "sudo /sbin/service postgresql start" is all you
need to do.
regards, tom lane
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
Thanks.
I tryed to create another data dir because I don't have the template1 
database.

"# ls /var/lib/pgsql/data/base/1
1247   16386  16396  16406  16416  16601  16606  16611  16616  16621 
16630  16635  16640  16647  16652
1249   16388  16398  16408  16418  16602  16607  16612  16617  16624 
16631  16636  16641  16648  16653
1255   16390  16400  16410  16595  16603  16608  16613  16618  16625 
16632  16637  16642  16649  pg_internal.init
1259   16392  16402  16412  16597  16604  16609  16614  16619  16626 
16633  16638  16643  16650  PG_VERSION
16384  16394  16404  16414  16599  16605  16610  16615  16620  16629 
16634  16639  16644  16651"

How to workaround this, please? Should I remove the /var/lib/pgsql/data 
dir and create another with initdb command, please?

TIA,
Vinicius.
---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [ADMIN] Having problem with postgresql configuration (template1 doesn't

2005-02-20 Thread Tom Lane
Vinicius <[EMAIL PROTECTED]> writes:
> I tryed to create another data dir because I don't have the template1 
> database.

I think you got bit by one of the early-FC3 selinux policy bugs; see
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=142607
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=143208

You probably want to rm -rf /var/lib/pgsql/data/ and try again
after making sure (a) you have the latest postgres and selinux
packages and (b) you've done restorecon on /var/lib/pgsql and
/var/log/pgsql.

regards, tom lane

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


Re: [ADMIN] Postgres crashed on invalid IP entry in pg_hba.conf

2005-02-20 Thread Bruce Momjian
Pallav Kalva wrote:
> I am using 7.4.2 on Redhat 9 Linux 2.4. I know iam on old version, we 
> are actually planning to  move to 8.0.1 soon, I just wanted to know if 
> this is bug if so if it is 7.4.2 related .

You just need to stop your server, install 7.4.7 and restart.  There is
no reason to be running 7.4.2 unless you can't do 2 minutes of downtime.
Even if you upgrade to 8.0.1 you will need to do this when 8.0.2 comes
out.

-- 
  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 4: Don't 'kill -9' the postmaster


Re: [ADMIN] [SQL] Trigger

2005-02-20 Thread Eugen Gass


Hi,
Thank you ALL for the fast help

it works fine with following code:

CREATE OR REPLACE FUNCTION synchronize () RETURNS trigger AS 'BEGIN
NEW.objectid := NEW.gid; RETURN NEW; END;' LANGUAGE plpgsql;

CREATE TRIGGER syncl_holz_lager AFTER INSERT ON holz_lagerplatz FOR EACH ROW
EXECUTE PROCEDURE synchronize();

Best Regards

Eugen




-Ursprüngliche Nachricht-
Von: Pavel Rabel [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 16. Februar 2005 21:43
An: Eugen Gass
Cc: pgsql-sql@postgresql.org
Betreff: Re: [SQL] Trigger


It requires a bit more work in PostgreSQL to create a trigger.

 From the documentation: "It is not currently possible to write a
SQL-language trigger function. Trigger functions can be written in C or
in some of the available procedural languages."

I guess you will prefer to write the trigger in PL/pgSQL, have a look at
http://www.postgresql.org/docs/8.0/interactive/plpgsql-trigger.html

Regards

Pavel

Eugen Gass wrote:

>Hi,
>
>I'm trying to create a trigger on PostgreSQL
>
>it should be like an oracle(sql) sample code:
>
>create or replace trigger frei_polygon_sync
>after INSERT on frei_polygon
>Referencing NEW as newROW
>for each row
>Begin
> :newRow.objektid :=  :newRow.gid;
> :
>end;
>
>Can sombody help me to do the same on Postrgres
>
>Thanks
>
>Best Regards
>
>EG
>
>---(end of broadcast)---
>TIP 5: Have you checked our extensive FAQ?
>
>   http://www.postgresql.org/docs/faq
>
>
>


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


[ADMIN] Access Permissions to Users

2005-02-20 Thread ganapatiram



Hi Experts,
 
  I am using 
Postgresql 8.0 windows version. I am using this in the server as well as clients 
with the same access permissions to users as i am not aware how to set-up the 
access permissions for other users seperating super user.
 
        
    If i want to give only view permissions to a set of users, 
how can i do that?
 
If 
i want to give only insert & view permissions to a set of users, how 
can i do that? and on...
 
 
Please let me know how can i set access 
permissions.
 
Thanks and Regards
Ram


[ADMIN] PostgreSQL Errors...

2005-02-20 Thread Chari Clark
I created the following statement:
CREATE TYPE get_item_info_type AS (full_name varchar(300),dob 
varchar(300));

CREATE OR REPLACE FUNCTION sp_items(int8) RETURNS get_item_info_type AS
'
   DECLARE
   in_id  items.item_no%TYPE;
   BEGIN
   select
   coalesce(full_name, '') as fullname,
   coalesce(dob, '') as dob
   from
   items
   where
   item_no = in_id
   ;
   RETURN;
   END;
'
LANGUAGE 'plpgsql';
This statement compiles fine, but when calling the funtion from a SELECT 
statement for a specific item, I get the following error message:

select * FROM sp_items('850001');
ERROR:  return type mismatch in function returning tuple at or near ";"
CONTEXT:  compile of PL/pgSQL function "sp_aliases" near line 14
In order to return fullname and dob, I'm not sure if the data type for 
sp_items needs to match the get_item_info_type or what.

I think this is my last hurdle, so any help would be over-greatly 
appreciated.

Thanks,
--
Chari Clark
Database Administrator
National Background Data, LLC
A First Advantage Company (NASDAQ:  FADV)
352.629.9913
[EMAIL PROTECTED]
www.nationalbackgrounddata.com
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[ADMIN] ODBC driver version

2005-02-20 Thread Insyde



Hello.
 
I'm using PostgreSQL 7.4 in one server. But 
recently I installed version 8.0 in my machine for testing. The ODBC driver 
installed was the version 8.0 too, and now, some applications using ODBC to 
create tables in server (7.4) version doesn't work.
 
Questions:
  - Can 8.0 version of driver be used with 7.4 
version of server?
  - I can't found any distribution of 8.0 
version of ODBC driver. Is the 8.0 version of driver stable?
 
Thanks.
 
Maurício Kanada


Re: [ADMIN] Access Permissions to Users

2005-02-20 Thread John DeSoi
On Feb 17, 2005, at 6:15 AM, ganapatiram wrote:
  I am using Postgresql 8.0 windows version. I am using this 
in the server as well as clients with the same access permissions to 
users as i am not aware how to set-up the access permissions for other 
users seperating super user.
 
            If i want to give only view permissions to a set of users, 
how can i do that?
 
If i want to give only insert & view permissions to a set 
of users, how can i do that? and on...
 
 
Please let me know how can i set access permissions.

Use CREATE GROUP to give permissions to a set of users.
http://www.postgresql.org/docs/8.0/interactive/sql-creategroup.html
The GRANT command is used to give permissions for specific operations 
to users and/or groups.

http://www.postgresql.org/docs/8.0/interactive/sql-grant.html
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faq


Re: [ADMIN] PostgreSQL Errors...

2005-02-20 Thread Iain
Hi,
try doing it this way and work from there:
select sp_items('850001');
regards
Iain
- Original Message - 
From: "Chari Clark" <[EMAIL PROTECTED]>
To: ; <[EMAIL PROTECTED]>
Sent: Friday, February 18, 2005 5:25 AM
Subject: [ADMIN] PostgreSQL Errors...


I created the following statement:
CREATE TYPE get_item_info_type AS (full_name varchar(300),dob 
varchar(300));

CREATE OR REPLACE FUNCTION sp_items(int8) RETURNS get_item_info_type AS
'
   DECLARE
   in_id  items.item_no%TYPE;
   BEGIN
   select
   coalesce(full_name, '') as fullname,
   coalesce(dob, '') as dob
   from
   items
   where
   item_no = in_id
   ;
   RETURN;
   END;
'
LANGUAGE 'plpgsql';
This statement compiles fine, but when calling the funtion from a SELECT 
statement for a specific item, I get the following error message:

select * FROM sp_items('850001');
ERROR:  return type mismatch in function returning tuple at or near ";"
CONTEXT:  compile of PL/pgSQL function "sp_aliases" near line 14
In order to return fullname and dob, I'm not sure if the data type for 
sp_items needs to match the get_item_info_type or what.

I think this is my last hurdle, so any help would be over-greatly 
appreciated.

Thanks,
--
Chari Clark
Database Administrator
National Background Data, LLC
A First Advantage Company (NASDAQ:  FADV)
352.629.9913
[EMAIL PROTECTED]
www.nationalbackgrounddata.com
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org