Thread: Oid problem

Oid problem

From
Sky
Date:
Problem:
pg_loopen() unable to open PostgreSQL large object in...

Solution from another mailing list:
My blob oid was very big.
I had to cast to (float) the oid parameter of pg_loopen.

Question:
The oid is a type, isn't it?
I tried to use the oid in a function:

CREATE FUNCTION addfoto(character varying, oid)
RETURNS INTEGER
AS
 '
 BEGIN;
 INSERT INTO foto(filename, image) VALUES ( $1, $2 );
 COMMIT;
 SELECT 1 AS RESULT;
 '
LANGUAGE 'sql';

So, What can I do, and how, how can I "CAST" ??

--
Sky
sky AT sylvio .hu
Debian Group - Association of Hungarian Linux Users
Accessibility Project leader
gpg --keyserver hkp://pgp.mit.edu --recv-keys 314D1B0C
fingerprint = B211 E8C7 C6C2 18B2 9F30  ADF6 EDD9 A7FA 314D 1B0C


Re: Oid problem

From
Richard Huxton
Date:
On Thursday 08 April 2004 15:21, Sky wrote:
> Problem:
> pg_loopen() unable to open PostgreSQL large object in...
>
> Solution from another mailing list:
> My blob oid was very big.
> I had to cast to (float) the oid parameter of pg_loopen.

Sorry, bigger than what? Why float?

> Question:
> The oid is a type, isn't it?

Yes

> I tried to use the oid in a function:
>
> CREATE FUNCTION addfoto(character varying, oid)
> RETURNS INTEGER
> AS
>  '
>  BEGIN;
>  INSERT INTO foto(filename, image) VALUES ( $1, $2 );
>  COMMIT;
>  SELECT 1 AS RESULT;
>  '
> LANGUAGE 'sql';

Assuming the definition of "foto" is OK, looks fine from here.

> So, What can I do, and how, how can I "CAST" ??

Sorry - dont understand, but you can cast by:

SELECT foo::int8 ...
SELECT CAST(foo as int8) ...


Is the problem that you want to handle oid's (0 .. 4 billion) and you are
using int4 (-2 billion .. +2 billion). In which case int8 might be a better
choice than int4.

HTH
--
  Richard Huxton
  Archonet Ltd

Re: Oid problem

From
Sky
Date:
Richard Huxton írta:

>On Thursday 08 April 2004 15:21, Sky wrote:
>
>
>>Problem:
>>pg_loopen() unable to open PostgreSQL large object in...
>>
>>Solution from another mailing list:
>>My blob oid was very big.
>>I had to cast to (float) the oid parameter of pg_loopen.
>>
>>
>
>Sorry, bigger than what? Why float?
>
>
Watch these links:
http://archives.postgresql.org/pgsql-php/2003-09/msg00077.php
http://archives.postgresql.org/pgsql-php/2003-09/msg00079.php
I found it by google.

This error message is my problem:
pg_loopen() unable to open large object
/ PHP4 /

>>I tried to use the oid in a function:
>>
>>CREATE FUNCTION addfoto(character varying, oid)
>>RETURNS INTEGER
>>AS
>> '
>> BEGIN;
>> INSERT INTO foto(filename, image) VALUES ( $1, $2 );
>> COMMIT;
>> SELECT 1 AS RESULT;
>> '
>>LANGUAGE 'sql';
>>
>>
>
>Assuming the definition of "foto" is OK, looks fine from here.
>
>
>
>>So, What can I do, and how, how can I "CAST" ??
>>
>>
>
>Sorry - dont understand, but you can cast by:
>
Watch the links above.

>
>SELECT foo::int8 ...
>SELECT CAST(foo as int8) ...
>
>
>Is the problem that you want to handle oid's (0 .. 4 billion) and you are
>using int4 (-2 billion .. +2 billion). In which case int8 might be a better
>choice than int4.
>
Sorry but I don't understand, where do I use int4 ??
Here is my table definition too:

CREATE TABLE foto(
  filename CHARACTER VARYING,
  image OID
  );

>
>HTH
>
>

Many thanks!

--
Sky
sky AT sylvio .hu
Debian Group - Association of Hungarian Linux Users
Accessibility Project leader
gpg --keyserver hkp://pgp.mit.edu --recv-keys 314D1B0C
fingerprint = B211 E8C7 C6C2 18B2 9F30  ADF6 EDD9 A7FA 314D 1B0C