BLOB HOWTO??

Started by Olivier PRENANTover 25 years ago12 messageshackers
Jump to latest
#1Olivier PRENANT
ohp@pyrenet.fr

Hi,

Beeing very impressed by TOAST, I wonder how I can insert BLOB from a flat
file.

It seems quite easy with php; But how can I do it from psql??

TIA

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#2Olivier PRENANT
ohp@pyrenet.fr
In reply to: Olivier PRENANT (#1)
Re: BLOB HOWTO??

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Regards,
On Sun, 28 Jan 2001, Bruce Momjian wrote:

No way. We haven't written a binary interface to TOAST yet.

Hi,

Beeing very impressed by TOAST, I wonder how I can insert BLOB from a flat
file.

It seems quite easy with php; But how can I do it from psql??

TIA

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#3Martin A. Marques
martin@math.unl.edu.ar
In reply to: Olivier PRENANT (#1)
Re: BLOB HOWTO??

El Dom 28 Ene 2001 16:59, Olivier PRENANT escribi�:

Beeing very impressed by TOAST, I wonder how I can insert BLOB from a flat
file.

It seems quite easy with php; But how can I do it from psql??

I think you mean that it seems easy, because I haven't been able to
understand it (always talking about the php way).

I can't understand how the pg module of php knows where the large object
should be inserted. I mean, what if I have 2 large objects in the same
database (or even in the same table), where is the data inserted? There is no
place where someone tells php that the data in this variable should go in
this column that is of type blob.

TIA

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Mart�n Marqu�s email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

#4robert gravsjo
robert.gravsjo@nsgroup.net
In reply to: Olivier PRENANT (#1)
Re: BLOB HOWTO??

Maybe the functions lo_import and lo_export is what you're looking for?

regards,
robert gravsjo

Olivier PRENANT wrote:

Show quoted text

Hi,

Beeing very impressed by TOAST, I wonder how I can insert BLOB from a flat
file.

It seems quite easy with php; But how can I do it from psql??

TIA

#5Bruce Momjian
bruce@momjian.us
In reply to: Olivier PRENANT (#2)
Re: BLOB HOWTO??

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Lack of large object support for new TOAST columns is going to be a big
7.1 complaint. I was thinking of using the same functions as our large
object stuff, but remove the OID requirement.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#6Bruce Momjian
bruce@momjian.us
In reply to: Olivier PRENANT (#2)
Re: BLOB HOWTO??

Hi Bruce,

Any idea when it's due for??

When? Probably not until 7.2, which is a pain.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#7Olivier PRENANT
ohp@pyrenet.fr
In reply to: Bruce Momjian (#5)
Re: BLOB HOWTO??

Bruce,

Thanks for replying (I know you're a busy man :)

Any chance to have it backported to 7.1 or maybe in contrib???

This is a feature w all gonna lack (with GiST...)

Regards,
On Mon, 29 Jan 2001, Bruce Momjian wrote:

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Lack of large object support for new TOAST columns is going to be a big
7.1 complaint. I was thinking of using the same functions as our large
object stuff, but remove the OID requirement.

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#8Bruce Momjian
bruce@momjian.us
In reply to: Olivier PRENANT (#7)
Re: BLOB HOWTO??

I would LOVE to see it in a minor 7.1.X release.

Bruce,

Thanks for replying (I know you're a busy man :)

Any chance to have it backported to 7.1 or maybe in contrib???

This is a feature w all gonna lack (with GiST...)

Regards,
On Mon, 29 Jan 2001, Bruce Momjian wrote:

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Lack of large object support for new TOAST columns is going to be a big
7.1 complaint. I was thinking of using the same functions as our large
object stuff, but remove the OID requirement.

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#9Jan Wieck
JanWieck@Yahoo.com
In reply to: Bruce Momjian (#6)
Re: BLOB HOWTO??

Bruce Momjian wrote:

Hi Bruce,

Any idea when it's due for??

When? Probably not until 7.2, which is a pain.

We cannot use TOAST as is for BLOB/CLOB storage with a binary
IO interface over fastpath.

The reason is that you cannot force a column to be moved off
anyway and that the toast reference contains the original
objects size. Thus, opening a BLOB for writing would require
the reference in the main tuple to get updated and maybe
moving off the data first.

My plans for 7.2 are to use the toast table for storage, but
to build new data types with support hooks in the toaster for
it.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

#10Jan Wieck
JanWieck@Yahoo.com
In reply to: Bruce Momjian (#8)
Re: [SQL] Re: BLOB HOWTO??

Bruce Momjian wrote:

I would LOVE to see it in a minor 7.1.X release.

It's *feature* with alot necessary coding in core
functionality below heap access methods. Not a good candidate
for a bugfix release.

Jan

Bruce,

Thanks for replying (I know you're a busy man :)

Any chance to have it backported to 7.1 or maybe in contrib???

This is a feature w all gonna lack (with GiST...)

Regards,
On Mon, 29 Jan 2001, Bruce Momjian wrote:

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Lack of large object support for new TOAST columns is going to be a big
7.1 complaint. I was thinking of using the same functions as our large
object stuff, but remove the OID requirement.

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

--
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 853-3000
+  If your life is a hard drive,     |  830 Blythe Avenue
+  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

#11Jan Wieck
JanWieck@Yahoo.com
In reply to: Olivier PRENANT (#2)
Re: BLOB HOWTO??

Olivier PRENANT wrote:

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Something similar to the existing lo_...() functions.

Actually, someone should use the existing large objects to
deal with binary content. What has to be kept in mind is

1. You have to cleanup yourself - the existing large objects
aren't removed automatically if you delete a table row
referencing to the LO or drop the table.

2. The existing LOs don't have copy behaviour. So if you
reference to a LO from one table and do an INSERT ...
SELECT, just it's OID is copied, not the data (as it
should be IMHO).

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

#12Franck Martin
Franck@sopac.org
In reply to: Jan Wieck (#11)
Re: BLOB HOWTO??

I'm interested by TOAST, and I have asked several questions on the subject...
I haven't tested them yet...

First I thought that the type bytea allows storing of binary data, a BSOB
(Binary Small OBject).
Secondly that by using a binary cursor you have access to the raw data as it
is stored in the database, but not as it is presented in ASCII
Thridly we could use a funtion to retreive parts of columns, something like
mid(column,start,length)
Fourthly we may use the same function for storing data back.

Cheers...
Franck@sopac.org

Jan Wieck wrote:

Show quoted text

Olivier PRENANT wrote:

Hi Bruce,

Any idea when it's due for??
I've been thining about writing a user function; But I'll get stuck with
permission as a user function is running under the "postgres" or whatever
user instead of the calling user.

Also, what kind of binary interface are you thinking of??

Something similar to the existing lo_...() functions.

Actually, someone should use the existing large objects to
deal with binary content. What has to be kept in mind is

1. You have to cleanup yourself - the existing large objects
aren't removed automatically if you delete a table row
referencing to the LO or drop the table.

2. The existing LOs don't have copy behaviour. So if you
reference to a LO from one table and do an INSERT ...
SELECT, just it's OID is copied, not the data (as it
should be IMHO).

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com