Re: Random strings - Mailing list pgsql-patches

From Joe Conway
Subject Re: Random strings
Date
Msg-id 003701c120a1$5319fc80$0205a8c0@jecw2k1
Whole thread Raw
In response to Re: Random strings  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-patches
> > Perhaps one of these returning bytea would be enough and you can use
> > the new encode functions to convert them to a format of choice.  Also,
why
> > aren't you using /dev/random?
>

Here's a revised patch. This one has only one user function, randomstr(int
binlen, text source). It allows any length request (well, limited by int)
against a source of 'urandom', or a maximum of 64 bytes against a source of
'random'. I also added a couple of examples to the readme to show how to use
randomstr() with encode() to get hex or base64 output.

On a side note, in the last version of this, I had a function which escaped
the binary C string so that I could feed it to byteain. In this version, I
decided to populate the varlena struct directly, because it seemed an awful
waste to escape the binary just so that byteain could unescape it. But I'm
not sure this is considered a "good thing", or a "bad thing". I'd appreciate
any guidance.

Thanks,

Joe


Attachment

pgsql-patches by date:

Previous
From: Jason Tishler
Date:
Subject: Re: Re: can't make src/tutorial
Next
From: Justin Clift
Date:
Subject: Re: Re: can't make src/tutorial