[comp.databases] Informix dirpath values, was Re: Duplicating Informix SQL Database

harry@wsl.UUCP (Henry M. Moreau on wsl) (10/03/89)

In the context of other problems with Informix software 
e.g.     - Totally inadequate query optimisation.
		 - Incredibly slow sorting.
		 - Inability to recognise that records have just been added
		   to a table if statistics are not updated,
this problem of dirpath seems to me very trivial.
Yes, I too have screwed up a database because of it, but the rule about
altering tables was easily discovered.

As an adjunct, here's a little shell script that I use frequently
on our databases to ensure that dirpath entries are in order:

#!/bin/sh
#
# Check and fix dirpath values in systables for informix.
#
case $# in
0)	echo usage ckidp database >&2
	exit 1
esac

# Get dirpath values that start with /

tf=/tmp/ckdp$$
isql $1 - > $tf << @@@
select dirpath from systables where dirpath matches "/*"
@@@

# Strip trailing spaces off any lines that begin with /
# Get two tagged regular expressions out of each dirpath value
# that correspond to the leading pathname and the basename of
# the table's file.
# Use this to create an update statement.
# E.G. if $tf contains a line:
#	/u/me/db/table123
# The resulting SQL statement is
# 	update systables set dirpath = "table123" where dirpath "/u/me/db/table123"

sed -n '/^\//s/  *$//
/^\//s/\(.*\)\/\(.*\)/update systables set dirpath = "\2" where dirpath = "&"/p' $tf | isql $1 -
rm -f $tf

*************************************************************************
* Henry M. Moreau * snail: Workhorse Systems Ltd. * email: harry@wsl.ie *
* 		  *        16, Morehampton Road   ***********************
* 		  *        Dublin, 4              * phone: 608721       *
*  		  *        Ireland                *                     * 
*************************************************************************
* Opinions expressed herein do not necessarily correspond to opinions   *
* that I have expressed in the past.                                    *
*************************************************************************