adding a C function with optional arguments

Started by Jim Mercerover 25 years ago2 messagesgeneral
Jump to latest
#1Jim Mercer
jim@pneumonoultramicroscopicsilicovolcanoconiosis.ca

i've poked about and made a new function "makecrypt(plainpass, salt)", and
it works ok.

basically, it is just a hook to the unix crypt() function.

i was wondering if someone could tell me how, if possible, to implement
a c function such that i can do:

SELECT makecrypt('secret', 'salt');

or

SELECT makecrypt('secret');

such that if salt is not specified, the c function would make one up.

--
[ Jim Mercer jim@pneumonoultramicroscopicsilicovolcanoconiosis.ca ]
[ Reptilian Research -- Longer Life through Colder Blood ]
[ aka jim@reptiles.org +1 416 410-5633 ]

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jim Mercer (#1)
Re: adding a C function with optional arguments

Jim Mercer <jim@pneumonoultramicroscopicsilicovolcanoconiosis.ca> writes:

i was wondering if someone could tell me how, if possible, to implement
a c function such that i can do:

SELECT makecrypt('secret', 'salt');

or

SELECT makecrypt('secret');

such that if salt is not specified, the c function would make one up.

This would be two separate functions in Postgres' view of the world.
Whether one calls the other internally is between you and your code...

regards, tom lane

PS: pneumonoultramicroscopicsilicovolcanoconiosis? Wazzat?