Re: C-ISAM - SE Composite index Problems
Posted in 1995
Hi,
You need to analyse the '.idx' files of an SE-built C-ISAM file because
they are not the same as you would normally build with C-ISAM. I attach
(old) C-ISAM code which analyses the indexes -- no guarantees that it works
8 or so years after it was written. Anyway, index 0 is different in SE
from that you'd expect if using pure C-ISAM.
The best way to handle interworking C-ISAM and SE is to have SE create the
C-ISAM files and to have the C-ISAM application access exactly the files
provided by SE. It is the '.idx' files which differ; the '.dat' contents
are the same.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>From: Gordon Livingstone <esky@ozemail.com.au>
>Date: Thu, 26 Oct 1995 01:46:46 +1100
>X-Informix-List-Id: <news.18233>
>
>I am having trouble geting informix SE to use existing C-ISAM
>data files, I have created tables via dbaccess to match the
>C-ISAM tables then altered the systable dirpath to point to the
>C-ISAM data files.
>
>The tables with non composite indexes perform perfectly however,
>if i try qualify a select on a table with a composite index with
>a WHERE clause I get an error message. The same query without any
>WHERE entered will work fine.
: "@(#)shar.sh 1.9"
#! /bin/sh
#
# This is a shell archive.
# Remove everything above this line and run sh on the resulting file.
# If this archive is complete, you will see this message at the end:
# "All files extracted"
#
# Created: Wed Oct 25 11:51:46 PDT 1995 by johnl at Informix Software Ltd.
# Files archived in this archive:
# isamidx.c
#
#--------------------
if [ -f isamidx.c -a "$1" != "-c" ]
then echo shar: isamidx.c already exists
else
echo 'x - isamidx.c (2720 characters)'
sed -e 's/^X//' >isamidx.c <<'SHAR-EOF'
X/*
X@(#) File: isamidx.c
X@(#) Version: 1.1
X@(#) Last changed: 87/11/23
X@(#) Purpose: Analyse the structure of C-ISAM files
X@(#) Author: J Leffler
X*/
X
X/* -- Include Files */
X
X#include <stdio.h>
X#include <isam.h>
X
X/* -- Type Definitions */
X
Xtypedef struct keydesc Keydesc;
Xtypedef struct keypart Keypart;
Xtypedef struct dictinfo Dictinf;
X
X/* -- Declarations */
X
Xextern void usage(); /* Forward declaration */
Xextern void err_exit2(); /* Forward declaration */
Xextern void printkey(); /* Forward declaration */
X
Xchar *arg0; /* Program name */
X
Xchar *type[] =
X{
X "char",
X "decimal",
X "int",
X "long",
X "double",
X "float"
X};
X
X#ifndef lint
Xstatic char sccs[] = "@(#)isamidx.c 1.1";
X#endif
X
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X int i;
X
X arg0 = argv[0];
X if (argc <= 1)
X usage("isamfile [isamfile ...]");
X for (i = 1; i < argc; i++)
X prindexinfo(argv[i]);
X exit(0);
X}
X
Xprindexinfo(file)
Xchar *file;
X{
X int isfd, i, j;
X Keydesc key;
X Dictinf dict;
X Keypart *kp;
X
X /* Remove trailing .idx, .dat, .??? */
X i = strlen(file);
X if (file[i-4] == '.')
X file[i-4] = '\\0';
X
X if ((isfd = isopen(file, ISINPUT + ISMANULOCK)) < 0)
X err_exit2("failed to open isam file", file);
X if (isindexinfo(isfd, &dict, 0) < 0)
X err_exit2("isindexinfo failed", file);
X printf("ISAM file: %s\\n", file);
X printf("Data record size = %d\\n", dict.di_recsize);
X printf("Index record size = %d\\n", dict.di_idxsize);
X printf("Number of indexes = %d\\n", dict.di_nkeys);
X printf("Number of data rows = %ld\\n", dict.di_nrecords);
X for (i = 1; i <= dict.di_nkeys; i++)
X {
X if (isindexinfo(isfd, &key, i) < 0)
X err_exit2("isindexinfo failed", file);
X printf("\\nIndex Number %d\\n", i);
X printkey(&key, stdout);
X }
X putchar('\\n');
X isclose(isfd);
X return(0);
X}
X
Xvoid err_exit2(s1,s2)
Xchar *s1, *s2;
X{
X fprintf(stderr, "%s: %s %s\\n", arg0, s1, s2);
X exit(1);
X}
X
Xvoid usage(s)
Xchar *s;
X{
X fprintf(stderr, "Usage: %s %s\\n", arg0, s);
X exit(1);
X}
X
Xvoid printkey(key, fp)
XKeydesc *key;
XFILE *fp;
X{
X int j;
X Keypart *kp;
X
X fprintf(fp, "Key parts = %d\\n", key->k_nparts);
X if (key->k_flags & ISDUPS)
X fprintf(fp, "Duplicates index\\n");
X else
X fprintf(fp, "Unique index\\n");
X fprintf(fp, "Compression: ");
X if (key->k_flags & DCOMPRESS)
X fprintf(fp, "Duplicate ");
X if (key->k_flags & LCOMPRESS)
X fprintf(fp, "Leading ");
X if (key->k_flags & TCOMPRESS)
X fprintf(fp, "Trailing ");
X if (key->k_flags & COMPRESS)
X fprintf(fp, "-- All compression");
X putc('\\n', fp);
X
X for (j = 0; j < key->k_nparts; j++)
X {
X kp = &key->k_part[j];
X fprintf(fp, "Part %d: offset = %d, ", j, kp->kp_start);
X fprintf(fp, "length = %d, ", kp->kp_leng);
X fprintf(fp, "type = %d ", kp->kp_type);
X fprintf(fp, "(%s)\\n", type[kp->kp_type]);
X }
X putc('\\n', fp);
X}
SHAR-EOF
chmod 444 isamidx.c
if [ `wc -c <isamidx.c` -ne 2720 ]
then echo shar: isamidx.c unpacked with wrong size
fi
# end of overwriting check
fi
echo All files extracted
exit 0