Thread: [NOVICE] newbie problem on creating table

[NOVICE] newbie problem on creating table

From
"Thomas Krebs"
Date:
> >I am trying to get a start with Postgres 6.4 on Suse Linux 6.4.
> I did that just 2 weeks ago.

 and it works?

 > >I created a superuser who is allowed to create databases.I created a
> >user and a database, but I didn't manage so far to create a table.
> like : $ psql -c "create table test ( a int, b int )"

 yes, I tried exactly this statement, but still the same error

 > > It just returns "Error cannot create <tablename>.
> Did you install the pg_datab and pg_ifa packages, too ?

 yes, I installed both packages

> >In the configuration file for the authentication, I used the settings
coming
> >with the installation:
> >
> >local all            trust
> >hosts all 127.0.0.1 255.255.255.255 trust
> >
> >The logfile also just shows the messages:
> >Error: Cannot create <table>
> >AbortCurrentTx
> >....
> >
> >I am really stuck and have no glue where to look or to start. Any help is
> >highly welcome
> Well, glue won't help you to become unstuck :-)
 I take whatever it needs to get this fixed :-)

 > >thomas
> >
> >PS: posted to pgsql-novice and pgsql-general
> >
> >
> --
> Bernd Tegge                  mailto:tegge@repas-aeg.de
> Tel: ++49-511-87449-12       repas AEG Automation GmbH
> Fax: ++49-511-87449-20       GS Hannover, Germany
>
>
>


Re: [NOVICE] newbie problem on creating table

From
Travis Bauer
Date:
Does the database you created have the same name as the user executing the
query you mentioned?  I believe that, as given, psql will try to connect
to a database having the same name as the login name of the user executing
the statement.

----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------

On Mon, 10 Jul 2000, Thomas Krebs wrote:

> > >I am trying to get a start with Postgres 6.4 on Suse Linux 6.4.
> > I did that just 2 weeks ago.
>
>  and it works?
>
>  > >I created a superuser who is allowed to create databases.I created a
> > >user and a database, but I didn't manage so far to create a table.
> > like : $ psql -c "create table test ( a int, b int )"
>
>  yes, I tried exactly this statement, but still the same error
>


Re: [NOVICE] newbie problem on creating table

From
Tom Lane
Date:
"Thomas Krebs" <thomas@krebs-haertl.de> writes:
>>>> It just returns "Error cannot create <tablename>.

I believe this error indicates that the kernel rejected Postgres'
attempt to create a file for the new table.  Unfortunately we can't
see the exact kernel error message (that's fixed for 7.1, but it
won't help you for 7.0 unless you're prepared to alter and recompile
sources...).

I will make a wild guess that the problem is incorrect permissions on
the database directory.  Take a look in $PGDATA/base/ and make sure the
database subdirectory is owned and writable by whatever user you are
running the postmaster as.  (Which had better NOT be root!)

            regards, tom lane

Re: [NOVICE] newbie problem on creating table

From
"Thomas Krebs"
Date:
> >> >I am trying to get a start with Postgres 6.4 on Suse Linux 6.4.
> >> I did that just 2 weeks ago.
> >
> >and it works?
> yes, no problems :
> root@hanlrs:/tmp > su -- postgres
> postgres@hanlrs:/tmp > PATH=$PATH:/usr/lib/pgsql/bin
> postgres@hanlrs:/tmp > createuser
> Enter name of user to add: root
> Shall the new user be allowed to create databases? (y/n) y
> Shall the new user be allowed to create more new users? (y/n) y
> CREATE USER
> postgres@hanlrs:/tmp > exit
> root@hanlrs:/tmp > createuser nobody
> Shall the new user be allowed to create databases? (y/n) y
> Shall the new user be allowed to create more new users? (y/n) n
> CREATE USER
> root@hanlrs:/tmp > su -- nobody
> nobody@hanlrs:/tmp > PATH=$PATH:/usr/lib/pgsql/bin
> nobody@hanlrs:/tmp > createdb test
> CREATE DATABASE
> nobody@hanlrs:/tmp > psql -dtest -c "create table test1( a int)"
> CREATE
> nobody@hanlrs:/tmp > psql -dtest
> Welcome to psql, the PostgreSQL interactive terminal.
>
> Type:  \copyright for distribution terms
>        \h for help with SQL commands
>        \? for help on internal slash commands
>        \g or terminate with semicolon to execute query
>        \q to quit
>
> test=> insert into test1 values (1);
> INSERT 621408 1
> test=> select * from test1
> test-> \g
>  a
> ---
>  1
> (1 row)
>
> test=>

I deinstalled and installed postgres and executed exactly the same
statements as you, and it worked. One thing I am not sure about is during
creation of a user, I am asked whether to use a postgres ID or UNIX ID, what
is the right/recommended approach (I used UNIX ID).

Then I created a new database "castortest". I tried to execute a file
creating a schema with a bunch of tables and index definitions with
psql -dcastortest -f create.sql

This returned an error with the first create table statement. Any attempt
after that, even after reboot, to create a table failed.

Below is the postgresql.log file

-----

TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
Line: 446)

!(((bool) (UserId != 0))) (0) [Unpassender IOCTL (I/O-Control) für das
Gerät]
ERROR:  cannot create prod
ERROR:  DefineIndex: prod relation not found
TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
Line: 446)

!(((bool) (UserId != 0))) (0) [Unpassender IOCTL (I/O-Control) für das
Gerät]
ERROR:  cannot create prod
TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
Line: 446)

!(((bool) (UserId != 0))) (0) [Unpassender IOCTL (I/O-Control) für das
Gerät]
TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
Line: 446)

!(((bool) (UserId != 0))) (0) [Unpassender IOCTL (I/O-Control) für das
Gerät]
ERROR:  cannot create test2
ERROR:  test2: Table does not exist.
TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
Line: 446)

!(((bool) (UserId != 0))) (0) [Unpassender IOCTL (I/O-Control) für das
Gerät]


> --
> Bernd Tegge                  mailto:tegge@repas-aeg.de
> Tel: ++49-511-87449-12       repas AEG Automation GmbH
> Fax: ++49-511-87449-20       GS Hannover, Germany
>
>


Re: [NOVICE] newbie problem on creating table

From
Tom Lane
Date:
"Thomas Krebs" <thomas@krebs-haertl.de> writes:
> TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
> Line: 446)

I think what's causing this is that you can't use zero as a Postgres
userid.  Unfortunately createuser doesn't enforce that restriction;
I'll see about fixing that oversight for 7.1.

            regards, tom lane

Re: Re: [NOVICE] newbie problem on creating table

From
root
Date:
Tom Lane wrote:
>
> "Thomas Krebs" <thomas@krebs-haertl.de> writes:
> > TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
> > Line: 446)
>
> I think what's causing this is that you can't use zero as a Postgres
> userid.  Unfortunately createuser doesn't enforce that restriction;
> I'll see about fixing that oversight for 7.1.
>
>                         regards, tom lane

Sorry, but I'm think you are wrong.
I run Postgres (7.0.2) without any problems as userid 0.

pg_id says:

"root> pg_id
uid=0(root)"

Andreas Maus

Re: Re: [NOVICE] newbie problem on creating table

From
Peter Eisentraut
Date:
Tom Lane writes:

> "Thomas Krebs" <thomas@krebs-haertl.de> writes:
> > TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
> > Line: 446)
>
> I think what's causing this is that you can't use zero as a Postgres
> userid.  Unfortunately createuser doesn't enforce that restriction;
> I'll see about fixing that oversight for 7.1.

Create User does, but initdb doesn't.


--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden


Re: Re: [NOVICE] newbie problem on creating table

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
>>>> TRAP: Failed Assertion("!(((bool) (UserId != 0))):", File: "miscinit.c",
>>>> Line: 446)
>>
>> I think what's causing this is that you can't use zero as a Postgres
>> userid.  Unfortunately createuser doesn't enforce that restriction;
>> I'll see about fixing that oversight for 7.1.

> Create User does, but initdb doesn't.

Hmm.  But we have other defenses against the postgres superuser being
root.  I had assumed that the issue here was a non-superuser Postgres
account being created with zero userid...

            regards, tom lane