Proposal: new large object API

Started by Tatsuo Ishiiabout 18 years ago12 messageshackers
Jump to latest
#1Tatsuo Ishii
t-ishii@sra.co.jp

I would like to propose new large object client side API for 8.4.

Currently we have:

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

But we do not have an API which imports a large object specifying the
object id. This is inconvenient and inconsistent since we already have
lo_create() and lo_open() which allow to specify the large object id.

So I propose to add new API:

int lo_import_with_oid(PGconn *conn, Oid lobjId, const char *filename);

Another idea is changing the signature of lo_import:

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

which will be cleaner but break the backward compatibility.

Comments are welcome.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

#2Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tatsuo Ishii (#1)
Re: [HACKERS] Proposal: new large object API

Here is the proposed patches. If there's no objection, I will
commit(or Shall I wait for next "commit festa"?).

Note that I decide to use lo_import_with_oid, but the signature is
changed(the second and the third arguments are swapped because it
seems more natural).
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Show quoted text

I would like to propose new large object client side API for 8.4.

Currently we have:

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

But we do not have an API which imports a large object specifying the
object id. This is inconvenient and inconsistent since we already have
lo_create() and lo_open() which allow to specify the large object id.

So I propose to add new API:

int lo_import_with_oid(PGconn *conn, Oid lobjId, const char *filename);

Another idea is changing the signature of lo_import:

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

which will be cleaner but break the backward compatibility.

Comments are welcome.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

lob.patchtext/plain; charset=us-asciiDownload+55-8
#3Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tatsuo Ishii (#1)
Re: Proposal: new large object API

I have posted proposed patches to pgsql-patches.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Show quoted text

I would like to propose new large object client side API for 8.4.

Currently we have:

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

But we do not have an API which imports a large object specifying the
object id. This is inconvenient and inconsistent since we already have
lo_create() and lo_open() which allow to specify the large object id.

So I propose to add new API:

int lo_import_with_oid(PGconn *conn, Oid lobjId, const char *filename);

Another idea is changing the signature of lo_import:

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

which will be cleaner but break the backward compatibility.

Comments are welcome.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tatsuo Ishii (#2)
Re: [HACKERS] Proposal: new large object API

Tatsuo Ishii <ishii@postgresql.org> writes:

Here is the proposed patches. If there's no objection, I will
commit(or Shall I wait for next "commit festa"?).

No need to wait IMHO.

regards, tom lane

#5Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tatsuo Ishii (#3)
Re: Proposal: new large object API

lo_import_with_oid added.

Note that actually committed function signature is:

Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Show quoted text

I have posted proposed patches to pgsql-patches.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

I would like to propose new large object client side API for 8.4.

Currently we have:

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

But we do not have an API which imports a large object specifying the
object id. This is inconvenient and inconsistent since we already have
lo_create() and lo_open() which allow to specify the large object id.

So I propose to add new API:

int lo_import_with_oid(PGconn *conn, Oid lobjId, const char *filename);

Another idea is changing the signature of lo_import:

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

which will be cleaner but break the backward compatibility.

Comments are welcome.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tatsuo Ishii (#5)
Re: Proposal: new large object API

lo_import_with_oid added.

Note that actually committed function signature is:

Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
--
Tatsuo Ishii
SRA OSS, Inc. Japan

It seems I forgot about the serer side lo_import. Included are the
patches to add new form of lo_import which accepts the large object id
as the second argument.

Comments, objection?
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Attachments:

lobj.difftext/plain; charset=us-asciiDownload+25-11
#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tatsuo Ishii (#6)
Re: Proposal: new large object API

Tatsuo Ishii <ishii@postgresql.org> writes:

It seems I forgot about the serer side lo_import. Included are the
patches to add new form of lo_import which accepts the large object id
as the second argument.

Comments, objection?

Breaking the type_sanity test is not acceptable. Put in a second C
function.

regards, tom lane

#8Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tom Lane (#7)
Re: Proposal: new large object API

Tatsuo Ishii <ishii@postgresql.org> writes:

It seems I forgot about the serer side lo_import. Included are the
patches to add new form of lo_import which accepts the large object id
as the second argument.

Comments, objection?

Breaking the type_sanity test is not acceptable. Put in a second C
function.

Are you talking opr_sanity?

From what I read from opr_sanity.sql:

-- Look for uses of different type OIDs in the argument/result type fields
-- for different aliases of the same built-in function.
-- This indicates that the types are being presumed to be binary-equivalent,
-- or that the built-in function is prepared to deal with different types.
-- That's not wrong, necessarily, but we make lists of all the types being
-- so treated. Note that the expected output of this part of the test will
-- need to be modified whenever new pairs of types are made binary-equivalent,
-- or when new polymorphic built-in functions are added!
-- Note: ignore aggregate functions here, since they all point to the same
-- dummy built-in function.

What is evil with a polymorphic function?
--
Tatsuo Ishii
SRA OSS, Inc. Japan

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tatsuo Ishii (#8)
Re: Proposal: new large object API

Tatsuo Ishii <ishii@postgresql.org> writes:

Breaking the type_sanity test is not acceptable. Put in a second C
function.

Are you talking opr_sanity?

Sorry, yes, too little caffeine ...

What is evil with a polymorphic function?

(1) It's creating a false match --- your proposed entry in the opr_sanity
results has nothing at all to do with what the test is looking for.

(2) Refactoring to have two separate C functions will make the code
clearer, and not noticeably longer.

regards, tom lane

#10Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tom Lane (#9)
Re: Proposal: new large object API

What is evil with a polymorphic function?

(1) It's creating a false match --- your proposed entry in the opr_sanity
results has nothing at all to do with what the test is looking for.

(2) Refactoring to have two separate C functions will make the code
clearer, and not noticeably longer.

Ok, here is the revised patch.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Attachments:

lobj.difftext/plain; charset=us-asciiDownload+43-12
#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tatsuo Ishii (#10)
Re: Proposal: new large object API

Tatsuo Ishii <ishii@postgresql.org> writes:

Ok, here is the revised patch.

This looks sane to me, but I'd suggest leaving out the mention of 8.4
in the docs. Actually, I'm not sure you need a paragraph at all ---
just adding an example would be enough, I think.

SELECT lo_unlink(173454); -- deletes large object with OID 173454

  INSERT INTO image (name, raster)
      VALUES ('beautiful image', lo_import('/etc/motd'));
+ 
+ INSERT INTO image (name, raster)  -- same as above, but specify OID to use
+     VALUES ('beautiful image', lo_import('/etc/motd', 68583));

SELECT lo_export(image.raster, '/tmp/motd') FROM image
WHERE name = 'beautiful image';
</programlisting>

regards, tom lane

#12Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tom Lane (#11)
Re: Proposal: new large object API

Tatsuo Ishii <ishii@postgresql.org> writes:

Ok, here is the revised patch.

This looks sane to me, but I'd suggest leaving out the mention of 8.4
in the docs. Actually, I'm not sure you need a paragraph at all ---
just adding an example would be enough, I think.

SELECT lo_unlink(173454); -- deletes large object with OID 173454

INSERT INTO image (name, raster)
VALUES ('beautiful image', lo_import('/etc/motd'));
+ 
+ INSERT INTO image (name, raster)  -- same as above, but specify OID to use
+     VALUES ('beautiful image', lo_import('/etc/motd', 68583));

SELECT lo_export(image.raster, '/tmp/motd') FROM image
WHERE name = 'beautiful image';
</programlisting>

Thanks for the comment. I have committed with your suggested doc
changing.
--
Tatsuo Ishii
SRA OSS, Inc. Japan