Обсуждение: adding a C function with optional arguments

Поиск
Список
Период
Сортировка

adding a C function with optional arguments

От
Jim Mercer
Дата:
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 ]

Re: adding a C function with optional arguments

От
Tom Lane
Дата:
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?