Hex representation

Lists: pgsql-admin
From: Carol Walter <walterc(at)indiana(dot)edu>
To: pgsql-admin(at)postgresql(dot)org
Subject: Hex representation
Date: 2008-09-24 19:20:03
Message-ID: 337D9AE2-2BEF-48E3-8DF4-E7F0CA560A1B@indiana.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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


From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-24 19:32:46
Message-ID: gbe4kv$e4j$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Carol Walter" <walterc(at)indiana(dot)edu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-24 19:43:51
Message-ID: dcc563d10809241243t20c14dbcl65089e12d54de44@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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(at)indiana(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>

Attachment Content-Type Size
mk55 application/octet-stream 74 bytes

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Carol Walter <walterc(at)indiana(dot)edu>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-25 17:40:59
Message-ID: 48DBCD2B.6020108@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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


From: "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu>
To: "Steve Crawford" <scrawford(at)pinpointresearch(dot)com>, "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
Cc: "Carol Walter" <walterc(at)indiana(dot)edu>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Hex representation
Date: 2008-09-25 18:12:17
Message-ID: FE44E0D7EAD2ED4BB2165071DB8E328C0378F525@egcrc-ex01.egcrc.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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(at)gallo(dot)ucsf(dot)edu

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org on behalf of Steve Crawford
Sent: Thu 9/25/2008 10:40 AM
To: Scott Marlowe
Cc: Carol Walter; pgsql-admin(at)postgresql(dot)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


From: Carol Walter <walterc(at)indiana(dot)edu>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-25 18:15:21
Message-ID: B69C54C5-4A69-493B-ACA2-E9F3D3E5DC19@indiana.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin


From: "Plugge, Joe R(dot)" <JRPlugge(at)west(dot)com>
To: "Carol Walter" <walterc(at)indiana(dot)edu>, "Steve Crawford" <scrawford(at)pinpointresearch(dot)com>
Cc: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Hex representation
Date: 2008-09-25 18:39:04
Message-ID: 32CC45C5BDC57241B9BCEF37AC0C5DB5080B9A0E@OMAEXMB02.corp.westworlds.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Carol Walter
Sent: Thursday, September 25, 2008 1:15 PM
To: Steve Crawford
Cc: Scott Marlowe; pgsql-admin(at)postgresql(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin


From: Steve Martin <steve(dot)martin(at)nec(dot)co(dot)nz>
To: Carol Walter <walterc(at)indiana(dot)edu>
Cc: "Plugge, Joe R(dot)" <JRPlugge(at)west(dot)com>, Steve Crawford <scrawford(at)pinpointresearch(dot)com>, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-26 00:43:23
Message-ID: 48DC302B.7000100@nec.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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(at)postgresql(dot)org
>[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Carol Walter
>Sent: Thursday, September 25, 2008 1:15 PM
>To: Steve Crawford
>Cc: Scott Marlowe; pgsql-admin(at)postgresql(dot)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


From: Michelle Konzack <linux4michelle(at)tamay-dogan(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-27 15:24:15
Message-ID: 20080927152415.GP17284@tamay-dogan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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)


From: Reece Hart <reece(at)harts(dot)net>
To: Steve Martin <steve(dot)martin(at)nec(dot)co(dot)nz>
Cc: Carol Walter <walterc(at)indiana(dot)edu>, "Plugge, Joe R(dot)" <JRPlugge(at)west(dot)com>, Steve Crawford <scrawford(at)pinpointresearch(dot)com>, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Hex representation
Date: 2008-09-30 04:17:23
Message-ID: 1222748243.7111.100.camel@snafu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

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