Oracle PL/SQL WARNINGS Versions 10.1 - 19.3 |
---|
Security Advisory | |||||||||||||||||||||||
Since the day we first found PL/SQL Warnings in a Beta test we have not deployed a single customer database without overriding Oracle's default. To benefit from enabling these you must compile PL/SQL objects in your database using SQL*Plus which you should be doing 100% of the time. If you have been compiling objects in your database using any other tool not only can you not benefit from enabling these warnings ... you also are very likely to have been compiling them in debug mode without even knowing it. And, equally important, they work even when code has been wrapped. | |||||||||||||||||||||||
Recommended Security Rules | |||||||||||||||||||||||
NEVER
|
|||||||||||||||||||||||
How Oracle Works | |||||||||||||||||||||||
PL/SQL Warnings are created by essentially the same set of processes that produce errors when you try to run SQL or create objects using invalid syntax. The primary difference between these message and the error message you are used to seeing is that these are hidden from you on default installation. Developers and Pre-Production DBAs can gain valuable insights by capturing these messages during installation of PL/SQL objects such as functions, operators, packages and procedures and the value received will help you write better code, get better performance, and in some cases avoid security issues that you could not detect by any other means. |
|||||||||||||||||||||||
Oracle Error Messages (Oracle shows you these by default) | CREATE OR REPLACE PROCEDURE plw06002 AS |
||||||||||||||||||||||
Oracle Warning Messages (the result of a default Oracle installation) | set linesize 121
Didn't find the issue did you. Run the next demo to see what is wrong |
||||||||||||||||||||||
Oracle Warning Messages with message display enabled | ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
||||||||||||||||||||||
Oracle Warning Messages with message display enabled with wrapped code. You may not be able to read the PL/SQL but the compiler can. |
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
||||||||||||||||||||||
As the above code clearly demonstrates, Oracle walked the code with the default value of "x" which is 10. Look closely at the first line of the IF statement ... IF x = 10.
Well of course it does. x has no option but to have the value of 10 so at line 7 position 5, x := 100 will never execute. Consider these implications if this code made it into production
Now that we have your attention ... be sure you enable PL/SQL warnings on all of your databases ... especially those in development and test. |
|||||||||||||||||||||||
PL/SQL Warnings General Information | |||||||||||||||||||||||
Constants |
|
||||||||||||||||||||||
Data Dictionary Objects |
|
||||||||||||||||||||||
First Available | 10.1 | ||||||||||||||||||||||
Initialization Parameter | PLSQL_WARNINGS | ||||||||||||||||||||||
ALTER SYSTEM SET plsql_warnings = 'ENABLE:ALL' |
|||||||||||||||||||||||
Syntax and Usage | |||||||||||||||||||||||
Basic Examples | PLSQL_WARNINGS = '<DISABLE | ENABLE | ERROR>:<ALL | INFORMATIONAL | PERFORMANCE | SEVERE>' |
||||||||||||||||||||||
col value format a80 |
|||||||||||||||||||||||
Severe Warning Messages (5000-5999) | |||||||||||||||||||||||
PLW-05000 | Mismatch in NOCOPY qualification between specification and body The indicated parameter was declared with the NOCOPY hint in the subprogram specification but not in the body, or it was declared with the NOCOPY hint in the body but not in the specification. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL'; |
|||||||||||||||||||||||
PLW-05001 | Previous use of 'string' (at line string) conflicts with this use While looking for prior declarations of a variable or constant, the compiler found another object with the same name in the same scope, or, the headers of subprogram in a package specification and body are not identical. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05003 | Same actual parameter(string and string) at IN and NOCOPY may have side effects The indicated parameter was declared with the NOCOPY hint in the subprogram specification but not in the body, or it was declared with the NOCOPY hint in the body but not in the specification. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05004 | Identifier string is also declared in STANDARD or is a SQL builtin The indicated identifier was also either:
|
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; sho err |
|||||||||||||||||||||||
PLW-05005 | Function string returns without value at line string The function exited without a return value. Return statements are required for all PL/SQL functions. |
||||||||||||||||||||||
eALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL'; |
|||||||||||||||||||||||
PLW-05006 | Shadow type generation resulted in warning string Compilation of a table function causes the creation of internally- generated types. A problem occurred during creation of these types which was not severe enough to prevent the creation of the types, but which may impact the usage of the table function. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05007 | First parameter to pragma INLINE must be an identifier The first parameter to the pragma INLINE must be an identifier denoting a procedure or function. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05008 | Illegal number of arguments for pragma string The number of arguments (actual parameters) passed to the named pragma (compiler directive) is incorrect. A required argument was omitted from the argument list, or the pragma syntax is faulty (for example, a comma might be missing between two parameters). |
||||||||||||||||||||||
I have tried numerous times to generate this warning without success. In every case the compiler has raised a full exception due to the syntax being invalid. | |||||||||||||||||||||||
PLW-05009 | Pragma INLINE may not appear in a declaration list Pragma INLINE applies only to the following statement, and can not appear immediately prior to a declaration. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05010 | Duplicate pragma INLINE on procedure 'string' Pragma INLINE was applied twice to the same procedure in the same statement. The procedure will be inlined only if all duplicates specify a control value of 'YES'. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05011 | Pragma INLINE for procedure 'string' does not apply to any calls A pragma INLINE was provided, but there was no call to the mentioned procedure in the next statement. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw05011 AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-05012 | Pragma INLINE for procedure 'string' could not be applied A pragma INLINE(<name>, 'yes') was used, but the named procedure could not be inlined. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05013 | Second parameter to pragma INLINE 'string' is not 'YES' or 'NO' The second parameter to the pragma INLINE governs whether or not a procedure call can be inlined. The only legal values are 'YES', meaning that the compiler should attempt to inline the call, and 'NO', meaning that the compiler must not inline the call. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw05013 AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-05014 | Pragma string cannot be specified here The pragma was specified in an inappropriate context. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05015 | Implementation restriction - too many debug records The program is so large that it overflowed a compiler limit on the size of the debug symbol table. The module was compiled with partial debugging information. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05016 | INTO clause should not be specified here The INTO clause was incorrectly specified on a cursor declaration. It should have been specified on the FETCH statement. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL'; |
|||||||||||||||||||||||
PLW-05017 | Prefix of the expression will be ignored Generalized invocation with explicit SELF and a dotted name was used to call the type method causing the prefix of the dotted name to be ignored. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05018 | Package, procedure, function, or PL/SQL type does not contain the AUTHID clause Unit omitted optional AUTHID clause; default value DEFINER used.This warning is a generic reminder to explicitly define AUTHID |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw05018 IS |
|||||||||||||||||||||||
PLW-05019 | Language element 'string' is deprecated in the indicated version The language element near keyword string is deprecated beginning with version string. A deprecated language element was used. The particular language element is deprecated in PL/SQL versions greater than or equal to the version number given in the message text. |
||||||||||||||||||||||
CREATE OR REPLACE PACKAGE plw05019 AUTHID DEFINER AS |
|||||||||||||||||||||||
PLW-05020 | Parameter name must be an identifier A string literal was used as the parameter name in a call that used named notation. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE child (parm IN VARCHAR2) AUTHID CURRENT_USER IS |
|||||||||||||||||||||||
PLW-05021 | Exception <exception_name> does not have a pragma A user defined exception was created but not mapped to a pragma. I can see this warning as a real pain unless disabled which I do in my setup glogin.sql. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw05021 AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-05022 | Argument 'string' is not comparable An argument to either IN, BETWEEN or MEMBER OF was not of a comparable type. Or, if the argument was of an object type, no MAP or ORDER method was specified for the type. |
||||||||||||||||||||||
-- multiple attempts to produce this warning message have failed. Here is one of them.conn scott/tiger@pdbdev |
|||||||||||||||||||||||
PLW-05023 | PL/Scope is disabled because SYSAUX is offline PL/Scope was disabled for the current PL/SQL unit compilation because the SYSAUX tablespace is or was offline at the time of compilation. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05024 | Do not use BULK COLLECT clause in a cursor declaration A BULK COLLECT clause was specified in a cursor declaration. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw05024 AUTHID DEFINER AS |
|||||||||||||||||||||||
PLW-05025 | Do not refer to formal parameter string from this same subprogram declaration The default expression of a formal parameter referred to another formal parameter from the same subprogram declaration. This is only permitted in a formal %CHARSET expression. Action: Remove the reference. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-05999 | Implementation restriction (may be temporary) string | ||||||||||||||||||||||
TBD | |||||||||||||||||||||||
Informational Warning Messages (6000-6249) | |||||||||||||||||||||||
PLW-06002 | Unreachable code Static program analysis determined that some code on the specified line would never be reached during execution. This may come as a result of expression evaluation at compile time. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL'; |
|||||||||||||||||||||||
PLW-06002 with Wrapped Code | ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
||||||||||||||||||||||
PLW-06003 | Unknown inquiry directive 'string' An unknown inquiry directive was used. The inquiry directive is neither predefined nor user-defined. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw06003 IS |
|||||||||||||||||||||||
PLW-06004 | Inlining of call of procedure 'string' requested A pragma INLINE(, 'YES') referring to the named procedure was found. The compiler will, if possible, inline this call. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06005 | Inlining of call of procedure 'string' was done A call to the procedure was inlined. |
||||||||||||||||||||||
CREATE OR REPLACE TYPE t_airplanes_row AUTHID CURRENT_USER AS OBJECT ( |
|||||||||||||||||||||||
PLW-06006 | Uncalled procedure 'string' is removed Static program analysis determined that the procedure can never be called or executed. Therefore, it has been removed to save time during compilation and space during execution. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
|||||||||||||||||||||||
PLW-06007 | Procedure 'string' is removed because optimization removed calls Static program analysis determined that the procedure can never be called or executed. Therefore, it has been removed to save time during compilation and space during execution. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06008 | Call of procedure 'string' will not be inlined A pragma INLINE(, 'NO') referring to the named procedure was found. The compiler is prevented from inlining this call. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06009 | Procedure 'string' OTHERS handler does not end in RAISE or RAISE_APPLICATION_ERROR The OTHERS handler can exit without executing some form of RAISE or or a call to the standard procedure RAISE_APPLICATION_ERROR. |
||||||||||||||||||||||
CREATE OR REPLACE PROCEDURE plw06009 AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-06010 | Keyword 'string' used as a defined name A PL/SQL or SQL keyword was used as defined name. Although legal, this is not recommended. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
|||||||||||||||||||||||
PLW-06011 | Detailed dependency information discarded due to size limitations The compiled unit was so large that the compiler could not store detailed dependency information that could be used to quickly recompile the unit if it was invalidated. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06012 | SQL statement cannot be inlined. string The SQL statement could not be inlined. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06013 | Deprecated parameter PLSQL_DEBUG forces PLSQL_OPTIMIZE_LEVEL <= 1 The PLSQL_DEBUG parameter was set to TRUE forcing the optimization level to 1 (or 0 if the user selected 0) regardless of the setting of the PLSQL_OPTIMIZE_LEVEL parameter to a higher level |
||||||||||||||||||||||
show parameter level |
|||||||||||||||||||||||
PLW-06014 | PLSQL_OPTIMIZE_LEVEL <= 1 turns off native code generation Native code generation was not done because the optimization was set to 1 or less. |
||||||||||||||||||||||
SELECT DISTINCT owner, plsql_optimize_level |
|||||||||||||||||||||||
PLW-06015 | Parameter PLSQL_DEBUG is deprecated; use PLSQL_OPTIMIZE_LEVEL = 1 The PLSQL_DEBUG parameter was specified. |
||||||||||||||||||||||
show parameter level |
|||||||||||||||||||||||
PLW-06016 | Unit string is too large; native code generation turned off Because the program was extremely large, analysis took an excessive amount of time or space to complete causing native compilation to be turned off. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06017 | An operation will raise an exception An operation near this location is certain to raise an exception during execution; it may be a programming error because it is not an explicit RAISE. |
||||||||||||||||||||||
-- the signtype data type can only handle the values -1, 0, and +1CREATE OR REPLACE FUNCTION plw6017f RETURN SIGNTYPE AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-06018 | An infinity or NaN value is computed or used An operation near this location computes or uses an infinite NUMBER, BINARY_FLOAT, or BINARY_DOUBLE value or a NaN BINARY_FLOAT or BINARY_DOUBLE value. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06019 | Entity string is deprecated The entity was deprecated and could be removed in a future release. |
||||||||||||||||||||||
SQL> CREATE OR REPLACE PACKAGE plw06019a AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-06020 | Reference to a deprecated entity: declared in unit The referenced entity was deprecated and could be removed in a future release. Do not use the deprecated entity. Follow the specific instructions in the warning if any are given. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06021 | PRAGMA DEPRECATE on string is misplaced The pragma deprecate should follow immediately after the declaration of the entity that is being deprecated. Place the pragma immediately after the declaration of the entity that is being deprecated. |
||||||||||||||||||||||
SQL> CREATE OR REPLACE PROCEDURE plw06021 AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-06022 | Cannot use PRAGMA DEPRECATE on this entity This entity cannot be deprecated. Deprecation only applies to entities that may be declared in a package or type specification as well as to top-level procedure and function definitions. |
||||||||||||||||||||||
SQL> CREATE OR REPLACE PROCEDURE plw06022 AUTHID DEFINER IS |
|||||||||||||||||||||||
PLW-06023 | Invocation of string computes trivial value An IS NULL, IS NOT NULL or NVL operator was used on an object that is either never null or always null. The code may be made more efficient by eliding the call. Rewrite the code to remove the call. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06024 | Incorrect use of PRAGMA COVERAGE PRAGMA COVERAGE was encountered in a location in which it did not belong. Rewrite the code so that occurrences of NOT_FEASIBLE_START match occurrences of NOT_FEASIBLE_END. Pragmas may not be nested. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06025 | Implicit use of NLS session parameters may be a security risk A conversion to a CHAR or VARCHAR type without the explicit specification of National Language Support (NLS) conversion parameters may introduce security risks. This may occur during implicit conversion, as when non-character types are concatenated. Rewrite implicit conversions to explicitly specify the format model to use in the conversion. |
||||||||||||||||||||||
TBD | |||||||||||||||||||||||
PLW-06026 | Package specification exposes global variable A global variable was directly declared in a package specification. Rewrite the code to avoid exposing a global variable directly in the package specification, for example, by moving the global variable to the package body and providing a function to access and return its value. |
||||||||||||||||||||||
SQL> CREATE OR REPLACE PACKAGE plw06026package AUTHID DEFINER AS |
|||||||||||||||||||||||
Performance Warning Messages (7000-7249) | |||||||||||||||||||||||
PLW-07202 | Bind type will result in conversion away from column type The column type and the bind type do not exactly match. This will result in the column being converted to the type of the bind variable. This type conversion may prevent the SQL optimizer from using any index the column participates in. This may adversely affect the execution performance of this statement. The 18c docs claim this warning does not exist ... but Oracle is incorrect as shown below. |
||||||||||||||||||||||
SQL> CREATE TABLE test (datecol DATE); |
|||||||||||||||||||||||
PLW-07203 | Parameter 'string' may benefit from use of the NOCOPY compiler hint The mode of the specified parameter was IN OUT or OUT. Use of the NOCOPY compiler hint may speed up calls to this subprogram. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
|||||||||||||||||||||||
PLW-07204 | Conversion away from column type may result in sub-optimal query plan. The column type and the bind type do not exactly match. This may result in the column being converted to the type of the bind variable. This type conversion may prevent the SQL optimizer from using any index the column participates in. This may adversely affect the execution performance of this statement. |
||||||||||||||||||||||
desc servers |
|||||||||||||||||||||||
PLW-07205 | SIMPLE_INTEGER is mixed with BINARY_INTEGER or PLS_INTEGER Using SIMPLE_INTEGER and BINARY_INTEGER or PLS_INTEGER arguments in the same arithmetic expression may inhibit certain optimizations. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'; |
|||||||||||||||||||||||
PLW-07206 | Analysis suggests that the assignment to 'string' may be unnecessary This assignment may be unnecessary; the PL/SQL optimizer could not find any further use of the variable which was being set. If the assignment was being done for some side-effect such as raising a specific exception, the compiler may not have been able to understand the side-effect and this warning may be inappropriate. |
||||||||||||||||||||||
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL'; |
|||||||||||||||||||||||
PLW-07207 | BULK COLLECT used without the LIMIT clause The BULK COLLECT FETCH did not have a LIMIT clause potentially producing in a memory shortage at run time. |
||||||||||||||||||||||
-- this compilation is successful due to the presence of the limit clause
-- this compilation, without the limit clause, generates a warning CREATE OR REPLACE PROCEDURE plw07207 AUTHID DEFINER IS |
Related Topics |
DBMS_WARNING |
DBMS_WARNING_INTERNAL |
PL/SQL Object Settings |