PostgreSQL - Unidirection

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
eduardomendes
Posts: 28
Joined: Wed 24 Feb 2010 14:08

PostgreSQL - Unidirection

Post by eduardomendes » Fri 04 May 2012 17:19

In PostgreSQL i work with group permission in the connection. After connected, i execute "SET ROLE <USER_GROUP>". It's working perfect, the current user handles the objects in name of the group.

But... if i work with TUnitable or TUniquery with option "Unidirection=True" show an error that the user hasn´t permission to manipulate the object (table, schema, etc...). It's occurs because a new connection is created with the option Unidirection set as True.

How do I set the connection in this component or create a connection inheriting the configurations of another one?

Thanks in advance,

Eduardo Mendes Camar

ROD
Devart Team
Posts: 23
Joined: Mon 07 May 2012 09:09

Re: PostgreSQL - Unidirection

Post by ROD » Tue 08 May 2012 09:04

Hello, Eduardo!

If there is no active transaction, PgDAC opens an additional internal connection and starts transaction on this connection, which is not rewarded (execute "SET ROLE <USER_GROUP>) with new privileges.

But it has a solution. You can use the "Unidirectional=True" option to manipulate data.

Use the TPgDataSetOptions.CursorWithHold option to open the query in the FetchAll=False mode without any transaction.

When CursorWithHold is True, PgDAC uses the DECLARE CURSOR ... WITH HOLD statement to open the query. In this case no active transaction is required but this may take additional server resources.

P.S.: Or start a transaction yourself.

Post Reply