有同事今天过来找我说"我的一个package body(PCK_SAL_VFY_BATCH_RELEASE)在PL/SQL Developer里编译不过,报错PLS-123 Program too large(Diana Nodes)"。
要想解决上述问题,我们需要了解oracle里存储过程在compile的时候会做什么事情。
在"Oracle 10gR2 PLSQL User's Guide and Reference"的附录C里提到:
PL/SQL is based on the programming language
At compile time, PL/SQL source code is translated into machine-readable m-code.
Both the DIANA and m-code for a procedure or package are stored in the database. At run time, they are loaded into the shared memory pool. The DIANA is used to compile dependent procedures; the m-code is simply executed.
也就是说oracle里存储过程编译的时候,会形成一种树状的结构,这种树状结构上的节点就是Diana Nodes,存储过程里的一行代码大概会产生5到10个Diana Nodes,这个Diana Nodes的总数在oracle里是有上限的。
在
这个3000行代码的限制显然是不够的,oracle也意识到这个问题,于是在
好了,罗嗦了这么多,回到我同事提到的那个问题。
上述库是
我们来看一下:
SQL> SELECT * FROM user_object_size WHERE name = 'PCK_SAL_VFY_BATCH_RELEASE';
NAME TYPE SOURCE_SIZE PARSED_SIZE CODE_SIZE ERROR_SIZE
------------------------------ ------------- ----------- ----------- ---------- ----------
PCK_SAL_VFY_BATCH_RELEASE PACKAGE 22217 12984 62446 0
PCK_SAL_VFY_BATCH_RELEASE PACKAGE BODY 149105 0 0 42
我们从结果里看到确实PCK_SAL_VFY_BATCH_RELEASE的package body在编译的时候报错了。
SQL> select count(*) from dba_source where name='PCK_SAL_VFY_BATCH_RELEASE' and type='PACKAGE BODY';
COUNT(*)
----------
3177
上述package body的代码行数只有3177行,远小于600万行的限制,按道理讲是不应该出现Diana Nodes这方面的错误的。
这里我猜是PL/SQL Developer自身的问题,也就是说PL/SQL Developer还是沿用了
好了,我们来验证一下:
这里我不用PL/SQL Developer来编译,换成由sqlplus来编译:
C:\Documents and Settings\cuihua>sqlplus /nolog
SQL*Plus: Release
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn ipra/acca@ipradev;
已连接。
SQL> alter package PCK_SAL_VFY_BATCH_RELEASE compile body;
程序包体已变更。
SQL> SELECT * FROM user_object_size WHERE name = 'PCK_SAL_VFY_BATCH_RELEASE';
NAME TYPE SOURCE_SIZE PARSED_SIZE CODE_SIZE ERROR_SIZE
------------------------------ ------------- ----------- ----------- ---------- ----------
PCK_SAL_VFY_BATCH_RELEASE PACKAGE 22217 12984 62446 0
PCK_SAL_VFY_BATCH_RELEASE PACKAGE BODY 149105 0 201859 0
现在我们从结果里可以看到,PCK_SAL_VFY_BATCH_RELEASE的package body现在已经能编译通过了。
总结一下:
思路很清晰~~也很好奇,像ORACLE根据版本做出的变化,第三方的公司的产品比如quest公司的sharedplex,是如何随机应变的呢,毕竟计划干不上变化快
我听说oracle透露了一部分的技术细节给quest。
quest,dsg做shareplex,dsg这些产品的开发人员,可能有ORACLE出来的员工。个人猜想。