pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
large objects and pg 7.3.x
10+ messages / 5 participants
[nested] [flat]

* large objects and pg 7.3.x
@ 2003-08-19 00:31  Andre Felipe Machado <andremachado@techforce.com.br>
  0 siblings, 1 reply; 10+ messages in thread

From: Andre Felipe Machado @ 2003-08-19 00:31 UTC (permalink / raw)
  To: pgsql-odbc

Hello,
I am trying to use OpenOffice 1.1RC2 and its forms to store images (large 
objects) into a postgresql 7.3.2 connected through psqlodbc when at windows 
and unixodbc when at linux.
Since pg 7.3.0, the prescribed workaround to create a new type "lo" does not 
work anymore.
I already tested the semi-official postgresql-contrib package that contains a 
"lo" implementation in c and sql.
It works nicely.
I can store and extract images (jpeg, gif) from database and the trigger 
launches db cleanup when deleting.

Reading the code, with my limited skill, I found the following files 
containing large objects code in the psqlodbc:
connection.c
convert.c
execute.c
pgtypes.c
statements.c
And their companion h files.

Please, is this possible to modify psqlodbc to use the semi-official "lo" 
implementation?
Regards.
Andre Felipe





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

* Re: large objects and pg 7.3.x
@ 2003-08-19 01:22  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andre Felipe Machado <andremachado@techforce.com.br>
  0 siblings, 2 replies; 10+ messages in thread

From: Tom Lane @ 2003-08-19 01:22 UTC (permalink / raw)
  To: andremachado@techforce.com.br; +Cc: pgsql-odbc

Andre Felipe Machado <andremachado@techforce.com.br> writes:
> Since pg 7.3.0, the prescribed workaround to create a new type "lo" does not 
> work anymore.

I think this is just a matter of obsolete documentation --- if you can
point to where it still says to use a CREATE TYPE hack, we can fix it.
The easy way to define "lo" now is just as a domain over oid:
	CREATE DOMAIN lo AS oid;

> I already tested the semi-official postgresql-contrib package that contains a
> "lo" implementation in c and sql.

However, if you want the cleanup semantics that the contrib package
offers, by all means use it instead.  I don't believe ODBC should care
which way you've defined "lo".

			regards, tom lane



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

* Re: large objects and pg 7.3.x
@ 2003-08-19 04:02  Hiroshi Inoue <Inoue@tpf.co.jp>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 10+ messages in thread

From: Hiroshi Inoue @ 2003-08-19 04:02 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: andremachado@techforce.com.br; pgsql-odbc

Tom Lane wrote:
> 
> Andre Felipe Machado <andremachado@techforce.com.br> writes:
> > Since pg 7.3.0, the prescribed workaround to create a new type "lo" does not
> > work anymore.
> 
> I think this is just a matter of obsolete documentation ---

Maybe pointing to contrib/lo is preferable. However, few people
take care of contrib/lo and it seems easily broken.
PostgreSQL has never supported LO properly and I can't recommend
anything for continuous LO use. 

> if you can
> point to where it still says to use a CREATE TYPE hack, we can fix it.
> The easy way to define "lo" now is just as a domain over oid:
>         CREATE DOMAIN lo AS oid;

I'm suspicious if it still works even in 7.4. 
Can we find the oid of the domain "lo" in the row description
message from the backend ? 
 
regards,
Hiroshi Inoue
	http://www.geocities.jp/inocchichichi/psqlodbc/



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

* Re: large objects and pg 7.3.x
@ 2003-08-19 04:08  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Hiroshi Inoue <Inoue@tpf.co.jp>
  0 siblings, 1 reply; 10+ messages in thread

From: Tom Lane @ 2003-08-19 04:08 UTC (permalink / raw)
  To: Hiroshi Inoue <Inoue@tpf.co.jp>; +Cc: andremachado@techforce.com.br; pgsql-odbc

Hiroshi Inoue <Inoue@tpf.co.jp> writes:
> Tom Lane wrote:
>> The easy way to define "lo" now is just as a domain over oid:
>> CREATE DOMAIN lo AS oid;

> I'm suspicious if it still works even in 7.4. 
> Can we find the oid of the domain "lo" in the row description
> message from the backend ? 

Hm, I think the column type will be reported as "oid", because the
JDBC crowd argued that they didn't want to know about domains.
Is that a problem for ODBC?

			regards, tom lane



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

* Re: large objects and pg 7.3.x
@ 2003-08-19 04:44  Hiroshi Inoue <Inoue@tpf.co.jp>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 10+ messages in thread

From: Hiroshi Inoue @ 2003-08-19 04:44 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: andremachado@techforce.com.br; pgsql-odbc

Tom Lane wrote:
> 
> Hiroshi Inoue <Inoue@tpf.co.jp> writes:
> > Tom Lane wrote:
> >> The easy way to define "lo" now is just as a domain over oid:
> >> CREATE DOMAIN lo AS oid;
> 
> > I'm suspicious if it still works even in 7.4.
> > Can we find the oid of the domain "lo" in the row description
> > message from the backend ?
> 
> Hm, I think the column type will be reported as "oid", because the
> JDBC crowd argued that they didn't want to know about domains.
> Is that a problem for ODBC?

Probably no except the "lo" domain case.
Psqlodbc would be able to convert PG types to corresponding
ODBC types using known base types.

regards,
Hiroshi Inoue
	http://www.geocities.jp/inocchichichi/psqlodbc/



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

* Re: large objects and pg 7.3.x
@ 2003-08-19 10:45  Andre Felipe Machado <andremachado@techforce.com.br>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 10+ messages in thread

From: Andre Felipe Machado @ 2003-08-19 10:45 UTC (permalink / raw)
  To: pgsql-odbc


Hello,
Many thanks for your answer.

>
> I think this is just a matter of obsolete documentation --- if you can
> point to where it still says to use a CREATE TYPE hack, we can fix it.

http://gborg.postgresql.org/project/psqlodbc/faq/faq.php?faq_id=52


> The easy way to define "lo" now is just as a domain over oid:
> 	CREATE DOMAIN lo AS oid;

I already tested this idea before contacting the list. Unfortunately it does 
not work also. At least from OpenOffice 1.1rc2 connected by psqlodbc or 
unixodbc.
Also without success, tested the idea from Hiroshi Saito 
(http://archives.postgresql.org/pgadmin-hackers/2003-06/msg00359.php )
Both suggestions did not work.
Using postgresql-contrib "lo", I was able to insert and extract images using 
sql commands from inside psql.
When inserted this way, psqlodbc can DISPLAY images at OpenOffice.org forms. 
But can not insert new ones.

>
> However, if you want the cleanup semantics that the contrib package
> offers, by all means use it instead.  I don't believe ODBC should care
> which way you've defined "lo".
>
> 			regards, tom lane

Please, could you give some guidance, or point to some psqlodbc devel 
documentation in order to modify the code?
I have very limited desktop programming coding skill , but will try to get it 
working, without disrupting whole code.
The contrib lo cleanup code seems to be context sensitive, adapting to the 
variable details.
The contrib lo definition does not use "passedbyvalue", but use a pointer 
instead. It uses variable length output too.
Regards.
Andre Felipe




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

* Re: large objects and pg 7.3.x
@ 2003-08-19 14:55  Hiroshi Inoue <inoue@tpf.co.jp>
  parent: Andre Felipe Machado <andremachado@techforce.com.br>
  0 siblings, 1 reply; 10+ messages in thread

From: Hiroshi Inoue @ 2003-08-19 14:55 UTC (permalink / raw)
  To: 'Andre Felipe Machado' <andremachado@techforce.com.br>; +Cc: pgsql-odbc



> -----Original Message-----
> From: Andre Felipe Machado

> Using postgresql-contrib "lo", I was able to insert and extract images
using 
> sql commands from inside psql.
> When inserted this way, psqlodbc can DISPLAY images at OpenOffice.org
forms.
 
> But can not insert new ones.

Could you give us more details about "can not insert new ones",  i.e.
error messages ?

regards,
Hiroshi Inoue





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

* Re: large objects and pg 7.3.x
@ 2003-08-19 15:16  Andre Felipe Machado <andremachado@techforce.com.br>
  parent: Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 10+ messages in thread

From: Andre Felipe Machado @ 2003-08-19 15:16 UTC (permalink / raw)
  To: pgsql-odbc; +Cc: Hiroshi Inoue <inoue@tpf.co.jp>

Hello,
Thanks for your message.
I am not sure if this mail list server allow attachments.
attached to this message is a compressed sql log session from unixodbc 2.2.6.
A very elementary table was created. Only an int ID and an image column.
The postgresql psql tool can insert an image (can also extracts it) using 
direct sql commands. And OpenOffice can display it at the form.
When trying to save a new record, containing a new image, the program 
complains.
The error message is reproduced at near the end of the attached sql log file.
I hope this help.
Regards.
Andre Felipe



>
> > But can not insert new ones.
>
> Could you give us more details about "can not insert new ones",  i.e.
> error messages ?
>
> regards,
> Hiroshi Inoue

Attachments:

  sql_log_unixodbc_bug_inserting_large_objects.tar.gz (application/x-tgz, 16.8K) download

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

* Re: large objects and pg 7.3.x
@ 2003-08-19 23:25  Julie May <julie@ccorb.com>
  parent: Andre Felipe Machado <andremachado@techforce.com.br>
  0 siblings, 1 reply; 10+ messages in thread

From: Julie May @ 2003-08-19 23:25 UTC (permalink / raw)
  To: Andre Felipe Machado <andremachado@techforce.com.br>; pgsql-odbc

I am able to insert an image into postgresql using the psqlodbc driver. I
created the lo type using the files in the contrib directory. I was never
able to make the lo_manage() function work. Instead I created my own
functions and used triggers to execute them. I only needed the functions for
deleting and updating records. I haven't had any problems inserting. When
the lo type was created it should have created the following functions :
lo(oid)
lo_in(cstring)
lo_manage()
lo_oid(public.lo)
lo_out(public.lo)
oid(public.lo)

I hope that is somewhat helpfull.

Julie

<snip>
----- Original Message -----
From: "Andre Felipe Machado" <andremachado@techforce.com.br>
> The postgresql psql tool can insert an image (can also extracts it) using
> direct sql commands. And OpenOffice can display it at the form.
> When trying to save a new record, containing a new image, the program
> complains.
> The error message is reproduced at near the end of the attached sql log
file.
> I hope this help.
> Regards.
> Andre Felipe

</snip>




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

* Re: large objects and pg 7.3.x
@ 2003-08-20 11:23  Andre Felipe Machado <andremachado@techforce.com.br>
  parent: Julie May <julie@ccorb.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Andre Felipe Machado @ 2003-08-20 11:23 UTC (permalink / raw)
  To: pgsql-odbc

Hello, Julie
Many thanks for your message.
Any hint will be helpfull.
I verified again and the functions are there.
Also, I created a trigger for the lo_manage() function, following exactly the 
instructions of the contrib/lo readme.
Could you tell how do you successfully insert images using the psqlodbc?

I guess the problem is that openoffice creates a prepared sql and parses the 
lo "by value", as it expects lo to be as a "normal" blob type.
The domain approach should solve this issue.
But this theory should be confirmed by another experiment:
I created a clean db, then declared lo as a domain (following mr. Lane 
suggestion) and tried to insert an image.
OpenOffice issued the following error:
Error inserting the new record

SQL Status 01000
Error code -1

[unixODBC]Error while executing the query (non-fatal);
ERROR:  oidin: error in 
"GIF87a\216\000\076\000\367\000\000\000\000\000\000\000\100\000\000\200\000\000ÿ\000 
\000\000 \100\000 \200\000 
ÿ\000\100\000\000\100\100\000\100\200\000\100ÿ\000\140\000\000\140\100\000\140\200\000\140ÿ\000\200\000\000\200\100\000\200\200\000\200ÿ\000\240\000\000\240\100\000\240\200\000\240ÿ\000À\000\000À\100\000À\200\000Àÿ\000ÿ\000\000ÿ\100\000ÿ\200\000ÿÿ 
\000\000 \000\100 \000\200 \000ÿ  \000  \100  \200  ÿ \100\000 \100\100


The error is very similar to the one issued when using another db with the 
postgresql/contrib/lo functions.
It seems that the image is being escaped to octal before parsing to the 
driver, as it should be for use with bytea pg type.

The previously sent sql log session file was of any help?
Regards.
Andre Felipe




Em Terça 19 Agosto 2003 20:25, você escreveu:
> I am able to insert an image into postgresql using the psqlodbc driver. I
> created the lo type using the files in the contrib directory. I was never
> able to make the lo_manage() function work. Instead I created my own
> functions and used triggers to execute them. I only needed the functions
> for deleting and updating records. I haven't had any problems inserting.
> When the lo type was created it should have created the following functions
> : lo(oid)
> lo_in(cstring)
> lo_manage()
> lo_oid(public.lo)
> lo_out(public.lo)
> oid(public.lo)
>
> I hope that is somewhat helpfull.
>
> Julie
>
> <snip>
> ----- Original Message -----
> From: "Andre Felipe Machado" <andremachado@techforce.com.br>
>
> > The postgresql psql tool can insert an image (can also extracts it) using
> > direct sql commands. And OpenOffice can display it at the form.
> > When trying to save a new record, containing a new image, the program
> > complains.
> > The error message is reproduced at near the end of the attached sql log
>
> file.
>
> > I hope this help.
> > Regards.
> > Andre Felipe
>
> </snip>




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


end of thread, other threads:[~2003-08-20 11:23 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-19 00:31 large objects and pg 7.3.x Andre Felipe Machado <andremachado@techforce.com.br>
2003-08-19 01:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-08-19 04:02   ` Hiroshi Inoue <Inoue@tpf.co.jp>
2003-08-19 04:08     ` Tom Lane <tgl@sss.pgh.pa.us>
2003-08-19 04:44       ` Hiroshi Inoue <Inoue@tpf.co.jp>
2003-08-19 10:45   ` Andre Felipe Machado <andremachado@techforce.com.br>
2003-08-19 14:55     ` Hiroshi Inoue <inoue@tpf.co.jp>
2003-08-19 15:16       ` Andre Felipe Machado <andremachado@techforce.com.br>
2003-08-19 23:25         ` Julie May <julie@ccorb.com>
2003-08-20 11:23           ` Andre Felipe Machado <andremachado@techforce.com.br>

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