Thread: error "permission denied for relation" on postgresql 9.0.6 during CREATE TABLE

error "permission denied for relation" on postgresql 9.0.6 during CREATE TABLE

From
Giuseppe Sacco
Date:
Hi,
I get this error while executing a CREATE TABLE statement.
This is my CREATE statement:

CREATE TABLE agenzia.BarcodeByDocumentInfo (
        docId VARCHAR(17) NOT NULL,
        defaultOp VARCHAR(10) NOT NULL DEFAULT 'Append',
        CONSTRAINT BcByDocInfo_pk PRIMARY KEY (docId),
        CONSTRAINT BcByDoc_defOp_ck
             CHECK ( defaultOp = 'Append' OR defaultOp = 'Overwrite' ),
        CONSTRAINT BcByDoc_docId_fk FOREIGN KEY(docId)
             REFERENCES agenzia.Documents(docId)
);

When I execute it on postgresql 9.0.6 I get this messages:

NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bcbydocinfo_pk" for table "barcodebydocumentinfo"
ERROR:  permission denied for relation documents

So, if I understand correctly the error message, this is a missing
permission a table "documents" that is only used in my CREATE STATEMENT
on a FOREIGN KEY constraint.

This is table "documents":

neos=> \d agenzia.documents
                         Table "agenzia.documents"
     Column     |         Type          |
Modifiers
----------------+-----------------------+----------------------------------
 docid          | character varying(17) | not null
 description    | character varying(45) |
 protid         | character varying(50) |
 iscommondata   | character(5)          | not null default
'FALSE'::bpchar
 tobecrypted    | character(5)          | not null default
'FALSE'::bpchar
 islistofvalues | character(5)          | not null default
'FALSE'::bpchar
 isfulltext     | character(5)          | not null default
'FALSE'::bpchar
Indexes:
[...]
Check constraints:
[...]
Foreign-key constraints:
[...]
Referenced by:
[...]

I am owner of table "documents":

neos=> \dt agenzia.documents
          List of relations
 Schema  |   Name    | Type  | Owner
---------+-----------+-------+-------
 agenzia | documents | table | neos
(1 row)

I read the documentation about postgresql 9.0 and it seems the error
message is about permission "x". As you may see "x" is among my
permissions:

neos=> \dp agenzia.documents
                               Access privileges
 Schema  |   Name    | Type  |  Access privileges   | Column access privileges
---------+-----------+-------+----------------------+--------------------------
 agenzia | documents | table | neos=arwdDxt/neos   +|
         |           |       | agenzia_r=arwdt/neos |
(1 row)

Do you have suggestion about this problem?

I thank you very much,
Giuseppe



On Friday, January 27, 2012 8:25:56 am Giuseppe Sacco wrote:
> Hi,
> I get this error while executing a CREATE TABLE statement.
> This is my CREATE statement:
>
> CREATE TABLE agenzia.BarcodeByDocumentInfo (
>         docId VARCHAR(17) NOT NULL,
>         defaultOp VARCHAR(10) NOT NULL DEFAULT 'Append',
>         CONSTRAINT BcByDocInfo_pk PRIMARY KEY (docId),
>         CONSTRAINT BcByDoc_defOp_ck
>              CHECK ( defaultOp = 'Append' OR defaultOp = 'Overwrite' ),
>         CONSTRAINT BcByDoc_docId_fk FOREIGN KEY(docId)
>              REFERENCES agenzia.Documents(docId)
> );
>
> When I execute it on postgresql 9.0.6 I get this messages:
>
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
> "bcbydocinfo_pk" for table "barcodebydocumentinfo" ERROR:  permission
> denied for relation documents
>

>
> I am owner of table "documents":
>
> neos=> \dt agenzia.documents
>           List of relations
>  Schema  |   Name    | Type  | Owner
> ---------+-----------+-------+-------
>  agenzia | documents | table | neos
> (1 row)
>
> I read the documentation about postgresql 9.0 and it seems the error
> message is about permission "x". As you may see "x" is among my
> permissions:

The x(REFERENCES) permission needs to be on both tables for the owner of the
referenced table(noes).

This is what I got from the thread below:

http://archives.postgresql.org/pgsql-general/2011-02/msg00957.php

So see what your permissions are on for table barcodebydocumentinfo. Also who
the owner of barcodebydocumentinfo is.

>
> neos=> \dp agenzia.documents
>                                Access privileges
>  Schema  |   Name    | Type  |  Access privileges   | Column access
> privileges
> ---------+-----------+-------+----------------------+---------------------
> ----- agenzia | documents | table | neos=arwdDxt/neos   +|
>
>          |           |       | agenzia_r=arwdt/neos |
>
> (1 row)
>
> Do you have suggestion about this problem?
>
> I thank you very much,
> Giuseppe

--
Adrian Klaver
adrian.klaver@gmail.com

Re: error "permission denied for relation" on postgresql 9.0.6 during CREATE TABLE

From
Giuseppe Sacco
Date:
Il giorno ven, 27/01/2012 alle 08.54 -0800, Adrian Klaver ha scritto:
> On Friday, January 27, 2012 8:25:56 am Giuseppe Sacco wrote:
[...]
> > I am owner of table "documents":
> >
> > neos=> \dt agenzia.documents
> >           List of relations
> >  Schema  |   Name    | Type  | Owner
> > ---------+-----------+-------+-------
> >  agenzia | documents | table | neos
> > (1 row)
> >
> > I read the documentation about postgresql 9.0 and it seems the error
> > message is about permission "x". As you may see "x" is among my
> > permissions:
>
> The x(REFERENCES) permission needs to be on both tables for the owner of the
> referenced table(noes).

Well, I am owner of the referenced table. I cannot check anything on the
barcodebydocumentinfo table since it is the one I am trying to CREATE.

Thanks,
Giuseppe


Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org> writes:
> I get this error while executing a CREATE TABLE statement.
> This is my CREATE statement:

> CREATE TABLE agenzia.BarcodeByDocumentInfo (
>         docId VARCHAR(17) NOT NULL,
>         defaultOp VARCHAR(10) NOT NULL DEFAULT 'Append',
>         CONSTRAINT BcByDocInfo_pk PRIMARY KEY (docId),
>         CONSTRAINT BcByDoc_defOp_ck
>              CHECK ( defaultOp = 'Append' OR defaultOp = 'Overwrite' ),
>         CONSTRAINT BcByDoc_docId_fk FOREIGN KEY(docId)
>              REFERENCES agenzia.Documents(docId)
> );

> When I execute it on postgresql 9.0.6 I get this messages:

> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bcbydocinfo_pk" for table "barcodebydocumentinfo"
> ERROR:  permission denied for relation documents

This example works for me.  Are you sure you are executing the CREATE
TABLE command as user "neos"?

            regards, tom lane

Re: error "permission denied for relation" on postgresql 9.0.6 during CREATE TABLE

From
Giuseppe Sacco
Date:
Il giorno ven, 27/01/2012 alle 12.38 -0500, Tom Lane ha scritto:
> > NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bcbydocinfo_pk" for table "barcodebydocumentinfo"
> > ERROR:  permission denied for relation documents
>
> This example works for me.  Are you sure you are executing the CREATE
> TABLE command as user "neos"?

Until ten minutes ago I was sure about it, but I was wrong. I was
writing to the list about it when I read your message.

Sorry for the noise.

Thank,
Giuseppe