Friday, July 06, 2007

wrap utility

Wrap utility can encrypt sql files.
People usually use ".plb" to identify encrypted files.
The objects created by ".plb" files are also encrypted, for example, in the TEXT column of dba_resource.

The ".plb" file may lead to ORA-4030 in some oracle versions if it is corrupted.

See below for details.

Subject: ORA-04030 (PLS non-lib hp,PAR.C:parchk) While Running a Wrapped Script
Doc ID: Note:280168.1 Type: PROBLEM
Last Revision Date: 18-MAY-2007 Status: MODERATED


The information in this article applies to:
Oracle Server - Enterprise Edition - Version: 8.1.7.4 to 9.2.0.5
This problem can occur on any platform.

Errors
ORA-04030

Symptoms
A wrapped plsql script is being run and we get the following error message:

CREATE OR REPLACE PROCEDURE p5 wrapped
*
ERROR at line 1:
ORA-04030: out of process memory when trying to allocate 659072 bytes (PLS non-lib hp,PAR.C:parchk:p

The plsql is wrapped and is not the ASCII source code.
Cause
Corrupted wrapped code. To see this we can use a small testcase.

1] We create a plsql script which has the following code in it:

create or replace procedure p1
as
x number;
begin
select count(*)
into x
from user_source;
end;
/

2] By running e.sql we can create the procedure fine.

SQL> @c:\e.sql
Procedure created.

3] We will wrap the plsql script.

SQL> host
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

D:\Ora92\BIN>wrap iname=c:\e.sql oname=c:\a.plb

PL/SQL Wrapper: Release 9.2.0.4.0- Production on Tue Jul 27 20:50:59 2004
Copyright (c) Oracle Corporation 1993, 2001. All Rights Reserved.
Processing c:\e.sql to c:\a.plb

D:\Ora92\BIN>exit

SQL> @c:\a.plb
Procedure created.

So the wrapped code is fine now and we are able to create the procedure

4] We will corrupt the wrapped code a.plb (opened the a.plb file with notepad/vi editor and added or deleted some characters)

SQL> set lines 5000
SQL> @c:\a.plb
CREATE OR REPLACE PROCEDURE p5 wrapped
*
ERROR at line 1:
ORA-04030: out of process memory when trying to allocate 659072 bytes (PLS non-lib hp,PAR.C:parchk:p

This has been reproduced on:
o 9.2.0.4 on Windows2000
o 8.1.7.4 on Linux
o 9.2.0.5 on Linux

Fix

The error message (memory related) is somewhat misleading. If we find the ORA-04030 with such an argument (PLS non-lib hp,PAR.C:parchk:) then we should check if the wrapped code is ok or not. We can either rewrap it or can possibly run the unwrapped code.

Note: On 10g DB the error message is proper and instead of giving a ORA-04030 it gives a relevent PLS- error :

SQL> @a.plb
Warning: Procedure created with compilation errors.

SQL> sho err
Errors for PROCEDURE P1:
LINE/COL ERROR
-------- -------------------------------------------
0/0 PLS-00801: internal error [pkg_read:ver]

This has been tested on 10.1.0.2 on Windows and Linux.

No comments: