解决Diana Nodes限制一例

| 3 Comments

有同事今天过来找我说"我的一个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 Ada. As a result, PL/SQL uses a variant of Descriptive Intermediate Attributed Notation for Ada (DIANA), a tree-structured intermediate language. It is defined using a meta-notation called Interface Definition Language (IDL). DIANA is used internally by compilers and other tools.

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,存储过程里的一行代码大概会产生510Diana Nodes,这个Diana Nodes的总数在oracle里是有上限的。

 

8.1.3以前,这个Diana Nodes上限的范围是16K32K,也就是相当于是3000行代码,这就是很多朋友都知道的oracle里存储过程的代码的行数限制。

 

这个3000行代码的限制显然是不够的,oracle也意识到这个问题,于是在8.1.3以后package bodytype bodyDiana Nodes的限制被放宽到67108864,也就是相当于600万行代码。

 

好了,罗嗦了这么多,回到我同事提到的那个问题。

上述库是10.2.0.1,且又是package body,按道理讲是不应该碰到Diana Nodes的问题的。

我们来看一下:

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_RELEASEpackage 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还是沿用了8.1.3之前的3000行代码的限制。

 

好了,我们来验证一下:

这里我不用PL/SQL Developer来编译,换成由sqlplus来编译:

C:\Documents and Settings\cuihua>sqlplus /nolog

 

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 7 22 12:10:30 2009

 

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_RELEASEpackage body现在已经能编译通过了。

 

总结一下:

以后在package body或者type body里编译的时候碰到PLS-123 Program too large(Diana Nodes)这种错误的时候,就用sqlplus编译。

3 Comments

思路很清晰~~也很好奇,像ORACLE根据版本做出的变化,第三方的公司的产品比如quest公司的sharedplex,是如何随机应变的呢,毕竟计划干不上变化快

我听说oracle透露了一部分的技术细节给quest。

quest,dsg做shareplex,dsg这些产品的开发人员,可能有ORACLE出来的员工。个人猜想。

Leave a comment

Recent Comments

  • 老熊: quest,dsg做shareplex,dsg这些产品的开发人员,可能有ORACLE出来的员工。个人猜想。 read more
  • cui hua: 我听说oracle透露了一部分的技术细节给quest。 read more
  • Freedba: 思路很清晰~~也很好奇,像ORACLE根据版本做出的变化,第三方的公司的产品比如quest公司的sharedplex,是如何随机应变的呢,毕竟计划干不上变化快 read more

About this Entry

This page contains a single entry by cui hua published on July 22, 2009 2:04 PM.

某公司招聘数据库方面的售前 was the previous entry in this blog.

解决Diana Nodes限制一例(续) is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.