Обсуждение: Getting oid of 0 when doing LargeObjectManager.create()
I am getting a oid value of 0 returned when I do a LargeObjectManager.create(). This tells me that I can't create a large object. What reasons would cause this? and what I can do to solve the problems.
thanks
Chris White
This works for me: // All LargeObject API calls must be within a transaction connection.setAutoCommit(false); // create a new large object int oid = largeObjectManager.create(LargeObjectManager.READ | LargeObjectManager.WRITE); You need to be in a transaction, and you need to create with flags. On Wed, Jul 10, 2002 at 04:49:39PM -0700, Chris White wrote: > I am getting a oid value of 0 returned when I do a > LargeObjectManager.create(). This tells me that I can't create a large > object. What reasons would cause this? and what I can do to solve the > problems. > > thanks > Chris White -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com
This is exactly what I have done and I get valid oids returned, but I intermittently get an oid of 0. It is these that concern me. -----Original Message----- From: Dror Matalon [mailto:dror@zapatec.com] Sent: Wednesday, July 10, 2002 5:18 PM To: Chris White Cc: pgsql-jdbc@postgresql.org Subject: Re: [JDBC] Getting oid of 0 when doing LargeObjectManager.create() This works for me: // All LargeObject API calls must be within a transaction connection.setAutoCommit(false); // create a new large object int oid = largeObjectManager.create(LargeObjectManager.READ | LargeObjectManager.WRITE); You need to be in a transaction, and you need to create with flags. On Wed, Jul 10, 2002 at 04:49:39PM -0700, Chris White wrote: > I am getting a oid value of 0 returned when I do a > LargeObjectManager.create(). This tells me that I can't create a large > object. What reasons would cause this? and what I can do to solve the > problems. > > thanks > Chris White -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com
Chris, What version are you using? I just fixed a bug last week on this, so have you tried the latest development driver build from jdbc.postgresql.org? If this isn't related to the bug I fixed then it is likely related to the fact that you are trying to use a large object after having done a commit. In order to use large objects you must run with autocommit turned off since the large object pointer becomes invalid on a commit. thanks, --Barry Chris White wrote: > I am getting a oid value of 0 returned when I do a > LargeObjectManager.create(). This tells me that I can't create a large > object. What reasons would cause this? and what I can do to solve the > problems. > > thanks > Chris White
I am using jdbc7.2dev-1.2.jar. So I will try the latest development version. I do have auto commit turned off, but don't I have to do a commit once I have written and closed the Large Object in order for it to retained in the database? Also, I thought I needed to store the oid in the database so I could read/delete the Large object later, so how come it becomes invalid on a commit, which I use all the time after doing inserts and updates? Chris -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Barry Lind Sent: Wednesday, July 10, 2002 8:57 PM To: cjwhite@cisco.com Cc: pgsql-jdbc@postgresql.org Subject: Re: [JDBC] Getting oid of 0 when doing LargeObjectManager.create() Chris, What version are you using? I just fixed a bug last week on this, so have you tried the latest development driver build from jdbc.postgresql.org? If this isn't related to the bug I fixed then it is likely related to the fact that you are trying to use a large object after having done a commit. In order to use large objects you must run with autocommit turned off since the large object pointer becomes invalid on a commit. thanks, --Barry Chris White wrote: > I am getting a oid value of 0 returned when I do a > LargeObjectManager.create(). This tells me that I can't create a large > object. What reasons would cause this? and what I can do to solve the > problems. > > thanks > Chris White ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
Chris, Sorry I wasn't very clear in my first response. It isn't the OID that becomes invalid, it is the FastPath function reference used by the jdbc LargeObject implementation that becomes invalid at the end of a transaction. Once you get an OID insert it and commit you are fine. But getting back an OID of 0 is an indication the the underlying code is using a reference that is no longer valid in the current transaction. The bug I recently fixed occured when garbage collection ran after a commit had occurred. The LargeObject instance had a finalize() method that was called during garbage collection that tried to close the LargeObject using the reference it had. However since a commit already had happened the reference was no longer valid and thus using it to close the LargeObject caused an error. Because this was garbage collection related it would happen seemingly randomly (i.e. whenever gc ran). thanks, --Barry Chris White wrote: >I am using jdbc7.2dev-1.2.jar. So I will try the latest development version. > >I do have auto commit turned off, but don't I have to do a commit once I >have written and closed the Large Object in order for it to retained in the >database? Also, I thought I needed to store the oid in the database so I >could read/delete the Large object later, so how come it becomes invalid on >a commit, which I use all the time after doing inserts and updates? > >Chris > >-----Original Message----- >From: pgsql-jdbc-owner@postgresql.org >[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Barry Lind >Sent: Wednesday, July 10, 2002 8:57 PM >To: cjwhite@cisco.com >Cc: pgsql-jdbc@postgresql.org >Subject: Re: [JDBC] Getting oid of 0 when doing >LargeObjectManager.create() > > >Chris, > >What version are you using? I just fixed a bug last week on this, so >have you tried the latest development driver build from jdbc.postgresql.org? > >If this isn't related to the bug I fixed then it is likely related to >the fact that you are trying to use a large object after having done a >commit. In order to use large objects you must run with autocommit >turned off since the large object pointer becomes invalid on a commit. > >thanks, >--Barry > >Chris White wrote: > > > >>I am getting a oid value of 0 returned when I do a >>LargeObjectManager.create(). This tells me that I can't create a large >>object. What reasons would cause this? and what I can do to solve the >>problems. >> >>thanks >>Chris White >> >> > > > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > > >