[SQL] How to store Byte strings into a table.

2010-07-04 Thread Trinath Somanchi
Hi,

How can I store Byte strings into a postgresql database.

Is there any special command to store it. How will be the sql query.

I have gone through this
http://www.postgresql.org/docs/8.4/static/datatype-binary.html but have not
seen any example for how to insert data into such a field.

Please help me in this regard.


-- 
Regards,
--
Trinath Somanchi,


Re: [SQL]

2010-07-04 Thread silly sad

On 07/05/10 09:57,  wrote:

Hi,

How can I store Byte strings into a postgresql database.
Is there any special command to store it. How will be the sql query.


there is only '\0' byte incapable to input-output.
so u have to have it escaped at all costs _AND NOTHING MORE_.

"escaped" doesn't mean "prefixed with backslash"
("backslash method" cause a zero-byte to pass SQL parser an to be 
actually stored, BUT
the output will be corrupted, because of this zero-byte will be actually 
output)


You may use the BYTEA type
(similar to the TEXT but with different input-output) which effectively 
escapes zero-byte and a lot of other completely harmless bytes as well 
(probably to reach a better overhead)


Or you may introduce a pair of your own escape rules.

Unfortunately there are no way to influence The Pg Developers to get rid 
of the nasty god damned CSTRING off the input/output operations.



--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL]

2010-07-04 Thread Trinath Somanchi
Hi,

I'm new in using BLOB. How will the insert for storing very large byte
strings into a column  of data type Blob.

On Mon, Jul 5, 2010 at 11:42 AM, silly sad  wrote:

> On 07/05/10 09:57,  wrote:
>
>> Hi,
>>
>> How can I store Byte strings into a postgresql database.
>> Is there any special command to store it. How will be the sql query.
>>
>
> there is only '\0' byte incapable to input-output.
> so u have to have it escaped at all costs _AND NOTHING MORE_.
>
> "escaped" doesn't mean "prefixed with backslash"
> ("backslash method" cause a zero-byte to pass SQL parser an to be actually
> stored, BUT
> the output will be corrupted, because of this zero-byte will be actually
> output)
>
> You may use the BYTEA type
> (similar to the TEXT but with different input-output) which effectively
> escapes zero-byte and a lot of other completely harmless bytes as well
> (probably to reach a better overhead)
>
> Or you may introduce a pair of your own escape rules.
>
> Unfortunately there are no way to influence The Pg Developers to get rid of
> the nasty god damned CSTRING off the input/output operations.
>
>
> --
> Sent via pgsql-sql mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
Regards,
--
Trinath Somanchi,


Re: [SQL]

2010-07-04 Thread Pavel Stehule
Hello

use a LO interface

http://www.postgresql.org/docs/8.4/static/lo-interfaces.html

exact form depends on language that you are use.

Regards

Pavel Stehule

2010/7/5 Trinath Somanchi :
> Hi,
>
> I'm new in using BLOB. How will the insert for storing very large byte
> strings into a column  of data type Blob.
>
> On Mon, Jul 5, 2010 at 11:42 AM, silly sad  wrote:
>>
>> On 07/05/10 09:57,  wrote:
>>>
>>> Hi,
>>>
>>> How can I store Byte strings into a postgresql database.
>>> Is there any special command to store it. How will be the sql query.
>>
>> there is only '\0' byte incapable to input-output.
>> so u have to have it escaped at all costs _AND NOTHING MORE_.
>>
>> "escaped" doesn't mean "prefixed with backslash"
>> ("backslash method" cause a zero-byte to pass SQL parser an to be actually
>> stored, BUT
>> the output will be corrupted, because of this zero-byte will be actually
>> output)
>>
>> You may use the BYTEA type
>> (similar to the TEXT but with different input-output) which effectively
>> escapes zero-byte and a lot of other completely harmless bytes as well
>> (probably to reach a better overhead)
>>
>> Or you may introduce a pair of your own escape rules.
>>
>> Unfortunately there are no way to influence The Pg Developers to get rid
>> of the nasty god damned CSTRING off the input/output operations.
>>
>>
>> --
>> Sent via pgsql-sql mailing list ([email protected])
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql
>
>
>
> --
> Regards,
> --
> Trinath Somanchi,
>

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL]

2010-07-04 Thread silly sad

On 07/05/10 10:30, Trinath Somanchi wrote:

Hi,

I'm new in using BLOB. How will the insert for storing very large byte
strings into a column  of data type Blob.


i didn't advice you to use BLOB.

you may store a string as long as 2GB at any TEXT or BYTEA field.

--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL]

2010-07-04 Thread Pavel Stehule
2010/7/5 silly sad :
> On 07/05/10 10:30, Trinath Somanchi wrote:
>>
>> Hi,
>>
>> I'm new in using BLOB. How will the insert for storing very large byte
>> strings into a column  of data type Blob.
>
> i didn't advice you to use BLOB.
>
> you may store a string as long as 2GB at any TEXT or BYTEA field.

you can do it, but don't do it! Escaping of large strings are not
cheap, processing extra long SQL statements are extreme expensive on
memory - so don't do it - or test it before and check memory and
processor usage - and check it in testing environment with more than
one user.

The good size for text or bytea is less than 100M and real max isn't
2G but it is 1G. LO isn't these limits because it isn't accessable on
SQL level.

Regards
Pavel Stehule
>
> --
> Sent via pgsql-sql mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] How to store Byte strings into a table.

2010-07-04 Thread Sergey Konoplev
On 5 July 2010 09:57, Trinath Somanchi  wrote:
> Hi,
>
> How can I store Byte strings into a postgresql database.
>
> Is there any special command to store it. How will be the sql query.
>
> I have gone through this
> http://www.postgresql.org/docs/8.4/static/datatype-binary.html but have not
> seen any example for how to insert data into such a field.

Use octet-escaping to form the string to put in your SQL like it
described it the article you referenced.

>
> Please help me in this regard.
>
>
> --
> Regards,
> --
> Trinath Somanchi,
>



-- 
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com /
Linkedin: http://ru.linkedin.com/in/grayhemp /
JID/GTalk: [email protected] / Skype: gray-hemp / ICQ: 29353802

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL]

2010-07-04 Thread silly sad

On 07/05/10 10:43, Pavel Stehule wrote:


The good size for text or bytea is less than 100M and real max isn't
2G but it is 1G. LO isn't these limits because it isn't accessable on
SQL level.


any regular file on my filesystem isn't accessible on SQL level.
i am happy with them and never tried to store at a database.

--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql