D'Arcy J.M. Cain schrieb:
On Tue, 25 Nov 2008 14:36:47 -0500
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote:
When we insert into a table we attempt to read back the values so that
we know the values after rules, triggers and defaults kick in. If we
can't SELECT on the table we return None. The problem is that we do a
try/except after the get() which means that we could abort an ongoing
transaction. It would be better if we could know in advance that the
SELECT will fail to avoid this. We could also use "RETURNING *" if we
know we can SELECT thus avoiding the extra database query.
Does anyone know of a very simple method of determining if we have
SELECT privs on a table? I am inclined to just add a flag to the
insert method, default to True for backwards compatibility, that allows
the caller to control whether the dictionary should be filled in. This
would also allow them to reduce DB access when they just don't care
about the new values.
I haven't seen any response to this so I will go ahead with this change
tomorrow. I think that this is important to get in before the major
release is completed. Even though it is mostly backwards compatible I
don't want to introduce this change in a minor release.
Sorry, somehow I totally missed your posting. It's unusual that you have
insert but not select privilege, but you're right it can happen and
selecting will abort a transaction in this case. I agree that it's
probably best to add a flag for suppressing the select since I see no
easy way to check the select privilege in advance (since it could be
obtained/inherited in some obscure indirect ways). By default, the
select should be made (backward compatibility, and usually it works).
Using "returning *" will of course not solve this problem since it will
also fail if there is no select privilege, but it is more efficient, and
it will also work when the table has no oids. But unfortunately, the
returnig clause exists only in Postgres >= 8.2. Maybe this and other
method should get another parameter "use_oids" with a default value that
can be set or changed for the complete DB() instance.
-- Christoph
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql