Thread: Hex representation

Hex representation

From
Carol Walter
Date:
Hello,

Does anyone know what the format of hex characters for postgres are?
I'm trying to create files that contain a 0x55.  It looks to me like
it should require a delimiter of some sort between the characters.  I
don't know how postgres would know that the string was a hex
representation and not just a character zero, followed by a character
x, followed by a character 5, followed by a character 5.

Carol

Re: Hex representation

From
"Milen A. Radev"
Date:
Carol Walter написа:
> Hello,
>
> Does anyone know what the format of hex characters for postgres are?
> I'm trying to create files that contain a 0x55.  It looks to me like it
> should require a delimiter of some sort between the characters.  I don't
> know how postgres would know that the string was a hex representation
> and not just a character zero, followed by a character x, followed by a
> character 5, followed by a character 5.


http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Look for "Also supported are \digits,..." in section "4.1.2.1. String Constants".


--
Milen A. Radev

Re: Hex representation

From
"Scott Marlowe"
Date:
I used this very simple little php script to make this

filename: mk55:
#!/usr/bin/php -q
<?php
for ($i=0;$i<262144;$i++){
    print chr(85);
}
?>

and ran it:

./mk55 > 55

ls -l 55
-rw-r--r-- 1 smarlowe smarlowe 262144 2008-09-24 13:41 55

i.e. it's 256k.

And it's attached.

On Wed, Sep 24, 2008 at 1:20 PM, Carol Walter <walterc@indiana.edu> wrote:
> Hello,
>
> Does anyone know what the format of hex characters for postgres are?  I'm
> trying to create files that contain a 0x55.  It looks to me like it should
> require a delimiter of some sort between the characters.  I don't know how
> postgres would know that the string was a hex representation and not just a
> character zero, followed by a character x, followed by a character 5,
> followed by a character 5.
>
> Carol
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>

Attachment

Re: Hex representation

From
Steve Crawford
Date:
Scott Marlowe wrote:
> I used this very simple little php script to make this
>
> filename: mk55:
> #!/usr/bin/php -q
> <?php
> for ($i=0;$i<262144;$i++){
>     print chr(85);
> }
> ?>
>
Or, using standard *nix tools (Note: 0x55 = ascii U):
dd bs=1k count=256 if=/dev/zero | tr '\000' U  > full_of_0x55

Cheers,
Steve


Re: Hex representation

From
"Tena Sakai"
Date:

Hi Steve,

That's a cool way to do it.  I wish I thought of it.
Here's yet another way by java:

public class lotsofhex55 {

        public static void main (String[] argv) {

                char myHex55;
                myHex55 = (char) 0x55;

                        // replace 256 with 262144 after testing
                for (int i = 0; i < 256; i++) {
                   System.out.print (myHex55);
                }
        } // end main()
} // end class

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: pgsql-admin-owner@postgresql.org on behalf of Steve Crawford
Sent: Thu 9/25/2008 10:40 AM
To: Scott Marlowe
Cc: Carol Walter; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Hex representation

Scott Marlowe wrote:
> I used this very simple little php script to make this
>
> filename: mk55:
> #!/usr/bin/php -q
> <?php
> for ($i=0;$i<262144;$i++){
>     print chr(85);
> }
> ?>
>  
Or, using standard *nix tools (Note: 0x55 = ascii U):
dd bs=1k count=256 if=/dev/zero | tr '\000' U  > full_of_0x55

Cheers,
Steve


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: Hex representation

From
Carol Walter
Date:
Well, it was a bit convoluted, but I created the file with Excel,
filling the right number of cells with \x55.  This worked too.  The
script wouldn't run for me.  I got an error about a "bad interpreter".

Carol

On Sep 25, 2008, at 1:40 PM, Steve Crawford wrote:

> Scott Marlowe wrote:
>> I used this very simple little php script to make this
>>
>> filename: mk55:
>> #!/usr/bin/php -q
>> <?php
>> for ($i=0;$i<262144;$i++){
>>     print chr(85);
>> }
>> ?>
>>
> Or, using standard *nix tools (Note: 0x55 = ascii U):
> dd bs=1k count=256 if=/dev/zero | tr '\000' U  > full_of_0x55
>
> Cheers,
> Steve
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin


Re: Hex representation

From
"Plugge, Joe R."
Date:
Change the shbang line to match where your php in installed (if it is at
all)

#!/full_path_to_my_php -q

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Carol Walter
Sent: Thursday, September 25, 2008 1:15 PM
To: Steve Crawford
Cc: Scott Marlowe; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Hex representation

Well, it was a bit convoluted, but I created the file with Excel,
filling the right number of cells with \x55.  This worked too.  The
script wouldn't run for me.  I got an error about a "bad interpreter".

Carol

On Sep 25, 2008, at 1:40 PM, Steve Crawford wrote:

> Scott Marlowe wrote:
>> I used this very simple little php script to make this
>>
>> filename: mk55:
>> #!/usr/bin/php -q
>> <?php
>> for ($i=0;$i<262144;$i++){
>>     print chr(85);
>> }
>> ?>
>>
> Or, using standard *nix tools (Note: 0x55 = ascii U):
> dd bs=1k count=256 if=/dev/zero | tr '\000' U  > full_of_0x55
>
> Cheers,
> Steve
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: Hex representation

From
Steve Martin
Date:
Hi, - see below

Plugge, Joe R. wrote:

>Change the shbang line to match where your php in installed (if it is at
>all)
>
>#!/full_path_to_my_php -q
>
>-----Original Message-----
>From: pgsql-admin-owner@postgresql.org
>[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Carol Walter
>Sent: Thursday, September 25, 2008 1:15 PM
>To: Steve Crawford
>Cc: Scott Marlowe; pgsql-admin@postgresql.org
>Subject: Re: [ADMIN] Hex representation
>
>Well, it was a bit convoluted, but I created the file with Excel,
>filling the right number of cells with \x55.  This worked too.  The
>script wouldn't run for me.  I got an error about a "bad interpreter".
>
>Carol
>
>On Sep 25, 2008, at 1:40 PM, Steve Crawford wrote:
>
>
>
>>Scott Marlowe wrote:
>>
>>
>>>I used this very simple little php script to make this
>>>
>>>filename: mk55:
>>>#!/usr/bin/php -q
>>><?php
>>>for ($i=0;$i<262144;$i++){
>>>    print chr(85);
>>>}
>>>?>
>>>
>>>
>>>
>>Or, using standard *nix tools (Note: 0x55 = ascii U):
>>dd bs=1k count=256 if=/dev/zero | tr '\000' U  > full_of_0x55
>>
>>Cheers,
>>Steve
>>
>>
>>
I liked Steve Crawford's idea, a good one liner but I could not get it
to work on sunos, version (Generic_118558-35).  Worked on HPUX.

Just using basic shell scripting, the following are another way of doing it.

Using bash, it can be done like this:
--- Start u.sh ---
#!/usr/local/bin/bash  <- change to output of "which bash"
max=`expr 256 \* 1024`
for (( i=0; i<$max; ++i )) ; do
  echo -n U   <- depends on system, try print
done
--- End u.sh ---
E.g
./u.sh > losOfUs.txt
% xd losOfUs.txt | less
0000000 5555 5555 5555 5555 5555 5555 5555 5555
*
0040000

Or ksh or sh
--- Start u.sh ---
#!/bin/ksh  <- change to output of "which ksh"
max=`expr 256 \* 1024`
i=0
while [ $i -lt $max ] ; do
  print -n U
  i=`expr $i + 1`
done
--- End u.sh ---
./u.sh > losOfUs.txt
od -x losOfUs.txt | less
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0003720  <- still working, slow machine :-{

Regards
Steve Martin



Re: Hex representation

From
Reece Hart
Date:
I can't resist one-liner games.

$ perl -e 'print "U"x(256*1024)' >Us

or, if you specifically want to specify hex:
$ perl -e 'print chr(hex(55))x(256*1024)' >Us

-Reece

-- 
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

Re: Hex representation

From
Michelle Konzack
Date:
Am 2008-09-24 15:20:03, schrieb Carol Walter:
> Hello,
>
> Does anyone know what the format of hex characters for postgres are?
> I'm trying to create files that contain a 0x55.  It looks to me like
> it should require a delimiter of some sort between the characters.  I
> don't know how postgres would know that the string was a hex
> representation and not just a character zero, followed by a character
> x, followed by a character 5, followed by a character 5.

This is working:

#!/bin/sh

for MAJ in 0 1 2 3 ; do
  for MIN in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do
    for HEX in $(seq 1 262144) ; do
      echo -n \x55 >>00${MAY}${MIN}
    done
  done
done

which should create your missing pg_clog files

Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator
    24V Electronic Engineer
    Tamay Dogan Network
    Debian GNU/Linux Consultant


--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
+49/177/9351947    50, rue de Soultz         MSN LinuxMichi
+33/6/61925193     67100 Strasbourg/France   IRC #Debian (irc.icq.com)

Attachment