0

I have this table:

sapiens=# \d financiero.almac_solicitud_paz_salvo
                                                                  Table "financiero.almac_solicitud_paz_salvo"
         Column         |            Type             |                                                        Modifiers
------------------------+-----------------------------+-------------------------------------------------------------------------------------------------------------------------
 id_solicitud_paz_salvo | bigint                      | not null default nextval(('financiero.sq_financiero_almac_solicitud_paz_salvo_id_solicitud_paz_salvo'::text)::regclass)
 fec_solicitud          | timestamp(0) with time zone | not null
 id_persona             | integer                     | not null
 observacion            | text                        |
 id_estado              | smallint                    | not null
 id_tipo_paz_salvo      | smallint                    | not null
 id_usuario             | bigint                      |
Indexes:
    "pk_financiero_almac_solicitud_paz_salvo_id_solicitud_paz_salvo" PRIMARY KEY, btree (id_solicitud_paz_salvo)
Foreign-key constraints:
    "fk_financiero_almac_solicitud_paz_salvo_id_estado" FOREIGN KEY (id_estado) REFERENCES general.gener_estado(id_estado)
    "fk_financiero_almac_solicitud_paz_salvo_id_persona" FOREIGN KEY (id_persona) REFERENCES general.gener_persona(id_persona)
    "fk_financiero_almac_solicitud_paz_salvo_id_tipo_paz_salvo" FOREIGN KEY (id_tipo_paz_salvo) REFERENCES financiero.almac_tipo_paz_salvo(id_tipo_paz_salvo)

ureport is the user that have all permissions, also I set owner of the table

sapiens=# \dp financiero.almac_solicitud_paz_salvo
                                               Access privileges
   Schema   |           Name            | Type  |       Access privileges       | Column privileges | Policies
------------+---------------------------+-------+-------------------------------+-------------------+----------
 financiero | almac_solicitud_paz_salvo | table | ureport=arwdDxt/ureport      +|                   |

but when I want to insert a value, like this:

INSERT INTO financiero.almac_solicitud_paz_salvo
(fec_solicitud, id_persona, observacion, id_estado, id_tipo_paz_salvo, id_usuario)
VALUES('2022-09-19'::timestamp, 17962, '', 2, 3, 17);

I get:

ERROR:  permission denied for relation almac_tipo_paz_salvo
CONTEXT:  SQL statement "SELECT 1 FROM ONLY "financiero"."almac_tipo_paz_salvo" x WHERE "id_tipo_paz_salvo" OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x"

********** Error **********

ERROR: permission denied for relation almac_tipo_paz_salvo
SQL state: 42501
Context: SQL statement "SELECT 1 FROM ONLY "financiero"."almac_tipo_paz_salvo" x WHERE "id_tipo_paz_salvo" OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x"

why is happening that?, thanks for your kindly support

1 Answers1

0

You are using nexval sequence, so it should have USAGE privilege too: GRANT USAGE, SELECT ON SEQUENCE financiero.sq_financiero_almac_solicitud_paz_salvo_id_solicitud_paz_salvo TO sapiens; where sapiens is your role. Don't forget to choose the database before executing the privilege grant commands

Pauel
  • 11
  • 2