Re: proposal: lob conversion functionality
От | Noah Misch |
---|---|
Тема | Re: proposal: lob conversion functionality |
Дата | |
Msg-id | 20131020235238.GA391151@tornado.leadboat.com обсуждение исходный текст |
Ответ на | Re: proposal: lob conversion functionality (Heikki Linnakangas <hlinnakangas@vmware.com>) |
Ответы |
Re: proposal: lob conversion functionality
Re: proposal: lob conversion functionality |
Список | pgsql-hackers |
On Mon, Sep 30, 2013 at 01:06:15PM +0300, Heikki Linnakangas wrote: > On 12.08.2013 21:08, Pavel Stehule wrote: >> 2013/8/10 Tom Lane<tgl@sss.pgh.pa.us>: >>> Pavel Stehule<pavel.stehule@gmail.com> writes: >>>> I found so there are no simple API for working with LO from PL without >>>> access to file system. >>> >>> What? See lo_open(), loread(), lowrite(), etc. >> >> yes, so there are three problems with these functions: >> >> a) probably (I didn't find) undocumented > > It's there, although it's a bit difficult to find by searching. See: > http://www.postgresql.org/docs/devel/static/lo-funcs.html. > > I don't actually agree with this phrase on that page: > >> The ones that are actually useful to call via SQL commands are >> lo_creat, lo_create, lo_unlink, lo_import, and lo_export > > Calling lo_open, loread and lowrite seems equally useful to me. > >> b) design with lo handler is little bit PL/pgSQL unfriendly. > > It's a bit awkward, I agree. All the other large object functions are named like lo*, so I think new ones should also be lo* rather than *_lo. One of the key benefits of large objects, compared to a bytea column in some table, is their efficiency when reading or writing only a subset of the object. However, the proposed functions only deal with the large object as a whole. We could easily fix that. Consider this list of new functions in their place: lo_create(oid, bytea) RETURNS oid -- new LO with content (similar to make_lo) lo_get(oid) RETURNS bytea -- read entire LO (same as load_lo) lo_get(oid, bigint, int) RETURNS bytea -- read from offset for length lo_put(oid, bigint, bytea) RETURNS void -- write data at offset Anything we do here effectively provides wrappers around the existing functions tailored toward the needs of libpq. A key outstanding question is whether doing so provides a compelling increment in usability. On the plus side, adding such functions resolves the weirdness of having a variety of database object that is easy to access from libpq but awkward to access from plain SQL. On the minus side, this could easily live as an extension module. I have not used the large object facility to any significant degree, but I generally feel this is helpful enough to justify core inclusion. Any other opinions on the general suitability or on the specifics of the API offered? Thanks, nm -- Noah Misch EnterpriseDB http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: