pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Binary large object processing problems
5+ messages / 3 participants
[nested] [flat]

* Binary large object processing problems
@ 2023-03-13 15:00 Raivo Rebane <raivore55@gmail.com>
  2023-03-13 15:26 ` Re: Binary large object processing problems Christoph Moench-Tegeder <cmt@burggraben.net>
  0 siblings, 1 reply; 5+ messages in thread

From: Raivo Rebane @ 2023-03-13 15:00 UTC (permalink / raw)
  To: pgsql-general

Hi

I am novice in pogres C API user and I want to store Binary Large Object
into database from C language program.

I am using following source :
Oid nloid = lo_import(conn, FileFUllName.c_str());

if (nloid == 0) {
std::cerr << "Error importing large object: " << PQerrorMessage(conn) <<
std::endl;
return -1;
}
else {
std::cout << "Large object imported successfully with fd " << nloid <<
std::endl;
}
And I seadely get 0 from lo_import.
I tried to create it previously an send oid to lo_impor_with_oid, but with
error

Can anybody help me find where is my mistake an what is working solution ?

Regards,
Raivo

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Binary large object processing problems
  2023-03-13 15:00 Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
@ 2023-03-13 15:26 ` Christoph Moench-Tegeder <cmt@burggraben.net>
  2023-03-13 15:54   ` Re: Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Christoph Moench-Tegeder @ 2023-03-13 15:26 UTC (permalink / raw)
  To: Raivo Rebane <raivore55@gmail.com>; +Cc: pgsql-general

## Raivo Rebane (raivore55@gmail.com):

> Can anybody help me find where is my mistake an what is working solution ?

The documentation clearly states "All large object manipulation using
these functions must take place within an SQL transaction block"
https://www.postgresql.org/docs/current/lo-interfaces.html
but I couldn't see anything of thank kind in your code.

Regards,
Christoph

-- 
Spare Space.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Binary large object processing problems
  2023-03-13 15:00 Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
  2023-03-13 15:26 ` Re: Binary large object processing problems Christoph Moench-Tegeder <cmt@burggraben.net>
@ 2023-03-13 15:54   ` Raivo Rebane <raivore55@gmail.com>
  2023-03-13 16:18     ` Re: Binary large object processing problems Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Raivo Rebane @ 2023-03-13 15:54 UTC (permalink / raw)
  To: Christoph Moench-Tegeder <cmt@burggraben.net>; +Cc: pgsql-general

Thank for answer, but I was also readed this manual and found there :
35.3.2. Importing a Large Object

To import an operating system file as a large object, call

Oid lo_import(PGconn *conn, const char *filename);

*filename* specifies the operating system name of the file to be imported
as a large object. The return value is the OID that was assigned to the new
large object, or InvalidOid (zero) on failure. Note that the file is read
by the client interface library, not by the server; so it must exist in the
client file system and be readable by the client application.
This file what I want to import is readable, I just tested it. So I
expected that lo_import doesn't work properly. It answers to my - invalid
large-object descriptor: 0
why ?

I try now by creating, opening, writing and closing sequence or are there
alternatives ?

Regards
Raivo



On Mon, Mar 13, 2023 at 5:26 PM Christoph Moench-Tegeder <cmt@burggraben.net>
wrote:

> ## Raivo Rebane (raivore55@gmail.com):
>
> > Can anybody help me find where is my mistake an what is working solution
> ?
>
> The documentation clearly states "All large object manipulation using
> these functions must take place within an SQL transaction block"
> https://www.postgresql.org/docs/current/lo-interfaces.html
> but I couldn't see anything of thank kind in your code.
>
> Regards,
> Christoph
>
> --
> Spare Space.
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Binary large object processing problems
  2023-03-13 15:00 Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
  2023-03-13 15:26 ` Re: Binary large object processing problems Christoph Moench-Tegeder <cmt@burggraben.net>
  2023-03-13 15:54   ` Re: Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
@ 2023-03-13 16:18     ` Tom Lane <tgl@sss.pgh.pa.us>
  2023-03-13 19:11       ` Re: Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2023-03-13 16:18 UTC (permalink / raw)
  To: Raivo Rebane <raivore55@gmail.com>; +Cc: Christoph Moench-Tegeder <cmt@burggraben.net>; pgsql-general

Raivo Rebane <raivore55@gmail.com> writes:
> Thank for answer, but I was also readed this manual and found there :
> 35.3.2. Importing a Large Object

You need to read the start of that section, which says

    All large object manipulation using these functions
    <emphasis>must</emphasis> take place within an SQL transaction block,

As Christoph said, you're responsible for supplying a BEGIN and COMMIT
around the call.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Binary large object processing problems
  2023-03-13 15:00 Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
  2023-03-13 15:26 ` Re: Binary large object processing problems Christoph Moench-Tegeder <cmt@burggraben.net>
  2023-03-13 15:54   ` Re: Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
  2023-03-13 16:18     ` Re: Binary large object processing problems Tom Lane <tgl@sss.pgh.pa.us>
@ 2023-03-13 19:11       ` Raivo Rebane <raivore55@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Raivo Rebane @ 2023-03-13 19:11 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Christoph Moench-Tegeder <cmt@burggraben.net>; pgsql-general

Ok, I will do that. ANd it works now in both way

Regards
Raivo

On Mon, Mar 13, 2023 at 6:18 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Raivo Rebane <raivore55@gmail.com> writes:
> > Thank for answer, but I was also readed this manual and found there :
> > 35.3.2. Importing a Large Object
>
> You need to read the start of that section, which says
>
>     All large object manipulation using these functions
>     <emphasis>must</emphasis> take place within an SQL transaction block,
>
> As Christoph said, you're responsible for supplying a BEGIN and COMMIT
> around the call.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2023-03-13 19:11 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 15:00 Binary large object processing problems Raivo Rebane <raivore55@gmail.com>
2023-03-13 15:26 ` Christoph Moench-Tegeder <cmt@burggraben.net>
2023-03-13 15:54   ` Raivo Rebane <raivore55@gmail.com>
2023-03-13 16:18     ` Tom Lane <tgl@sss.pgh.pa.us>
2023-03-13 19:11       ` Raivo Rebane <raivore55@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox