Create obfuscated procedure definitions for a registration script
If you plan to create a script that users run to register your
stored procedures in their databases, you can use a wrapping procedure
that takes as input the procedure definition and body, and which returns
a CREATE OR REPLACE PROCEDURE command that has obfuscated body text.
For example:
TEST.TESTSCH(USR)=> CREATE OR REPLACE PROCEDURE return_wrap(TEXT, TEXT)
RETURNS TEXT LANGUAGE NZPLSQL AS
BEGIN_PROC
DECLARE
proc alias for $1;
body alias for $2;
enc text;
sql text;
BEGIN
enc := wrap_nzplsql(body);
sql := proc || ' ' || '' || quote_literal(enc) || '';
return sql;
END;
END_PROC;
CREATE PROCEDURE
Similar to the
wrap_proc()
procedure, specify
the CREATE OR REPLACE main definition as a quoted text string in the
first input value, and specify the unquoted BEGIN PROC/END PROC contents
in the second input value. For example:TEST.TESTSCH(USR)=> CALL return_wrap('CREATE OR REPLACE PROCEDURE customer()
RETURNS INT4 LANGUAGE NZPLSQL AS', BEGIN_PROC BEGIN RAISE NOTICE 'The
customer name is alpha'; END; END_PROC);
return_wrap
----------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE customer() RETURNS INT4 LANGUAGE NZPLSQL
AS
'TlpQU1FMV1JBUDEwaTVJeHJnV1BLd1o0ZDVtNEtNMGxKQT09JCtiSlVDS1NHbkVrdVZja
01JR3Nrc2dTZlExWDdkaUpDeHdZWUp2dmlrUkZIeEpEQnR6dE1JSHMxOHRTR08xMG1IczJ
FSk92R2F0Ti8KMGhKTGlUUEdIZz09'
(1 row)
The return value is a CREATE OR REPLACE PROCEDURE command that you can use in your registration script to define your stored procedure without displaying the procedure body text to the script user.