{"id":247,"date":"2017-05-22T18:27:26","date_gmt":"2017-05-22T18:27:26","guid":{"rendered":"https:\/\/www.spotonoracle.com\/?p=247"},"modified":"2017-05-22T18:27:26","modified_gmt":"2017-05-22T18:27:26","slug":"patch-the-patch-12-2-directory-path-name","status":"publish","type":"post","link":"https:\/\/www.spotonoracle.com\/?p=247","title":{"rendered":"Patch the patch: 12.2 DIRECTORY path name"},"content":{"rendered":"<p>Oracle has released the first Database Proactive Bundle Patch (12.2.0.1.170516) on May 16th 2017 for Oracle database 12.2. Unfortunately, I could not successfully apply the patch to my lab environment. It would patch CDB$ROOT and PDB$SEED but failed patching my PDB (see lines 34 to 36).<\/p>\n<pre class=\"brush: bash; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n$ .\/datapatch -verbose\r\nSQL Patching tool version 12.2.0.1.0 Production on Sat May 20 22:49:57 2017\r\nCopyright (c) 2012, 2017, Oracle.  All rights reserved.\r\n\r\nLog file for this invocation: \/u01\/app\/oracle\/cfgtoollogs\/sqlpatch\/sqlpatch_4836_2017_05_20_22_49_57\/sqlpatch_invocation.log\r\n\r\nConnecting to database...OK\r\nNote:  Datapatch will only apply or rollback SQL fixes for PDBs\r\n       that are in an open state, no patches will be applied to closed PDBs.\r\n       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation\r\n       (Doc ID 1585822.1)\r\nBootstrapping registry and package to current versions...done\r\nDetermining current state...done\r\n\r\nCurrent state of SQL patches:\r\nBundle series DBBP:\r\n  ID 170516 in the binary registry and not installed in any PDB\r\n\r\nAdding patches to installation queue and performing prereq checks...\r\nInstallation queue:\r\n  For the following PDBs: CDB$ROOT PDB$SEED PDBDEV1\r\n    Nothing to roll back\r\n    The following patches will be applied:\r\n      25862693 (DATABASE BUNDLE PATCH 12.2.0.1.170516)\r\n\r\nInstalling patches...\r\nPatch installation complete.  Total patches installed: 3\r\n\r\nValidating logfiles...\r\nPatch 25862693 apply (pdb CDB$ROOT): SUCCESS\r\n  logfile: \/u01\/app\/oracle\/cfgtoollogs\/sqlpatch\/25862693\/21259009\/25862693_apply_DEV1_CDBROOT_2017May20_22_50_22.log (no errors)\r\nPatch 25862693 apply (pdb PDB$SEED): SUCCESS\r\n  logfile: \/u01\/app\/oracle\/cfgtoollogs\/sqlpatch\/25862693\/21259009\/25862693_apply_DEV1_PDBSEED_2017May20_22_50_47.log (no errors)\r\nPatch 25862693 apply (pdb PDBDEV1): WITH ERRORS\r\n  logfile: \/u01\/app\/oracle\/cfgtoollogs\/sqlpatch\/25862693\/21259009\/25862693_apply_DEV1_PDBDEV1_2017May20_22_50_47.log (errors)\r\n    Error at line 32: ORA-65254: invalid path specified for the directory\r\n\r\nPlease refer to MOS Note 1609718.1 and\/or the invocation log\r\n\/u01\/app\/oracle\/cfgtoollogs\/sqlpatch\/sqlpatch_4836_2017_05_20_22_49_57\/sqlpatch_invocation.log\r\nfor information on how to resolve the above errors.\r\n\r\nSQL Patching tool complete on Sat May 20 22:51:10 2017\r\n<\/pre>\n<p>Checking the logfile it showed that a call to &#8220;dbms_sqlpatch.patch_initialize&#8221; had failed. Looking at what might have caused this error in the procedure I found this:<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n       DIRECTORY_SQL := 'CREATE DIRECTORY dbms_sqlpatch_dir AS ' ||\r\n         DBMS_ASSERT.ENQUOTE_LITERAL(ORACLE_HOME || '\/rdbms\/admin');\r\n       DEBUG_PUT_LINE('directory sql: ' || DIRECTORY_SQL);\r\n       EXECUTE IMMEDIATE DIRECTORY_SQL;\r\n<\/pre>\n<p>Why would that fail? The code should actually work. After some further investigation I noticed a sneaky little behavior change in Oracle 12.2. If you create a PDB with the &#8220;PATH_PREFIX&#8221; clause &#8220;CREATE DIRECTORY&#8221; will no longer accept absolute path names in that PDB.<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\nSQL&gt; alter session set container=pdbdev1;\r\n\r\nSession altered.\r\n\r\nSQL&gt; create or replace directory testdir AS '\/u02\/oradata\/DEV1\/PDBDEV1\/dump';\r\ncreate or replace directory testdir AS '\/u02\/oradata\/DEV1\/PDBDEV1\/dump'\r\n*\r\nERROR at line 1:\r\nORA-65254: invalid path specified for the directory\r\n\r\n\r\nSQL&gt; create or replace directory testdir AS '.\/dump';\r\n\r\nDirectory created.\r\n\r\nSQL&gt; select directory_path from dba_directories where directory_name = 'TESTDIR';\r\n\r\nDIRECTORY_PATH\r\n--------------------------------------------------------------------------------\r\n\/u02\/oradata\/DEV1\/PDBDEV1\/.\/dump\r\n\r\nSQL&gt; create or replace directory testdir AS 'dump';\r\n\r\nDirectory created.\r\n\r\nSQL&gt; select directory_path from dba_directories where directory_name = 'TESTDIR';\r\n\r\nDIRECTORY_PATH\r\n--------------------------------------------------------------------------------\r\n\/u02\/oradata\/DEV1\/PDBDEV1\/dump\r\n<\/pre>\n<p>Oracle 12.2 will basically accept any string that doesn&#8217;t start with a forward-slash &#8220;\/&#8221; and append it to the PATH_PREFIX. This behavior does not reflect the current <a href=\"http:\/\/docs.oracle.com\/database\/122\/SQLRF\/CREATE-DIRECTORY.htm#SQLRF01207\" target=\"_blank\">documentation<\/a>:<br \/>\n<a href=\"https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1141\" height=\"93\" src=\"https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name.png\" alt=\"\" class=\"alignnone size-medium wp-image-248\" srcset=\"https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name.png 1141w, https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name-300x24.png 300w, https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name-768x63.png 768w, https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name-1024x83.png 1024w, https:\/\/www.spotonoracle.com\/wp-content\/uploads\/2017\/05\/ora-doc_dp-path-name-624x51.png 624w\" sizes=\"auto, (max-width: 1141px) 100vw, 1141px\" \/><\/a><\/p>\n<p>Oracle 12.1, on the other hand, will accept just any string. But as you can see only the first directory object ends up with the inteded directory path.<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\nSQL&gt; create or replace directory testdir AS '\/u02\/oradata\/DEV1\/PDB1';\r\n\r\nDirectory created.\r\n\r\nSQL&gt; select directory_path from dba_directories where directory_name = 'TESTDIR';\r\n\r\nDIRECTORY_PATH\r\n--------------------------------------------------------------------------------\r\n\/u02\/oradata\/DEV1\/PDB1\r\n\r\nSQL&gt; create or replace directory testdir AS '.\/dump';\r\n\r\nDirectory created.\r\n\r\nSQL&gt; select directory_path from dba_directories where directory_name = 'TESTDIR';\r\n\r\nDIRECTORY_PATH\r\n--------------------------------------------------------------------------------\r\n.\/dump\r\n\r\nSQL&gt; create or replace directory testdir AS 'dump';\r\n\r\nDirectory created.\r\n\r\nSQL&gt; select directory_path from dba_directories where directory_name = 'TESTDIR';\r\n\r\nDIRECTORY_PATH\r\n--------------------------------------------------------------------------------\r\ndump\r\n<\/pre>\n<p>I believe the intention of Oracle was to restrict the directory object path to &#8220;PATH_PREFIX&#8221; and subfolders in 12.2. They just did it in a very bad way. I&#8217;m going to raise a Service Request to see if that&#8217;s expected behavior or a regression and will keep you posted in the comment section of this post. Either way, Oracle will have to fix one or the other.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oracle has released the first Database Proactive Bundle Patch (12.2.0.1.170516) on May 16th 2017 for Oracle database 12.2. Unfortunately, I could not successfully apply the patch to my lab environment. It would patch CDB$ROOT and PDB$SEED but failed patching my PDB (see lines 34 to 36). $ .\/datapatch -verbose SQL Patching tool version 12.2.0.1.0 Production [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-247","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=247"}],"version-history":[{"count":8,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/247\/revisions"}],"predecessor-version":[{"id":256,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/247\/revisions\/256"}],"wp:attachment":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}