pgindent run over code.
authorBruce Momjian <[email protected]>
Tue, 25 May 1999 16:15:34 +0000 (16:15 +0000)
committerBruce Momjian <[email protected]>
Tue, 25 May 1999 16:15:34 +0000 (16:15 +0000)
413 files changed:
contrib/array/array_iterator.c
contrib/array/array_iterator.h
contrib/datetime/datetime_functions.c
contrib/earthdistance/earthdistance.c
contrib/findoidjoins/findoidjoins.c
contrib/fulltextindex/fti.c
contrib/isbn_issn/isbn.c
contrib/isbn_issn/issn.c
contrib/lo/lo.c
contrib/mSQL-interface/mpgsql.c
contrib/miscutil/misc_utils.c
contrib/miscutil/misc_utils.h
contrib/noupdate/noup.c
contrib/os2client/c.h
contrib/os2client/config.h
contrib/pginterface/pginterface.c
contrib/pginterface/pginterface.h
contrib/spi/moddatetime.c
contrib/spi/preprocessor/step1.c
contrib/spi/refint.c
contrib/string/string_io.c
contrib/string/string_io.h
contrib/userlock/user_locks.c
contrib/userlock/user_locks.h
contrib/vacuumlo/vacuumlo.c
src/backend/access/common/heaptuple.c
src/backend/access/common/printtup.c
src/backend/access/common/scankey.c
src/backend/access/common/tupdesc.c
src/backend/access/gist/gist.c
src/backend/access/gist/gistscan.c
src/backend/access/hash/hash.c
src/backend/access/hash/hashfunc.c
src/backend/access/hash/hashpage.c
src/backend/access/heap/heapam.c
src/backend/access/heap/hio.c
src/backend/access/index/genam.c
src/backend/access/index/istrat.c
src/backend/access/nbtree/nbtcompare.c
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtscan.c
src/backend/access/nbtree/nbtsearch.c
src/backend/access/nbtree/nbtsort.c
src/backend/access/rtree/rtree.c
src/backend/access/rtree/rtscan.c
src/backend/access/transam/transam.c
src/backend/access/transam/varsup.c
src/backend/access/transam/xact.c
src/backend/access/transam/xid.c
src/backend/bootstrap/bootstrap.c
src/backend/catalog/catalog.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/indexing.c
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_type.c
src/backend/commands/_deadcode/recipe.c
src/backend/commands/_deadcode/version.c
src/backend/commands/async.c
src/backend/commands/cluster.c
src/backend/commands/command.c
src/backend/commands/copy.c
src/backend/commands/creatinh.c
src/backend/commands/dbcommands.c
src/backend/commands/define.c
src/backend/commands/explain.c
src/backend/commands/indexcmds.c
src/backend/commands/remove.c
src/backend/commands/rename.c
src/backend/commands/sequence.c
src/backend/commands/trigger.c
src/backend/commands/user.c
src/backend/commands/vacuum.c
src/backend/commands/variable.c
src/backend/commands/view.c
src/backend/executor/_deadcode/nodeTee.c
src/backend/executor/execAmi.c
src/backend/executor/execMain.c
src/backend/executor/execQual.c
src/backend/executor/execTuples.c
src/backend/executor/execUtils.c
src/backend/executor/functions.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeAppend.c
src/backend/executor/nodeGroup.c
src/backend/executor/nodeHash.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeMaterial.c
src/backend/executor/nodeMergejoin.c
src/backend/executor/nodeResult.c
src/backend/executor/nodeSeqscan.c
src/backend/executor/nodeSubplan.c
src/backend/executor/spi.c
src/backend/lib/fstack.c
src/backend/lib/stringinfo.c
src/backend/libpq/auth.c
src/backend/libpq/be-dumpdata.c
src/backend/libpq/be-fsstubs.c
src/backend/libpq/crypt.c
src/backend/libpq/hba.c
src/backend/libpq/password.c
src/backend/libpq/portal.c
src/backend/libpq/portalbuf.c
src/backend/libpq/pqcomm.c
src/backend/libpq/pqformat.c
src/backend/libpq/util.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/freefuncs.c
src/backend/nodes/list.c
src/backend/nodes/outfuncs.c
src/backend/nodes/print.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/geqo/geqo_eval.c
src/backend/optimizer/geqo/geqo_main.c
src/backend/optimizer/geqo/geqo_misc.c
src/backend/optimizer/geqo/geqo_pool.c
src/backend/optimizer/geqo/minspantree.c
src/backend/optimizer/path/_deadcode/predmig.c
src/backend/optimizer/path/_deadcode/xfunc.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/clausesel.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/hashutils.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/mergeutils.c
src/backend/optimizer/path/orindxpath.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/path/prune.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepkeyset.c
src/backend/optimizer/prep/prepqual.c
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/indexnode.c
src/backend/optimizer/util/joininfo.c
src/backend/optimizer/util/keys.c
src/backend/optimizer/util/ordering.c
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/restrictinfo.c
src/backend/optimizer/util/tlist.c
src/backend/optimizer/util/var.c
src/backend/parser/analyze.c
src/backend/parser/parse_agg.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_expr.c
src/backend/parser/parse_func.c
src/backend/parser/parse_oper.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/parser/parse_type.c
src/backend/parser/parser.c
src/backend/parser/scansup.c
src/backend/port/dynloader/freebsd.c
src/backend/port/hpux/fixade.h
src/backend/port/snprintf.c
src/backend/postmaster/postmaster.c
src/backend/regex/regcomp.c
src/backend/regex/retest.c
src/backend/rewrite/rewriteDefine.c
src/backend/rewrite/rewriteHandler.c
src/backend/rewrite/rewriteManip.c
src/backend/rewrite/rewriteRemove.c
src/backend/storage/buffer/buf_init.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/freelist.c
src/backend/storage/buffer/s_lock.c
src/backend/storage/file/fd.c
src/backend/storage/ipc/ipc.c
src/backend/storage/ipc/ipci.c
src/backend/storage/ipc/shmem.c
src/backend/storage/ipc/sinval.c
src/backend/storage/ipc/sinvaladt.c
src/backend/storage/large_object/inv_api.c
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/multi.c
src/backend/storage/lmgr/proc.c
src/backend/storage/page/bufpage.c
src/backend/storage/page/itemptr.c
src/backend/storage/smgr/md.c
src/backend/storage/smgr/mm.c
src/backend/storage/smgr/smgr.c
src/backend/tcop/dest.c
src/backend/tcop/postgres.c
src/backend/tcop/pquery.c
src/backend/tcop/utility.c
src/backend/tioga/Varray.c
src/backend/tioga/tgRecipe.h
src/backend/utils/adt/acl.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/cash.c
src/backend/utils/adt/char.c
src/backend/utils/adt/chunk.c
src/backend/utils/adt/date.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/dt.c
src/backend/utils/adt/float.c
src/backend/utils/adt/inet_net_ntop.c
src/backend/utils/adt/inet_net_pton.c
src/backend/utils/adt/int8.c
src/backend/utils/adt/like.c
src/backend/utils/adt/mac.c
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/name.c
src/backend/utils/adt/network.c
src/backend/utils/adt/not_in.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numutils.c
src/backend/utils/adt/regproc.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/inval.c
src/backend/utils/cache/rel.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/backend/utils/cache/temprel.c
src/backend/utils/error/elog.c
src/backend/utils/error/exc.c
src/backend/utils/error/excid.c
src/backend/utils/error/format.c
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/hash/dynahash.c
src/backend/utils/init/enbl.c
src/backend/utils/init/findbe.c
src/backend/utils/init/globals.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/mb/alt.c
src/backend/utils/mb/big5.c
src/backend/utils/mb/common.c
src/backend/utils/mb/conv.c
src/backend/utils/mb/iso.c
src/backend/utils/mb/mbutils.c
src/backend/utils/mb/variable.c
src/backend/utils/mb/wchar.c
src/backend/utils/mb/win.c
src/backend/utils/misc/database.c
src/backend/utils/misc/trace.c
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/mcxt.c
src/backend/utils/mmgr/oset.c
src/backend/utils/mmgr/palloc.c
src/backend/utils/mmgr/portalmem.c
src/backend/utils/sort/psort.c
src/backend/utils/time/tqual.c
src/bin/pg_dump/common.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pgtclsh/pgtclAppInit.c
src/bin/pgtclsh/pgtkAppInit.c
src/bin/psql/psql.c
src/include/access/attnum.h
src/include/access/hash.h
src/include/access/heapam.h
src/include/access/hio.h
src/include/access/htup.h
src/include/access/istrat.h
src/include/access/nbtree.h
src/include/access/printtup.h
src/include/access/relscan.h
src/include/access/sdir.h
src/include/access/strat.h
src/include/access/transam.h
src/include/access/tupmacs.h
src/include/c.h
src/include/catalog/heap.h
src/include/catalog/index.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_class.h
src/include/catalog/pg_index.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_type.h
src/include/commands/command.h
src/include/commands/vacuum.h
src/include/executor/executor.h
src/include/executor/hashjoin.h
src/include/executor/nodeGroup.h
src/include/executor/nodeHash.h
src/include/executor/nodeHashjoin.h
src/include/executor/nodeNestloop.h
src/include/executor/spi.h
src/include/executor/spi_priv.h
src/include/executor/tuptable.h
src/include/lib/fstack.h
src/include/lib/stringinfo.h
src/include/libpq/libpq.h
src/include/libpq/pqformat.h
src/include/mb/pg_wchar.h
src/include/miscadmin.h
src/include/nodes/execnodes.h
src/include/nodes/makefuncs.h
src/include/nodes/memnodes.h
src/include/nodes/parsenodes.h
src/include/nodes/plannodes.h
src/include/nodes/primnodes.h
src/include/nodes/relation.h
src/include/optimizer/clauses.h
src/include/optimizer/cost.h
src/include/optimizer/geqo.h
src/include/optimizer/geqo_misc.h
src/include/optimizer/internal.h
src/include/optimizer/joininfo.h
src/include/optimizer/keys.h
src/include/optimizer/ordering.h
src/include/optimizer/pathnode.h
src/include/optimizer/paths.h
src/include/optimizer/planmain.h
src/include/optimizer/restrictinfo.h
src/include/optimizer/tlist.h
src/include/optimizer/xfunc.h
src/include/parser/analyze.h
src/include/parser/parse_agg.h
src/include/parser/parse_coerce.h
src/include/parser/parse_func.h
src/include/port/bsd.h
src/include/port/svr4.h
src/include/port/win.h
src/include/rewrite/rewriteHandler.h
src/include/rewrite/rewriteManip.h
src/include/storage/block.h
src/include/storage/buf.h
src/include/storage/buf_internals.h
src/include/storage/bufmgr.h
src/include/storage/bufpage.h
src/include/storage/fd.h
src/include/storage/itemid.h
src/include/storage/itemptr.h
src/include/storage/lock.h
src/include/storage/off.h
src/include/storage/page.h
src/include/storage/pagenum.h
src/include/storage/pos.h
src/include/storage/proc.h
src/include/storage/shmem.h
src/include/storage/sinvaladt.h
src/include/tcop/dest.h
src/include/tcop/tcopprot.h
src/include/utils/array.h
src/include/utils/bit.h
src/include/utils/builtins.h
src/include/utils/dt.h
src/include/utils/geo_decls.h
src/include/utils/hsearch.h
src/include/utils/inet.h
src/include/utils/int8.h
src/include/utils/mcxt.h
src/include/utils/memutils.h
src/include/utils/nabstime.h
src/include/utils/numeric.h
src/include/utils/palloc.h
src/include/utils/portal.h
src/include/utils/psort.h
src/include/utils/rel.h
src/include/utils/temprel.h
src/include/utils/tqual.h
src/include/utils/trace.h
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/lib/typename.c
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/preproc/type.h
src/interfaces/ecpg/test/header_test.h
src/interfaces/libpgtcl/pgtclCmds.c
src/interfaces/libpgtcl/pgtclCmds.h
src/interfaces/libpgtcl/pgtclId.c
src/interfaces/libpgtcl/pgtclId.h
src/interfaces/libpq/fe-auth.c
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/libpqdll.c
src/interfaces/python/pgmodule.c
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_funcs.c
src/pl/tcl/pltcl.c
src/test/examples/testlo.c
src/test/examples/testlo2.c
src/test/regress/regress.c
src/tools/pgindent/README
src/tutorial/funcs.c
src/utils/dllinit.c
src/utils/getopt.c
src/win32/endian.h
src/win32/tcp.h
src/win32/un.h

index 5c4a3371a4f5c31eb24de34d3e87a47f2ef993bc..1561c1b192b262086e2443d038a8f47e7cff32c9 100644 (file)
@@ -43,8 +43,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
    int         ndim,
               *dim;
    char       *p;
-   FmgrInfo finf;    /*Tobias Gabele Jan 18 1999*/
-   
+   FmgrInfo    finf;           /* Tobias Gabele Jan 18 1999 */
+
 
    /* Sanity checks */
    if ((array == (ArrayType *) NULL)
@@ -75,9 +75,9 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
 
    /* Lookup the function entry point */
    proc_fn = (func_ptr) NULL;
-        fmgr_info(proc,&finf); /*Tobias Gabele Jan 18 1999*/
-        proc_fn=finf.fn_addr;  /*Tobias Gabele Jan 18 1999*/
-        pronargs=finf.fn_nargs; /*Tobias Gabele Jan 18 1999*/
+   fmgr_info(proc, &finf);     /* Tobias Gabele Jan 18 1999 */
+   proc_fn = finf.fn_addr;     /* Tobias Gabele Jan 18 1999 */
+   pronargs = finf.fn_nargs;   /* Tobias Gabele Jan 18 1999 */
    if ((proc_fn == NULL) || (pronargs != 2))
    {
        elog(ERROR, "array_iterator: fmgr_info lookup failed for oid %d", proc);
@@ -110,38 +110,26 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
        {
            result = (int) (*proc_fn) (p, value);
            if (typlen > 0)
-           {
                p += typlen;
-           }
            else
-           {
                p += INTALIGN(*(int32 *) p);
-           }
        }
        if (result)
        {
            if (!and)
-           {
                return (1);
-           }
        }
        else
        {
            if (and)
-           {
                return (0);
-           }
        }
    }
 
    if (and && result)
-   {
        return (1);
-   }
    else
-   {
        return (0);
-   }
 }
 
 /*
@@ -344,7 +332,7 @@ int32
 array_oideq(ArrayType *array, Oid value)
 {
    return array_iterator((Oid) 26,     /* oid */
-                         (Oid) 184,        /* oideq */
+                         (Oid) 184,    /* oideq */
                          0,    /* logical or */
                          array, (Datum) value);
 }
index 5eab8d985b384a3769d07057c77c250ed311ffe0..6e84088487902e8d327f6f430633aa5fd8156f89 100644 (file)
@@ -1,8 +1,7 @@
 #ifndef ARRAY_ITERATOR_H
 #define ARRAY_ITERATOR_H
 
-static int32
-array_iterator(Oid elemtype, Oid proc, int and,
+static int32 array_iterator(Oid elemtype, Oid proc, int and,
               ArrayType *array, Datum value);
 int32      array_texteq(ArrayType *array, char *value);
 int32      array_all_texteq(ArrayType *array, char *value);
@@ -24,6 +23,7 @@ int32     array_int4lt(ArrayType *array, int4 value);
 int32      array_all_int4lt(ArrayType *array, int4 value);
 int32      array_int4le(ArrayType *array, int4 value);
 int32      array_all_int4le(ArrayType *array, int4 value);
-int32           array_oideq(ArrayType *array, Oid value);
-int32           array_all_oidne(ArrayType *array, Oid value);
+int32      array_oideq(ArrayType *array, Oid value);
+int32      array_all_oidne(ArrayType *array, Oid value);
+
 #endif
index 11c0be64f600418e394af59a03764c2cab09700b..9dd0828457c0cca0ecb48dbc5e91bc94adef114f 100644 (file)
@@ -225,8 +225,8 @@ currentdate()
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index 0c106f670bf6108a25c88e6c11746f37bceaf043..8dbef7295cfe39ae63a70ec3dbd71cf857bb03b7 100644 (file)
@@ -4,23 +4,24 @@
 
 #include <postgres.h>
 #include <utils/geo_decls.h>   /* for Pt */
-#include <utils/palloc.h>  /* for palloc */
+#include <utils/palloc.h>      /* for palloc */
 
 /* Earth's radius is in statute miles. */
-const EARTH_RADIUS = 3958.747716;
-const TWO_PI = 2.0 * M_PI;
+const      EARTH_RADIUS = 3958.747716;
+const      TWO_PI = 2.0 * M_PI;
 
 /******************************************************
  *
  * degtorad - convert degrees to radians
  *
- * arg:    double, angle in degrees
+ * arg: double, angle in degrees
  *
- * returns:    double, same angle in radians
+ * returns: double, same angle in radians
  ******************************************************/
 
 static double
-degtorad (double degrees) {
+degtorad(double degrees)
+{
    return (degrees / 360.0) * TWO_PI;
 }
 
@@ -30,36 +31,40 @@ degtorad (double degrees) {
  * geo_distance - distance between points
  *
  * args:
- *   a pair of points - for each point,
- *     x-coordinate is longitude in degrees west of Greenwich
- *     y-coordinate is latitude in degrees above equator
+ *  a pair of points - for each point,
+ *    x-coordinate is longitude in degrees west of Greenwich
+ *    y-coordinate is latitude in degrees above equator
  *
- * returns:    double
- *   distance between the points in miles on earth's surface
+ * returns: double
+ *  distance between the points in miles on earth's surface
  ******************************************************/
 
 double *
-geo_distance (Point *pt1, Point *pt2) {
+geo_distance(Point *pt1, Point *pt2)
+{
 
-   double long1, lat1, long2, lat2;
-   double longdiff;
-   double * resultp = palloc (sizeof(double));
+   double      long1,
+               lat1,
+               long2,
+               lat2;
+   double      longdiff;
+   double     *resultp = palloc(sizeof(double));
 
    /* convert degrees to radians */
 
-   long1 = degtorad (pt1->x);
-   lat1 = degtorad (pt1->y);
+   long1 = degtorad(pt1->x);
+   lat1 = degtorad(pt1->y);
 
-   long2 = degtorad (pt2->x);
-   lat2 = degtorad (pt2->y);
+   long2 = degtorad(pt2->x);
+   lat2 = degtorad(pt2->y);
 
    /* compute difference in longitudes - want < 180 degrees */
-   longdiff = fabs (long1 - long2);
+   longdiff = fabs(long1 - long2);
    if (longdiff > M_PI)
        longdiff = TWO_PI - longdiff;
 
-   * resultp = EARTH_RADIUS * acos
-     (sin (lat1) * sin (lat2) + cos (lat1) * cos (lat2) * cos (longdiff));
+   *resultp = EARTH_RADIUS * acos
+       (sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(longdiff));
 
    return resultp;
 }
index 77e8c7475db8e58227d0d4f815f88dc9fd924c96..f1b82a14ef28021307f387d087f57ef0d445f5f7 100644 (file)
@@ -9,7 +9,8 @@
 #include <libpq-fe.h>
 #include "pginterface.h"
 
-PGresult *attres, *relres;
+PGresult   *attres,
+          *relres;
 
 int
 main(int argc, char **argv)
@@ -55,7 +56,7 @@ main(int argc, char **argv)
        ");
    doquery("FETCH ALL IN c_relations");
    relres = get_result();
-   
+
    set_result(attres);
    while (fetch(typname, relname, attname) != END_OF_TUPLES)
    {
@@ -65,17 +66,17 @@ main(int argc, char **argv)
        {
            unset_result(relres);
            if (strcmp(typname, "oid") == 0)
-               sprintf(query,"\
+               sprintf(query, "\
                    DECLARE c_matches BINARY CURSOR FOR \
-                   SELECT  count(*)
-                   FROM    %s t1, %s t2 \
-                   WHERE   t1.%s = t2.oid", relname, relname2, attname);
+                   SELECT  count(*) \
+                       FROM % s t1, %s t2 \
+                   WHERE t1.% s = t2.oid ", relname, relname2, attname);
            else
-               sprintf(query,"\
+               sprintf(query, "\
                    DECLARE c_matches BINARY CURSOR FOR \
-                   SELECT  count(*)
-                   FROM    %s t1, %s t2 \
-                   WHERE   RegprocToOid(t1.%s) = t2.oid", relname, relname2, attname);
+                   SELECT  count(*) \
+                               FROM % s t1, %s t2 \
+                               WHERE RegprocToOid(t1.% s) = t2.oid ", relname, relname2, attname);
 
            doquery(query);
            doquery("FETCH ALL IN c_matches");
@@ -96,7 +97,7 @@ main(int argc, char **argv)
    doquery("CLOSE c_attributes");
    PQclear(attres);
    unset_result(attres);
-   
+
    doquery("COMMIT WORK");
 
    disconnectdb();
index e5539b44576c1275584d736d9956d4a18cd61dcf..0291a48a274644e05161a3ea661bb4da03cdf732 100644 (file)
@@ -1,18 +1,18 @@
 #include "postgres.h"
 #include "executor/spi.h"
 #include "commands/trigger.h"
-#include <ctype.h> /* tolower */
-#include <stdio.h> /* debugging */
+#include <ctype.h>             /* tolower */
+#include <stdio.h>             /* debugging */
 
 /*
  * Trigger function takes 2 arguments:
-       1. relation in which to store the substrings
-       2. field to extract substrings from
+       1. relation in which to store the substrings
+       2. field to extract substrings from
 
    The relation in which to insert *must* have the following layout:
 
-           string      varchar(#)
-           id          oid
+       string      varchar(#)
+       id          oid
 
    Example:
 
@@ -24,9 +24,9 @@ create index title_fti_idx on title_fti (string);
 
 create trigger title_fti_trigger after update or insert or delete on product
 for each row execute procedure fti(title_fti, title);
-                                   ^^^^^^^^^
+                                  ^^^^^^^^^
                                   where to store index in
-                                             ^^^^^
+                                             ^^^^^
                                              which column to index
 
 ofcourse don't forget to create an index on title_idx, column string, else
@@ -39,8 +39,8 @@ select p.* from product p, title_fti f1, title_fti f2 where
 */
 
 /*
-    march 4 1998 Changed breakup() to return less substrings. Only breakup
-                in word parts which are in turn shortened from the start
+   march 4 1998 Changed breakup() to return less substrings. Only breakup
+                in word parts which are in turn shortened from the start
                 of the word (ie. word, ord, rd)
                 Did allocation of substring buffer outside of breakup()
    oct. 5 1997, fixed a bug in string breakup (where there are more nonalpha
@@ -62,14 +62,14 @@ select p.* from product p, title_fti f1, title_fti f2 where
    */
 
 HeapTuple  fti(void);
-char *breakup(char*, char*);
-bool is_stopword(char*);
+char      *breakup(char *, char *);
+bool       is_stopword(char *);
 
-bool new_tuple = false;
+bool       new_tuple = false;
 
 
 /* THIS LIST MUST BE IN SORTED ORDER, A BINARY SEARCH IS USED!!!! */
-char *StopWords[] = {      /* list of words to skip in indexing */
+char      *StopWords[] = {     /* list of words to skip in indexing */
 #ifdef SAMPLE_STOP_WORDS
    "no"
    "the",
@@ -88,7 +88,7 @@ typedef struct
 static EPlan *InsertPlans = NULL;
 static EPlan *DeletePlans = NULL;
 static int nInsertPlans = 0;
-static int  nDeletePlans = 0;
+static int nDeletePlans = 0;
 
 static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans);
 
@@ -96,28 +96,28 @@ static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans);
 HeapTuple
 fti()
 {
-   Trigger     *trigger;   /* to get trigger name */
-   int         nargs;      /* # of arguments */
-   char        **args;     /* arguments */
-   char        *relname;   /* triggered relation name */
-   Relation    rel;        /* triggered relation */
-   char        *indexname; /* name of table for substrings */
+   Trigger    *trigger;        /* to get trigger name */
+   int         nargs;          /* # of arguments */
+   char      **args;           /* arguments */
+   char       *relname;        /* triggered relation name */
+   Relation    rel;            /* triggered relation */
+   char       *indexname;      /* name of table for substrings */
    HeapTuple   rettuple = NULL;
-   TupleDesc   tupdesc;    /* tuple description */
-   bool        isinsert=false;
-   bool        isdelete=false;
+   TupleDesc   tupdesc;        /* tuple description */
+   bool        isinsert = false;
+   bool        isdelete = false;
    int         ret;
    char        query[8192];
    Oid         oid;
+
    /*
-     FILE      *debug;
-     */
+    * FILE      *debug;
+    */
 
    /*
-     debug = fopen("/dev/xconsole", "w");
-     fprintf(debug, "FTI: entered function\n");
-     fflush(debug);
-     */
+    * debug = fopen("/dev/xconsole", "w"); fprintf(debug, "FTI: entered
+    * function\n"); fflush(debug);
+    */
 
    if (!CurrentTriggerData)
        elog(ERROR, "Full Text Indexing: triggers are not initialized");
@@ -127,47 +127,53 @@ fti()
        elog(ERROR, "Full Text Indexing: must be fired AFTER event");
 
    if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
-       isinsert=true;
+       isinsert = true;
    if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
-   { isdelete=true;isinsert=true;}
+   {
+       isdelete = true;
+       isinsert = true;
+   }
    if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event))
-       isdelete=true;
+       isdelete = true;
 
    trigger = CurrentTriggerData->tg_trigger;
    rel = CurrentTriggerData->tg_relation;
    relname = SPI_getrelname(rel);
-   rettuple=CurrentTriggerData->tg_trigtuple;
-   if (isdelete&&isinsert) /* is an UPDATE */
-       rettuple=CurrentTriggerData->tg_newtuple;
+   rettuple = CurrentTriggerData->tg_trigtuple;
+   if (isdelete && isinsert)   /* is an UPDATE */
+       rettuple = CurrentTriggerData->tg_newtuple;
 
-   CurrentTriggerData = NULL; /* invalidate 'normal' calls to this function */
+   CurrentTriggerData = NULL;  /* invalidate 'normal' calls to this
+                                * function */
+
+   if ((ret = SPI_connect()) < 0)
+       elog(ERROR, "Full Text Indexing: SPI_connect failed, returned %d\n", ret);
 
-   if ((ret = SPI_connect()) <0)
-       elog(ERROR,"Full Text Indexing: SPI_connect failed, returned %d\n",ret);
-       
    nargs = trigger->tgnargs;
    if (nargs != 2)
        elog(ERROR, "Full Text Indexing: trigger can only have 2 arguments");
-       
+
    args = trigger->tgargs;
    indexname = args[0];
-   tupdesc = rel->rd_att;  /* what the tuple looks like (?) */
+   tupdesc = rel->rd_att;      /* what the tuple looks like (?) */
 
    /* get oid of current tuple, needed by all, so place here */
    oid = rettuple->t_data->t_oid;
    if (!OidIsValid(oid))
-       elog(ERROR,"Full Text Indexing: oid of current tuple is NULL");
+       elog(ERROR, "Full Text Indexing: oid of current tuple is NULL");
 
-   if (isdelete) {
-       void *pplan;
-       Oid *argtypes;
-       Datum values[1];
-       EPlan *plan;
+   if (isdelete)
+   {
+       void       *pplan;
+       Oid        *argtypes;
+       Datum       values[1];
+       EPlan      *plan;
 
        sprintf(query, "D%s$%s", args[0], args[1]);
        plan = find_plan(query, &DeletePlans, &nDeletePlans);
-       if (plan->nplans <= 0) {
-           argtypes = (Oid *)palloc(sizeof(Oid));
+       if (plan->nplans <= 0)
+       {
+           argtypes = (Oid *) palloc(sizeof(Oid));
 
            argtypes[0] = OIDOID;
 
@@ -181,7 +187,7 @@ fti()
                elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL "
                     "in delete");
 
-           plan->splan = (void **)malloc(sizeof(void*));
+           plan->splan = (void **) malloc(sizeof(void *));
            *(plan->splan) = pplan;
            plan->nplans = 1;
        }
@@ -192,26 +198,29 @@ fti()
        if (ret != SPI_OK_DELETE)
            elog(ERROR, "Full Text Indexing: error executing plan in delete");
    }
-   
-   if (isinsert) {
-       char *substring, *column;
-       void *pplan;
-       Oid  *argtypes;
-       Datum values[2];
-       int  colnum;
+
+   if (isinsert)
+   {
+       char       *substring,
+                  *column;
+       void       *pplan;
+       Oid        *argtypes;
+       Datum       values[2];
+       int         colnum;
        struct varlena *data;
-       EPlan *plan;
+       EPlan      *plan;
 
        sprintf(query, "I%s$%s", args[0], args[1]);
        plan = find_plan(query, &InsertPlans, &nInsertPlans);
 
        /* no plan yet, so allocate mem for argtypes */
-       if (plan->nplans <= 0) {
-           argtypes = (Oid *)palloc(2*sizeof(Oid));
+       if (plan->nplans <= 0)
+       {
+           argtypes = (Oid *) palloc(2 * sizeof(Oid));
 
-           argtypes[0] =   VARCHAROID; /*create table t_name
-                                               (string varchar, */
-           argtypes[1] =   OIDOID;     /*       id     oid);    */
+           argtypes[0] = VARCHAROID;   /* create table t_name (string
+                                        * varchar, */
+           argtypes[1] = OIDOID;       /* id     oid);    */
 
            /* prepare plan to gain speed */
            sprintf(query, "INSERT INTO %s (string, id) VALUES ($1, $2)",
@@ -226,45 +235,49 @@ fti()
                elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL"
                     " in insert");
 
-           plan->splan = (void **)malloc(sizeof(void*));
+           plan->splan = (void **) malloc(sizeof(void *));
            *(plan->splan) = pplan;
            plan->nplans = 1;
        }
-       
-       
+
+
        /* prepare plan for query */
-       colnum=SPI_fnumber(tupdesc, args[1]);
+       colnum = SPI_fnumber(tupdesc, args[1]);
        if (colnum == SPI_ERROR_NOATTRIBUTE)
            elog(ERROR, "Full Text Indexing: column '%s' of '%s' not found",
                 args[1], args[0]);
-       
+
        /* Get the char* representation of the column with name args[1] */
        column = SPI_getvalue(rettuple, tupdesc, colnum);
-       
-       if (column) { /* make sure we don't try to index NULL's */
-           char *buff;
-           char *string = column;
-           
-           while(*string != '\0') { /* placed 'really' inline. */
-               *string = tolower(*string); /* some compilers will choke */
-               string++;                   /* on 'inline' keyword */
+
+       if (column)
+       {                       /* make sure we don't try to index NULL's */
+           char       *buff;
+           char       *string = column;
+
+           while (*string != '\0')
+           {                   /* placed 'really' inline. */
+               *string = tolower(*string);     /* some compilers will
+                                                * choke */
+               string++;       /* on 'inline' keyword */
            }
 
-           data = (struct varlena*)palloc(sizeof(int32)+strlen(column)+1);
+           data = (struct varlena *) palloc(sizeof(int32) + strlen(column) +1);
            buff = palloc(strlen(column) + 1);
-           /* saves lots of calls in while-loop and in breakup()*/
+           /* saves lots of calls in while-loop and in breakup() */
 
-           new_tuple=true;
-           while ((substring = breakup(column, buff))) {
-               int l;
+           new_tuple = true;
+           while ((substring = breakup(column, buff)))
+           {
+               int         l;
 
                l = strlen(substring);
 
-               data->vl_len = l+sizeof(int32);
+               data->vl_len = l + sizeof(int32);
                memcpy(VARDATA(data), substring, l);
                values[0] = PointerGetDatum(data);
                values[1] = oid;
-               
+
                ret = SPI_execp(*(plan->splan), values, NULL, 0);
                if (ret != SPI_OK_INSERT)
                    elog(ERROR, "Full Text Indexing: error executing plan "
@@ -279,76 +292,83 @@ fti()
    return (rettuple);
 }
 
-char *breakup(char *string, char *substring)
+char *
+breakup(char *string, char *substring)
 {
    static char *last_start;
    static char *cur_pos;
 
    if (new_tuple)
    {
-       cur_pos=last_start=&string[strlen(string)-1];
-       new_tuple=false; /* don't initialize this next time */
+       cur_pos = last_start = &string[strlen(string) - 1];
+       new_tuple = false;      /* don't initialize this next time */
    }
 
-   while (cur_pos > string) /* don't read before start of 'string' */
+   while (cur_pos > string)    /* don't read before start of 'string' */
    {
-       /* skip pieces at the end of a string that are not
-          alfa-numeric (ie. 'string$%^&', last_start first points to
-          '&', and after this to 'g' */
-       if (!isalnum((int)*last_start)) {
-           while (!isalnum((int)*last_start) &&
+
+       /*
+        * skip pieces at the end of a string that are not alfa-numeric
+        * (ie. 'string$%^&', last_start first points to '&', and after
+        * this to 'g'
+        */
+       if (!isalnum((int) *last_start))
+       {
+           while (!isalnum((int) *last_start) &&
                   last_start > string)
                last_start--;
-           cur_pos=last_start;
+           cur_pos = last_start;
        }
 
-       cur_pos--; /* substrings are at minimum 2 characters long */
+       cur_pos--;              /* substrings are at minimum 2 characters
+                                * long */
 
-       if (isalnum((int)*cur_pos))
+       if (isalnum((int) *cur_pos))
        {
            /* Houston, we have a substring! :) */
            memcpy(substring, cur_pos, last_start - cur_pos + 1);
-           substring[last_start-cur_pos+1]='\0';
-           if (!is_stopword(substring)) return substring;
+           substring[last_start - cur_pos + 1] = '\0';
+           if (!is_stopword(substring))
+               return substring;
        }
        else
        {
-           last_start=cur_pos-1;
+           last_start = cur_pos - 1;
            cur_pos = last_start;
        }
    }
 
-   return NULL; /* we've processed all of 'string' */
+   return NULL;                /* we've processed all of 'string' */
 }
 
 /* copied from src/backend/parser/keywords.c and adjusted for our situation*/
 bool
 is_stopword(char *text)
 {
-   char **StopLow;     /* for list of stop-words */
-   char **StopHigh;
-   char **StopMiddle;
-    unsigned int         difference;
+   char      **StopLow;        /* for list of stop-words */
+   char      **StopHigh;
+   char      **StopMiddle;
+   unsigned int difference;
 
-   StopLow = &StopWords[0];        /* initialize stuff for binary search */
+   StopLow = &StopWords[0];    /* initialize stuff for binary search */
    StopHigh = endof(StopWords);
 
    if (lengthof(StopWords) == 0)
        return false;
-       
-    while (StopLow <= StopHigh)
-    {
-        StopMiddle = StopLow + (StopHigh - StopLow) / 2;
-        difference = strcmp(*StopMiddle, text);
-        if (difference == 0)
-            return (true);
-        else if (difference < 0)
-            StopLow = StopMiddle + 1;
-        else
-            StopHigh = StopMiddle - 1;
-    }
-
-    return (false);
+
+   while (StopLow <= StopHigh)
+   {
+       StopMiddle = StopLow + (StopHigh - StopLow) / 2;
+       difference = strcmp(*StopMiddle, text);
+       if (difference == 0)
+           return (true);
+       else if (difference < 0)
+           StopLow = StopMiddle + 1;
+       else
+           StopHigh = StopMiddle - 1;
+   }
+
+   return (false);
 }
 
 /* for caching of query plans, stolen from contrib/spi/\*.c */
index ed608f3e1330c6922ef23f1356adbb4eeb224b75..5f4ac8890515464b9cd487b37f6f612848a2cf73 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PostgreSQL type definitions for ISBNs.
  *
- * $Id: isbn.c,v 1.1 1998/08/17 03:35:04 scrappy Exp $
+ * $Id: isbn.c,v 1.2 1999/05/25 16:05:40 momjian Exp $
  */
 
 #include <stdio.h>
@@ -16,8 +16,8 @@
 
 typedef struct isbn
 {
-   char    num[13];
-   char    pad[3];
+   char        num[13];
+   char        pad[3];
 }          isbn;
 
 /*
@@ -50,13 +50,15 @@ isbn_in(char *str)
    char       *cp;
    int         count;
 
-   if (strlen(str) != 13) {
+   if (strlen(str) != 13)
+   {
        elog(ERROR, "isbn_in: invalid ISBN \"%s\"", str);
        return (NULL);
    }
-   if (isbn_sum(str) != 0) {
+   if (isbn_sum(str) != 0)
+   {
        elog(ERROR, "isbn_in: purported ISBN \"%s\" failed checksum",
-            str);
+            str);
        return (NULL);
    }
 
@@ -84,28 +86,40 @@ isbn_in(char *str)
 int4
 isbn_sum(char *str)
 {
-   int4 sum = 0, dashes = 0, val;
-   int i;
-
-   for (i = 0; str[i] && i < 13; i++) {
-       switch(str[i]) {
-       case '-':
-           if (++dashes > 3)
+   int4        sum = 0,
+               dashes = 0,
+               val;
+   int         i;
+
+   for (i = 0; str[i] && i < 13; i++)
+   {
+       switch (str[i])
+       {
+           case '-':
+               if (++dashes > 3)
+                   return 12;
+               continue;
+
+           case '0':
+           case '1':
+           case '2':
+           case '3':
+           case '4':
+           case '5':
+           case '6':
+           case '7':
+           case '8':
+           case '9':
+               val = str[i] - '0';
+               break;
+
+           case 'X':
+           case 'x':
+               val = 10;
+               break;
+
+           default:
                return 12;
-           continue;
-
-       case '0': case '1': case '2': case '3':
-       case '4': case '5': case '6': case '7':
-       case '8': case '9':
-           val = str[i] - '0';
-           break;
-
-       case 'X': case 'x':
-           val = 10;
-           break;
-
-       default:
-           return 12;
        }
 
        sum += val * (i + 1 - dashes);
index 8f5aa22f7c436bf08a85d9e00c4e1d733ffdb688..ccb264ac8f7f6363f7eccd92f57cb99c298e6efb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PostgreSQL type definitions for ISSNs.
  *
- * $Id: issn.c,v 1.1 1998/08/17 03:35:05 scrappy Exp $
+ * $Id: issn.c,v 1.2 1999/05/25 16:05:42 momjian Exp $
  */
 
 #include <stdio.h>
@@ -16,8 +16,8 @@
 
 typedef struct issn
 {
-   char    num[9];
-   char    pad[7];
+   char        num[9];
+   char        pad[7];
 }          issn;
 
 /*
@@ -50,13 +50,15 @@ issn_in(char *str)
    char       *cp;
    int         count;
 
-   if (strlen(str) != 9) {
+   if (strlen(str) != 9)
+   {
        elog(ERROR, "issn_in: invalid ISSN \"%s\"", str);
        return (NULL);
    }
-   if (issn_sum(str) != 0) {
+   if (issn_sum(str) != 0)
+   {
        elog(ERROR, "issn_in: purported ISSN \"%s\" failed checksum",
-            str);
+            str);
        return (NULL);
    }
 
@@ -75,28 +77,40 @@ issn_in(char *str)
 int4
 issn_sum(char *str)
 {
-   int4 sum = 0, dashes = 0, val;
-   int i;
-
-   for (i = 0; str[i] && i < 9; i++) {
-       switch(str[i]) {
-       case '-':
-           if (++dashes > 1)
+   int4        sum = 0,
+               dashes = 0,
+               val;
+   int         i;
+
+   for (i = 0; str[i] && i < 9; i++)
+   {
+       switch (str[i])
+       {
+           case '-':
+               if (++dashes > 1)
+                   return 12;
+               continue;
+
+           case '0':
+           case '1':
+           case '2':
+           case '3':
+           case '4':
+           case '5':
+           case '6':
+           case '7':
+           case '8':
+           case '9':
+               val = str[i] - '0';
+               break;
+
+           case 'X':
+           case 'x':
+               val = 10;
+               break;
+
+           default:
                return 12;
-           continue;
-
-       case '0': case '1': case '2': case '3':
-       case '4': case '5': case '6': case '7':
-       case '8': case '9':
-           val = str[i] - '0';
-           break;
-
-       case 'X': case 'x':
-           val = 10;
-           break;
-
-       default:
-           return 12;
        }
 
        sum += val * (8 - (i - dashes));
index 96af1df3d9e0fac0ed542364b91c837d916d26da..3b0c1e2614242fe4b93c9ff9923f23c4287917b8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PostgreSQL type definitions for managed LargeObjects.
  *
- * $Id: lo.c,v 1.1 1998/06/16 07:07:11 momjian Exp $
+ * $Id: lo.c,v 1.2 1999/05/25 16:05:45 momjian Exp $
  *
  */
 
@@ -33,11 +33,11 @@ typedef Oid Blob;
  * Various forward declarations:
  */
 
-Blob          *lo_in(char *str);   /* Create from String       */
-char      *lo_out(Blob * addr);    /* Output oid as String     */
-Oid            lo_oid(Blob * addr);    /* Return oid as an oid     */
-Blob          *lo(Oid oid);        /* Return Blob based on oid */
-HeapTuple  lo_manage(void);        /* Trigger handler          */
+Blob      *lo_in(char *str);   /* Create from String       */
+char      *lo_out(Blob * addr);/* Output oid as String     */
+Oid            lo_oid(Blob * addr);/* Return oid as an oid     */
+Blob      *lo(Oid oid);        /* Return Blob based on oid */
+HeapTuple  lo_manage(void);    /* Trigger handler          */
 
 /*
  * This creates a large object, and set's its OID to the value in the
@@ -49,45 +49,46 @@ HeapTuple   lo_manage(void);        /* Trigger handler          */
 Blob *
 lo_in(char *str)
 {
-  Blob *result;
-  Oid oid;
-  int          count;
-  
-  if (strlen(str) > 0)
+   Blob       *result;
+   Oid         oid;
+   int         count;
+
+   if (strlen(str) > 0)
    {
-     
-     count = sscanf(str, "%d", &oid);
-     
-     if (count < 1)
+
+       count = sscanf(str, "%d", &oid);
+
+       if (count < 1)
        {
-         elog(ERROR, "lo_in: error in parsing \"%s\"", str);
-         return (NULL);
+           elog(ERROR, "lo_in: error in parsing \"%s\"", str);
+           return (NULL);
        }
-     
-     if(oid < 0)
+
+       if (oid < 0)
        {
-         elog(ERROR, "lo_in: illegal oid \"%s\"", str);
-         return (NULL);
+           elog(ERROR, "lo_in: illegal oid \"%s\"", str);
+           return (NULL);
        }
    }
-  else
+   else
    {
-     /*
-      * There is no Oid passed, so create a new one
-      */
-     oid = lo_creat(INV_READ|INV_WRITE);
-     if(oid == InvalidOid)
+
+       /*
+        * There is no Oid passed, so create a new one
+        */
+       oid = lo_creat(INV_READ | INV_WRITE);
+       if (oid == InvalidOid)
        {
-         elog(ERROR,"lo_in: InvalidOid returned from lo_creat");
-         return (NULL);
+           elog(ERROR, "lo_in: InvalidOid returned from lo_creat");
+           return (NULL);
        }
    }
-  
-  result = (Blob *) palloc(sizeof(Blob));
-  
-  *result = oid;
-  
-  return (result);
+
+   result = (Blob *) palloc(sizeof(Blob));
+
+   *result = oid;
+
+   return (result);
 }
 
 /*
@@ -96,42 +97,43 @@ lo_in(char *str)
 char *
 lo_out(Blob * addr)
 {
-  char    *result;
-  
-  if (addr == NULL)
-   return (NULL);
-  
-  result = (char *) palloc(32);
-  sprintf(result,"%d",*addr);
-  return (result);
+   char       *result;
+
+   if (addr == NULL)
+       return (NULL);
+
+   result = (char *) palloc(32);
+   sprintf(result, "%d", *addr);
+   return (result);
 }
 
 /*
  * This function converts Blob to oid.
  *
  * eg: select lo_export(raster::oid,'/path/file') from table;
- * 
+ *
  */
 Oid
 lo_oid(Blob * addr)
 {
-  if(addr == NULL)
-   return InvalidOid;
-  return (Oid)(*addr);
+   if (addr == NULL)
+       return InvalidOid;
+   return (Oid) (*addr);
 }
 
 /*
  * This function is used so we can convert oid's to lo's
  *
- * ie:  insert into table values(lo_import('/path/file')::lo);
+ * ie: insert into table values(lo_import('/path/file')::lo);
  *
  */
 Blob *
 lo(Oid oid)
 {
-  Blob *result = (Blob *) palloc(sizeof(Blob));
-  *result = oid;
-  return (result);
+   Blob       *result = (Blob *) palloc(sizeof(Blob));
+
+   *result = oid;
+   return (result);
 }
 
 /*
@@ -140,74 +142,77 @@ lo(Oid oid)
 HeapTuple
 lo_manage(void)
 {
-  int attnum;                  /* attribute number to monitor  */
-  char **args;                 /* Args containing attr name    */
-  TupleDesc    tupdesc;            /* Tuple Descriptor             */
-  HeapTuple    rettuple;           /* Tuple to be returned         */
-  bool     isdelete;           /* are we deleting?             */
-  HeapTuple newtuple=NULL;     /* The new value for tuple      */
-  HeapTuple trigtuple;         /* The original value of tuple  */
-  
-  if (!CurrentTriggerData)
-   elog(ERROR, "lo: triggers are not initialized");
-  
-  /*
-   * Fetch some values from CurrentTriggerData
-   */
-  newtuple = CurrentTriggerData->tg_newtuple;
-  trigtuple    = CurrentTriggerData->tg_trigtuple;
-  tupdesc  = CurrentTriggerData->tg_relation->rd_att;
-  args     = CurrentTriggerData->tg_trigger->tgargs;
-  
-  /* tuple to return to Executor */
-  if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
-   rettuple = newtuple;
-  else
-   rettuple = trigtuple;
-  
-  /* Are we deleting the row? */
-  isdelete = TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event);
-  
-  /* Were done with it */
-  CurrentTriggerData = NULL;
-  
-  /* Get the column were interested in */
-  attnum = SPI_fnumber(tupdesc,args[0]);
-  
-  /*
-   * Handle updates
-   *
-   * Here, if the value of the monitored attribute changes, then the
-   * large object associated with the original value is unlinked.
-   */
-  if(newtuple!=NULL) {
-   char *orig = SPI_getvalue(trigtuple,tupdesc,attnum);
-   char *newv = SPI_getvalue(newtuple,tupdesc,attnum);
-   
-   if((orig != newv && (orig==NULL || newv==NULL)) || (orig!=NULL && newv!=NULL && strcmp(orig,newv)))
-     lo_unlink(atoi(orig));
-   
-   if(newv)
-     pfree(newv);
-   if(orig)
-     pfree(orig);
-  }
-  
-  /*
-   * Handle deleting of rows
-   *
-   * Here, we unlink the large object associated with the managed attribute
-   *
-   */
-  if(isdelete) {
-   char *orig = SPI_getvalue(trigtuple,tupdesc,attnum);
-   
-   if(orig != NULL) {
-     lo_unlink(atoi(orig));
-     
-     pfree(orig);
+   int         attnum;         /* attribute number to monitor  */
+   char      **args;           /* Args containing attr name    */
+   TupleDesc   tupdesc;        /* Tuple Descriptor             */
+   HeapTuple   rettuple;       /* Tuple to be returned         */
+   bool        isdelete;       /* are we deleting?             */
+   HeapTuple   newtuple = NULL;/* The new value for tuple      */
+   HeapTuple   trigtuple;      /* The original value of tuple  */
+
+   if (!CurrentTriggerData)
+       elog(ERROR, "lo: triggers are not initialized");
+
+   /*
+    * Fetch some values from CurrentTriggerData
+    */
+   newtuple = CurrentTriggerData->tg_newtuple;
+   trigtuple = CurrentTriggerData->tg_trigtuple;
+   tupdesc = CurrentTriggerData->tg_relation->rd_att;
+   args = CurrentTriggerData->tg_trigger->tgargs;
+
+   /* tuple to return to Executor */
+   if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
+       rettuple = newtuple;
+   else
+       rettuple = trigtuple;
+
+   /* Are we deleting the row? */
+   isdelete = TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event);
+
+   /* Were done with it */
+   CurrentTriggerData = NULL;
+
+   /* Get the column were interested in */
+   attnum = SPI_fnumber(tupdesc, args[0]);
+
+   /*
+    * Handle updates
+    *
+    * Here, if the value of the monitored attribute changes, then the large
+    * object associated with the original value is unlinked.
+    */
+   if (newtuple != NULL)
+   {
+       char       *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
+       char       *newv = SPI_getvalue(newtuple, tupdesc, attnum);
+
+       if ((orig != newv && (orig == NULL || newv == NULL)) || (orig != NULL && newv != NULL && strcmp(orig, newv)))
+           lo_unlink(atoi(orig));
+
+       if (newv)
+           pfree(newv);
+       if (orig)
+           pfree(orig);
    }
-  }
-  
-  return (rettuple);
+
+   /*
+    * Handle deleting of rows
+    *
+    * Here, we unlink the large object associated with the managed attribute
+    *
+    */
+   if (isdelete)
+   {
+       char       *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
+
+       if (orig != NULL)
+       {
+           lo_unlink(atoi(orig));
+
+           pfree(orig);
+       }
+   }
+
+   return (rettuple);
 }
index 2f39d7cad96e8dbbe6c8afad6b94cdd2955c1dc5..5b35fe1638edb9706048760d9ea6a6ce21c2d040 100644 (file)
 
 #define HNDMAX 10
 
-PGconn *PGh[HNDMAX] = {
-   NULL, NULL, NULL, NULL, NULL,
-   NULL, NULL, NULL, NULL, NULL
+PGconn    *PGh[HNDMAX] = {
+   NULL, NULL, NULL, NULL, NULL,
+   NULL, NULL, NULL, NULL, NULL
 };
 
 #define E_NOHANDLERS 0
 
-char *msqlErrors[] = {
-   "Out of database handlers."
+char      *msqlErrors[] = {
+   "Out of database handlers."
 };
 
-char msqlErrMsg[BUFSIZ], *tfrom = "dunno";
-PGresult *queryres = NULL;
-
-int msqlConnect (char *host) {
-   int count;
-   
-   for (count = 0; count < HNDMAX; count++) 
-      if (PGh[count] == NULL) break;
-      
-   if (count == HNDMAX) {
-      strncpy(msqlErrMsg, msqlErrors[E_NOHANDLERS], BUFSIZ);
-      return -1;
-   }
-
-   PGh[count] = malloc(sizeof (PGconn));
-   PGh[count]->pghost = host ? strdup(host) : NULL;
-   return count;
-}
+char       msqlErrMsg[BUFSIZ],
+          *tfrom = "dunno";
+PGresult   *queryres = NULL;
+
+int
+msqlConnect(char *host)
+{
+   int         count;
+
+   for (count = 0; count < HNDMAX; count++)
+       if (PGh[count] == NULL)
+           break;
 
-int msqlSelectDB(int handle, char *dbname) {
-   char *options = calloc(1, BUFSIZ);
-   char *e = getenv("PG_OPTIONS");
-   
-   if (e == NULL) 
-      e = "";
-   
-   if (PGh[handle]->pghost) {
-      strcat(options, "host=");
-      strncat(options, PGh[handle]->pghost, BUFSIZ);
-      strncat(options, " ", BUFSIZ);
-      free(PGh[handle]->pghost);
-      PGh[handle]->pghost = NULL;
-   }
-   strncat(options, "dbname=", BUFSIZ);
-   strncat(options, dbname, BUFSIZ);
-   strncat(options, " ", BUFSIZ);
-   strncat(options, e, BUFSIZ);
-   free(PGh[handle]);
-   PGh[handle] = PQconnectdb(options);
-   free(options);
-   strncpy(msqlErrMsg, PQerrorMessage(PGh[handle]), BUFSIZ);
-   return (PQstatus(PGh[handle]) == CONNECTION_BAD ? -1 : 0);
+   if (count == HNDMAX)
+   {
+       strncpy(msqlErrMsg, msqlErrors[E_NOHANDLERS], BUFSIZ);
+       return -1;
+   }
+
+   PGh[count] = malloc(sizeof(PGconn));
+   PGh[count]->pghost = host ? strdup(host) : NULL;
+   return count;
 }
 
-int msqlQuery(int handle, char *query) {
-   char *tq = strdup(query);
-   char *p = tq;
-   PGresult *res;
-   PGconn *conn = PGh[handle];
-   ExecStatusType rcode;
-   
-   res = PQexec(conn, p);
-
-   rcode = PQresultStatus(res);
-    
-   if (rcode == PGRES_TUPLES_OK) {
-      queryres = res;
-      return PQntuples(res);
-   } else if (rcode == PGRES_FATAL_ERROR || rcode == PGRES_NONFATAL_ERROR) {
-      PQclear(res);
-      queryres = NULL;
-      return -1;
-   } else {
-      PQclear(res);
-      queryres = NULL;
-      return 0;
-   }
+int
+msqlSelectDB(int handle, char *dbname)
+{
+   char       *options = calloc(1, BUFSIZ);
+   char       *e = getenv("PG_OPTIONS");
+
+   if (e == NULL)
+       e = "";
+
+   if (PGh[handle]->pghost)
+   {
+       strcat(options, "host=");
+       strncat(options, PGh[handle]->pghost, BUFSIZ);
+       strncat(options, " ", BUFSIZ);
+       free(PGh[handle]->pghost);
+       PGh[handle]->pghost = NULL;
+   }
+   strncat(options, "dbname=", BUFSIZ);
+   strncat(options, dbname, BUFSIZ);
+   strncat(options, " ", BUFSIZ);
+   strncat(options, e, BUFSIZ);
+   free(PGh[handle]);
+   PGh[handle] = PQconnectdb(options);
+   free(options);
+   strncpy(msqlErrMsg, PQerrorMessage(PGh[handle]), BUFSIZ);
+   return (PQstatus(PGh[handle]) == CONNECTION_BAD ? -1 : 0);
 }
 
-int msqlCreateDB (int a, char*b) {
-   char tbuf[BUFSIZ];
-   sprintf(tbuf, "create database %s", b);
-   return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
+int
+msqlQuery(int handle, char *query)
+{
+   char       *tq = strdup(query);
+   char       *p = tq;
+   PGresult   *res;
+   PGconn     *conn = PGh[handle];
+   ExecStatusType rcode;
+
+   res = PQexec(conn, p);
+
+   rcode = PQresultStatus(res);
+
+   if (rcode == PGRES_TUPLES_OK)
+   {
+       queryres = res;
+       return PQntuples(res);
+   }
+   else if (rcode == PGRES_FATAL_ERROR || rcode == PGRES_NONFATAL_ERROR)
+   {
+       PQclear(res);
+       queryres = NULL;
+       return -1;
+   }
+   else
+   {
+       PQclear(res);
+       queryres = NULL;
+       return 0;
+   }
 }
 
-int msqlDropDB (int a, char* b) {
-   char tbuf[BUFSIZ];
-   sprintf(tbuf, "drop database %s", b);
-   return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
+int
+msqlCreateDB(int a, char *b)
+{
+   char        tbuf[BUFSIZ];
+
+   sprintf(tbuf, "create database %s", b);
+   return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
 }
 
-int msqlShutdown(int a) {
+int
+msqlDropDB(int a, char *b)
+{
+   char        tbuf[BUFSIZ];
+
+   sprintf(tbuf, "drop database %s", b);
+   return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
 }
 
-int msqlGetProtoInfo(void) {
+int
+msqlShutdown(int a)
+{
 }
 
-int msqlReloadAcls(int a) {
+int
+msqlGetProtoInfo(void)
+{
 }
 
-char *msqlGetServerInfo(void) {
+int
+msqlReloadAcls(int a)
+{
 }
 
-char *msqlGetHostInfo(void) {
+char *
+msqlGetServerInfo(void)
+{
 }
 
-char *msqlUnixTimeToDate(time_t date) {
+char *
+msqlGetHostInfo(void)
+{
 }
 
-char *msqlUnixTimeToTime(time_t time) {
+char *
+msqlUnixTimeToDate(time_t date)
+{
 }
 
-void msqlClose(int a) {
-    PQfinish(PGh[a]);
-    PGh[a] = NULL;
-    if (queryres) {
-       free(queryres);
-       queryres = NULL;
-    }
+char *
+msqlUnixTimeToTime(time_t time)
+{
 }
 
-void msqlDataSeek(m_result *result, int count) {
-   int c;
-   result->cursor = result->queryData;
-   for (c = 1; c < count; c++)
-      if (result->cursor->next)
-         result->cursor = result->cursor->next;
+void
+msqlClose(int a)
+{
+   PQfinish(PGh[a]);
+   PGh[a] = NULL;
+   if (queryres)
+   {
+       free(queryres);
+       queryres = NULL;
+   }
 }
 
-void msqlFieldSeek(m_result *result, int count) {
-   int c;
-   result->fieldCursor = result->fieldData;
-   for (c = 1; c < count; c++)
-      if (result->fieldCursor->next)
-         result->fieldCursor = result->fieldCursor->next;
+void
+msqlDataSeek(m_result * result, int count)
+{
+   int         c;
+
+   result->cursor = result->queryData;
+   for (c = 1; c < count; c++)
+       if (result->cursor->next)
+           result->cursor = result->cursor->next;
 }
 
-void msqlFreeResult(m_result *result) {
-   if (result) {
-      /* Clears fields */
-      free(result->fieldData);
-      result->cursor = result->queryData;
-      while (result->cursor) {
-         int c;
-         m_row m = result->cursor->data;
-         
-         for (c = 0; m[c]; c++)
-            free(m[c]);
-
-         result->cursor = result->cursor->next;
-      } 
-      free(result->queryData);
-      free(result);
-   }  
+void
+msqlFieldSeek(m_result * result, int count)
+{
+   int         c;
+
+   result->fieldCursor = result->fieldData;
+   for (c = 1; c < count; c++)
+       if (result->fieldCursor->next)
+           result->fieldCursor = result->fieldCursor->next;
 }
 
-m_row msqlFetchRow(m_result *row) {
-   m_data *r = row->cursor;
-   if (r) {
-      row->cursor = row->cursor->next;
-      return (m_row)r->data;
-   }
-   return (m_row)NULL;
+void
+msqlFreeResult(m_result * result)
+{
+   if (result)
+   {
+       /* Clears fields */
+       free(result->fieldData);
+       result->cursor = result->queryData;
+       while (result->cursor)
+       {
+           int         c;
+           m_row       m = result->cursor->data;
+
+           for (c = 0; m[c]; c++)
+               free(m[c]);
+
+           result->cursor = result->cursor->next;
+       }
+       free(result->queryData);
+       free(result);
+   }
 }
 
-m_seq *msqlGetSequenceInfo(int a, char *b) {
+m_row
+msqlFetchRow(m_result * row)
+{
+   m_data     *r = row->cursor;
+
+   if (r)
+   {
+       row->cursor = row->cursor->next;
+       return (m_row) r->data;
+   }
+   return (m_row) NULL;
 }
 
-m_field *msqlFetchField (m_result *mr) {
-   m_field *m = (m_field*)mr->fieldCursor;
-   if (m) {
-      mr->fieldCursor = mr->fieldCursor->next;
-      return m;
-   }
-   return NULL;
+m_seq *
+msqlGetSequenceInfo(int a, char *b)
+{
 }
 
-m_result *msqlListDBs(int a) {
-   m_result *m;
-   if (msqlQuery(a, "select datname from pg_database") > 0) {
-      m = msqlStoreResult();
-      return m;
-   } else return NULL;
+m_field    *
+msqlFetchField(m_result * mr)
+{
+   m_field    *m = (m_field *) mr->fieldCursor;
+
+   if (m)
+   {
+       mr->fieldCursor = mr->fieldCursor->next;
+       return m;
+   }
+   return NULL;
 }
 
-m_result *msqlListTables(int a) {
-   m_result *m;
-   char tbuf[BUFSIZ];
-   
-   sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid());
-   if (msqlQuery(a, tbuf) > 0) {
-      m = msqlStoreResult();
-      return m;
-   } else return NULL;
+m_result   *
+msqlListDBs(int a)
+{
+   m_result   *m;
+
+   if (msqlQuery(a, "select datname from pg_database") > 0)
+   {
+       m = msqlStoreResult();
+       return m;
+   }
+   else
+       return NULL;
 }
 
-m_result *msqlListFields(int a, char *b) {
-   
+m_result   *
+msqlListTables(int a)
+{
+   m_result   *m;
+   char        tbuf[BUFSIZ];
+
+   sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid());
+   if (msqlQuery(a, tbuf) > 0)
+   {
+       m = msqlStoreResult();
+       return m;
+   }
+   else
+       return NULL;
 }
 
-m_result *msqlListIndex(int a, char *b, char *c) {
-   m_result *m;
-   char tbuf[BUFSIZ];
-   
-   sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid());
-   if (msqlQuery(a, tbuf) > 0) {
-      m = msqlStoreResult();
-      return m;
-   } else return NULL;
+m_result   *
+msqlListFields(int a, char *b)
+{
+
 }
 
-m_result *msqlStoreResult(void) {
-   if (queryres) {
-      m_result *mr = malloc(sizeof(m_result));
-      m_fdata *mf;
-      m_data *md;
-      int count;
-      mr->queryData = mr->cursor = NULL;
-      mr->numRows = PQntuples(queryres);  
-      mr->numFields = PQnfields(queryres);
-      
-      mf = calloc(PQnfields(queryres), sizeof(m_fdata));      
-      for (count = 0; count < PQnfields(queryres); count++) {
-         (m_fdata*)(mf+count)->field.name = strdup(PQfname(queryres, count)); 
-         (m_fdata*)(mf+count)->field.table = tfrom; 
-         (m_fdata*)(mf+count)->field.type = CHAR_TYPE;
-         (m_fdata*)(mf+count)->field.length = PQfsize(queryres, count);
-         (m_fdata*)(mf+count)->next = (m_fdata*)(mf+count+1);
-      }
-      (m_fdata*)(mf+count-1)->next = NULL;
-      
-      md = calloc(PQntuples(queryres), sizeof(m_data));
-      for (count = 0; count < PQntuples(queryres); count++) {
-         m_row rows = calloc(PQnfields(queryres)*sizeof(m_row)+1, 1);
-         int c;
-         
-         for (c = 0; c < PQnfields(queryres); c++) {
-            rows[c] = strdup(PQgetvalue(queryres, count, c));
-         }
-         (m_data*)(md+count)->data = rows;
-         
-         (m_data*)(md+count)->width = PQnfields(queryres);
-         (m_data*)(md+count)->next = (m_data*)(md+count+1);
-      }
-      (m_data*)(md+count-1)->next = NULL;
-      
-      mr->queryData = mr->cursor = md;
-      mr->fieldCursor = mr->fieldData = mf;
-
-      return mr;
-   } else return NULL;
+m_result   *
+msqlListIndex(int a, char *b, char *c)
+{
+   m_result   *m;
+   char        tbuf[BUFSIZ];
+
+   sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid());
+   if (msqlQuery(a, tbuf) > 0)
+   {
+       m = msqlStoreResult();
+       return m;
+   }
+   else
+       return NULL;
 }
 
-time_t msqlDateToUnixTime(char *a) {
+m_result   *
+msqlStoreResult(void)
+{
+   if (queryres)
+   {
+       m_result   *mr = malloc(sizeof(m_result));
+       m_fdata    *mf;
+       m_data     *md;
+       int         count;
+
+       mr->queryData = mr->cursor = NULL;
+       mr->numRows = PQntuples(queryres);
+       mr->numFields = PQnfields(queryres);
+
+       mf = calloc(PQnfields(queryres), sizeof(m_fdata));
+       for (count = 0; count < PQnfields(queryres); count++)
+       {
+           (m_fdata *) (mf + count)->field.name = strdup(PQfname(queryres, count));
+           (m_fdata *) (mf + count)->field.table = tfrom;
+           (m_fdata *) (mf + count)->field.type = CHAR_TYPE;
+           (m_fdata *) (mf + count)->field.length = PQfsize(queryres, count);
+           (m_fdata *) (mf + count)->next = (m_fdata *) (mf + count + 1);
+       }
+       (m_fdata *) (mf + count - 1)->next = NULL;
+
+       md = calloc(PQntuples(queryres), sizeof(m_data));
+       for (count = 0; count < PQntuples(queryres); count++)
+       {
+           m_row       rows = calloc(PQnfields(queryres) * sizeof(m_row) + 1, 1);
+           int         c;
+
+           for (c = 0; c < PQnfields(queryres); c++)
+               rows[c] = strdup(PQgetvalue(queryres, count, c));
+           (m_data *) (md + count)->data = rows;
+
+           (m_data *) (md + count)->width = PQnfields(queryres);
+           (m_data *) (md + count)->next = (m_data *) (md + count + 1);
+       }
+       (m_data *) (md + count - 1)->next = NULL;
+
+       mr->queryData = mr->cursor = md;
+       mr->fieldCursor = mr->fieldData = mf;
+
+       return mr;
+   }
+   else
+       return NULL;
 }
 
-time_t msqlTimeToUnixTime(char *b) {
+time_t
+msqlDateToUnixTime(char *a)
+{
 }
 
-char *msql_tmpnam(void) {
-   return tmpnam("/tmp/msql.XXXXXX");
+time_t
+msqlTimeToUnixTime(char *b)
+{
 }
 
-int msqlLoadConfigFile(char *a) {
+char *
+msql_tmpnam(void)
+{
+   return tmpnam("/tmp/msql.XXXXXX");
 }
 
+int
+msqlLoadConfigFile(char *a)
+{
+}
index ee2f3ec2b28c545b18b653a3ef29ed75769bda0f..24d069f71c29bdf5b80172d50383fb96417f42f2 100644 (file)
@@ -23,6 +23,7 @@ extern int    assertTest(int val);
 
 #ifdef ASSERT_CHECKING_TEST
 extern int assertEnable(int val);
+
 #endif
 
 int
@@ -68,14 +69,15 @@ assert_test(int val)
 {
    return assertTest(val);
 }
+
 #endif
 
 /* end of file */
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index cc7f923443228f5fe76f8f615c93574513c156ab..e82fd4a29d1e5389d8457c392b869a9ec7cbd816 100644 (file)
@@ -7,16 +7,18 @@ int           unlisten(char *relname);
 int            max(int x, int y);
 int            min(int x, int y);
 int            assert_enable(int val);
+
 #ifdef ASSERT_CHECKING_TEST
 int            assert_test(int val);
+
 #endif
 
 #endif
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index efbe031239d62f2234d1ecbd0c242aa6eb9f24bb..ecbbd3d5ed233cbc5b9dec856ff7fa8aaf126b06 100644 (file)
@@ -12,7 +12,7 @@ HeapTuple noup(void);
  * noup () -- revoke permission on column
  *
  * Though it's called without args You have to specify referenced
- * table/column while creating trigger:  
+ * table/column while creating trigger:
  * EXECUTE PROCEDURE noup ('col').
  */
 
@@ -98,8 +98,8 @@ noup()
         */
        if (!isnull)
        {
-   
-           elog(WARN, "%s: update not allowed", args[i] );
+
+           elog(WARN, "%s: update not allowed", args[i]);
            SPI_finish();
            return NULL;
        }
index 5fbc5ae22eea7ce3ca6580f21e7ba75ab4a84888..8c7ed3fe2a562ebddef8200643f689b518f68c88 100644 (file)
@@ -1,5 +1,5 @@
-#undef PORTNAME \r
-#define PORTNAME OS2 \r
+#undef PORTNAME\r
+#define PORTNAME OS2\r
 /*-------------------------------------------------------------------------
  *
  * c.h--
@@ -9,7 +9,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.1 1998/10/31 04:10:53 scrappy Exp $
+ * $Id: c.h,v 1.2 1999/05/25 16:06:01 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,7 +65,8 @@
 #ifndef __cplusplus
 #ifndef bool
 typedef char bool;
-#endif   /* ndef bool */
+
+#endif  /* ndef bool */
 #endif  /* not C++ */
 typedef bool *BoolPtr;
 
index d09a59630ac4b1aae9e8563933211aa538b0e24c..872b34a65620bb9031a51b5763000c45f7c4fcb7 100644 (file)
@@ -1,17 +1,17 @@
 \r
 #ifndef TCPIPV4\r
-# define TCPIPV4\r
-#endif\r
+#define TCPIPV4\r
+#endif  /*\r */
 \r
 #ifndef MAXSOCKETS\r
 #define MAXSOCKETS 2048\r
-#endif\r
+#endif  /*\r */
 \r
-/*\r
- * DEF_PGPORT is the TCP port number on which the Postmaster listens by\r
- * default.  This can be overriden by command options, environment variables,\r
- * and the postconfig hook. (set by build script)\r
- */\r
+/*
+ * DEF_PGPORT is the TCP port number on which the Postmaster listens by
+ * default.  This can be overriden by command options, environment variables,
+ * and the postconfig hook. (set by build script)
 */\r
 \r
 #define DEF_PGPORT "5432"\r
 \r
index 42e4a3c47c67ff5cbd46e162fa22e426cca5d05e..1da61aae4933c963633ed23be11a663352cbbc9b 100644 (file)
@@ -206,28 +206,30 @@ on_error_continue()
 **     get_result
 **
 */
-PGresult   *get_result()
+PGresult   *
+get_result()
 {
-   char *cmdstatus = PQcmdStatus(res);
-   
+   char       *cmdstatus = PQcmdStatus(res);
+
    was_get_unset_result = TRUE;
 
    /* we have to store the fetch location somewhere */
    cmdstatus[0] = NUL;
-   memcpy(&cmdstatus[1],&tuple, sizeof(tuple));
+   memcpy(&cmdstatus[1], &tuple, sizeof(tuple));
 
    return res;
 }
-   
+
 /*
 **
 **     set_result
 **
 */
-void        set_result(PGresult *newres)
+void
+set_result(PGresult *newres)
 {
 
-   char *cmdstatus = PQcmdStatus(res);
+   char       *cmdstatus = PQcmdStatus(res);
 
    if (newres == NULL)
        halt("set_result called with null result pointer\n");
@@ -256,9 +258,10 @@ void        set_result(PGresult *newres)
 **     unset_result
 **
 */
-void       unset_result(PGresult *oldres)
+void
+unset_result(PGresult *oldres)
 {
-   char *cmdstatus = PQcmdStatus(oldres);
+   char       *cmdstatus = PQcmdStatus(oldres);
 
    if (oldres == NULL)
        halt("unset_result called with null result pointer\n");
@@ -277,8 +280,8 @@ void       unset_result(PGresult *oldres)
 **     reset_fetch
 **
 */
-void        reset_fetch()
+void
+reset_fetch()
 {
    tuple = 0;
 }
-
index 5f856ac016b62f5cf51aff4a3e6d3c778804a978..11253acebc68bcff93e7e72a6f3e7107d7a6543d 100644 (file)
@@ -11,8 +11,8 @@ int           fetchwithnulls(void *param,...);
 void       on_error_continue();
 void       on_error_stop();
 PGresult   *get_result();
-void        set_result(PGresult *newres);
-void        unset_result(PGresult *oldres);
-void        reset_fetch();
+void       set_result(PGresult *newres);
+void       unset_result(PGresult *oldres);
+void       reset_fetch();
 
 #define END_OF_TUPLES  (-1)
index a6ef3b27953bb70383c5d5edc4718d8bf8775657..39c3ddf0f2f9b684b003097b5bc16de947876b51 100644 (file)
@@ -7,7 +7,7 @@ a modification datetime stamp in a record when that record is UPDATEd.
 
 Credits
 This is 95%+ based on autoinc.c, which I used as a starting point as I do
-not really know what I am doing.  I also had help from 
+not really know what I am doing.  I also had help from
 Jan Wieck <[email protected]> who told me about the datetime_in("now") function.
 OH, me, I'm Terry Mackintosh <[email protected]>
 */
@@ -17,17 +17,18 @@ OH, me, I'm Terry Mackintosh <[email protected]>
 
 HeapTuple  moddatetime(void);
 
-HeapTuple moddatetime()
+HeapTuple
+moddatetime()
 {
-   Trigger     *trigger;       /* to get trigger name */
+   Trigger    *trigger;        /* to get trigger name */
    int         nargs;          /* # of arguments */
    int         attnum;         /* positional number of field to change */
-   Datum           newdt;          /* The current datetime. */
-   char            **args;         /* arguments */
-   char            *relname;       /* triggered relation name */
-   Relation        rel;                /* triggered relation */
+   Datum       newdt;          /* The current datetime. */
+   char      **args;           /* arguments */
+   char       *relname;        /* triggered relation name */
+   Relation    rel;            /* triggered relation */
    HeapTuple   rettuple = NULL;
-   TupleDesc   tupdesc;            /* tuple description */
+   TupleDesc   tupdesc;        /* tuple description */
 
    if (!CurrentTriggerData)
        elog(ERROR, "moddatetime: triggers are not initialized.");
@@ -65,28 +66,31 @@ HeapTuple moddatetime()
    /* Get the current datetime. */
    newdt = datetime_in("now");
 
-   /* This gets the position in the turple of the field we want.
-       args[0] being the name of the field to update, as passed in
-       from the trigger.
-   */
+   /*
+    * This gets the position in the turple of the field we want. args[0]
+    * being the name of the field to update, as passed in from the
+    * trigger.
+    */
    attnum = SPI_fnumber(tupdesc, args[0]);
 
-   /* This is were we check to see if the feild we are suppost to update even
-       exits.  The above function must return -1 if name not found?
-   */
+   /*
+    * This is were we check to see if the feild we are suppost to update
+    * even exits.  The above function must return -1 if name not found?
+    */
    if (attnum < 0)
        elog(ERROR, "moddatetime (%s): there is no attribute %s", relname,
-           args[0]);
-           
-   /* OK, this is where we make sure the datetime field that we are 
-       modifying is really a datetime field.
-       Hay, error checking, what a novel idea !-)
-   */
-   if (SPI_gettypeid(tupdesc, attnum) != DATETIMEOID )
+            args[0]);
+
+   /*
+    * OK, this is where we make sure the datetime field that we are
+    * modifying is really a datetime field. Hay, error checking, what a
+    * novel idea !-)
+    */
+   if (SPI_gettypeid(tupdesc, attnum) != DATETIMEOID)
        elog(ERROR, "moddatetime (%s): attribute %s must be of DATETIME type",
             relname, args[0]);
 
-/* 1 is the number of items in the arrays attnum and newdt. 
+/* 1 is the number of items in the arrays attnum and newdt.
    attnum is the positional number of the field to be updated.
    newdt is the new datetime stamp.
    NOTE that attnum and newdt are not arrays, but then a 1 ellement array
index 9d59c47edd883706e12fc851e1c39f8e44200d43..1f2c5380d514822ac7a743b609de0f9e05c33c82 100644 (file)
@@ -1,24 +1,27 @@
 #include <stdio.h>
 
-char *strtoupper(char *string)
+char *
+strtoupper(char *string)
 {
-   int i ;
-   for (i=0;i<strlen(string);i++)
-   {
-      string[i]=toupper(string[i]);
-   }
-   return string;
+   int         i;
+
+   for (i = 0; i < strlen(string); i++)
+       string[i] = toupper(string[i]);
+   return string;
 }
 
 
 
-void main ( char argc , char **argv )
+void
+main(char argc, char **argv)
 {
-   char str[250];
-   int sw = 0 ;
-   while ( fgets (str,240,stdin) )
-   {
-      if ( sw == 0 ) printf("%s",strtoupper(str));
-   }
+   char        str[250];
+   int         sw = 0;
+
+   while (fgets(str, 240, stdin))
+   {
+       if (sw == 0)
+           printf("%s", strtoupper(str));
+   }
 
 }
index a4b686fecb45a945a4f10cd5ca2634cac84fadae..1062592e6ff3a7f862b2cd036f481681788f9eb8 100644 (file)
@@ -60,8 +60,8 @@ check_primary_key()
    /*
     * Some checks first...
     */
-#ifdef  DEBUG_QUERY       
-        elog(NOTICE,"Check_primary_key Enter Function"); 
+#ifdef DEBUG_QUERY
+   elog(NOTICE, "Check_primary_key Enter Function");
 #endif
    /* Called by trigger manager ? */
    if (!CurrentTriggerData)
@@ -228,7 +228,7 @@ check_foreign_key()
    Trigger    *trigger;        /* to get trigger name */
    int         nargs;          /* # of args specified in CREATE TRIGGER */
    char      **args;           /* arguments: as described above */
-        char     **args_temp ;
+   char      **args_temp;
    int         nrefs;          /* number of references (== # of plans) */
    char        action;         /* 'R'estrict | 'S'etnull | 'C'ascade */
    int         nkeys;          /* # of key columns */
@@ -244,13 +244,15 @@ check_foreign_key()
    bool        isequal = true; /* are keys in both tuples equal (in
                                 * UPDATE) */
    char        ident[2 * NAMEDATALEN]; /* to identify myself */
-        int        is_update=0;
+   int         is_update = 0;
    int         ret;
    int         i,
                r;
-#ifdef DEBUG_QUERY                                
-       elog(NOTICE,"Check_foreign_key Enter Function"); 
+
+#ifdef DEBUG_QUERY
+   elog(NOTICE, "Check_foreign_key Enter Function");
 #endif
+
    /*
     * Some checks first...
     */
@@ -275,12 +277,12 @@ check_foreign_key()
     * key in tg_newtuple is the same as in tg_trigtuple then nothing to
     * do.
     */
-        is_update=0; 
+   is_update = 0;
    if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
-        {
+   {
        newtuple = CurrentTriggerData->tg_newtuple;
-                is_update=1;
-        }        
+       is_update = 1;
+   }
    trigger = CurrentTriggerData->tg_trigger;
    nargs = trigger->tgnargs;
    args = trigger->tgargs;
@@ -288,7 +290,7 @@ check_foreign_key()
    if (nargs < 5)              /* nrefs, action, key, Relation, key - at
                                 * least */
        elog(ERROR, "check_foreign_key: too short %d (< 5) list of arguments", nargs);
-                
+
    nrefs = pg_atoi(args[0], sizeof(int), 0);
    if (nrefs < 1)
        elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs);
@@ -386,7 +388,7 @@ check_foreign_key()
        if (plan->nplans <= 0)  /* Get typeId of column */
            argtypes[i] = SPI_gettypeid(tupdesc, fnumber);
    }
-        args_temp = args;
+   args_temp = args;
    nargs -= nkeys;
    args += nkeys;
 
@@ -397,13 +399,14 @@ check_foreign_key()
    {
        void       *pplan;
        char        sql[8192];
-                char   **args2 = args ;
+       char      **args2 = args;
 
        plan->splan = (void **) malloc(nrefs * sizeof(void *));
 
        for (r = 0; r < nrefs; r++)
        {
            relname = args2[0];
+
            /*
             * For 'R'estrict action we construct SELECT query - SELECT 1
             * FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 =
@@ -417,50 +420,59 @@ check_foreign_key()
             * For 'C'ascade action we construct DELETE query - DELETE
             * FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 =
             * $2 [...]] - to delete all referencing tuples.
-                        */
-                        /*Max : Cascade with UPDATE query i create update query that
-                           updates new key values in referenced tables
-                        */
-                         
-                         
-           else if (action == 'c'){
-                           if (is_update == 1)
-               {
-               int    fn;
-               char       *nv;
-               int        k ;
-               sprintf(sql, "update %s set ", relname);
-               for (k = 1; k <= nkeys; k++)
+            */
+
+           /*
+            * Max : Cascade with UPDATE query i create update query that
+            * updates new key values in referenced tables
+            */
+
+
+           else if (action == 'c')
+           {
+               if (is_update == 1)
                {
-                                    int is_char_type =0;
-                                    char *type;
-                                    
-                   fn = SPI_fnumber(tupdesc, args_temp[k-1]);
-                   nv = SPI_getvalue(newtuple, tupdesc, fn);
-                                    type=SPI_gettype(tupdesc,fn);
-                                
-                                    if ( (strcmp(type,"text") && strcmp (type,"varchar")  &&
-                                          strcmp(type,"char") && strcmp (type,"bpchar")   &&
-                                          strcmp(type,"date") && strcmp (type,"datetime")) == 0 )
-                                         is_char_type=1;
-#ifdef  DEBUG_QUERY                                    
-                                    elog(NOTICE,"Check_foreign_key Debug value %s type %s %d", 
-                                               nv,type,is_char_type);
+                   int         fn;
+                   char       *nv;
+                   int         k;
+
+                   sprintf(sql, "update %s set ", relname);
+                   for (k = 1; k <= nkeys; k++)
+                   {
+                       int         is_char_type = 0;
+                       char       *type;
+
+                       fn = SPI_fnumber(tupdesc, args_temp[k - 1]);
+                       nv = SPI_getvalue(newtuple, tupdesc, fn);
+                       type = SPI_gettype(tupdesc, fn);
+
+                       if ((strcmp(type, "text") && strcmp(type, "varchar") &&
+                       strcmp(type, "char") && strcmp(type, "bpchar") &&
+                            strcmp(type, "date") && strcmp(type, "datetime")) == 0)
+                           is_char_type = 1;
+#ifdef DEBUG_QUERY
+                       elog(NOTICE, "Check_foreign_key Debug value %s type %s %d",
+                            nv, type, is_char_type);
 #endif
-                                    /* is_char_type =1 i set ' ' for define a new value
-                                    */            
-                   sprintf(sql + strlen(sql), " %s = %s%s%s %s ",
-                   args2[k], (is_char_type>0) ? "'" :"" ,
-                                        nv, (is_char_type >0) ? "'" :"",(k < nkeys) ? ", " : "");
-                                    is_char_type=0;    
+
+                       /*
+                        * is_char_type =1 i set ' ' for define a new
+                        * value
+                        */
+                       sprintf(sql + strlen(sql), " %s = %s%s%s %s ",
+                               args2[k], (is_char_type > 0) ? "'" : "",
+                               nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : "");
+                       is_char_type = 0;
+                   }
+                   strcat(sql, " where ");
+
                }
-               strcat(sql, " where ");
-                                
-               }
-               else /* DELETE */
-               sprintf(sql, "delete from %s where ", relname);
-                            
-                        }           
+               else
+/* DELETE */
+                   sprintf(sql, "delete from %s where ", relname);
+
+           }
+
            /*
             * For 'S'etnull action we construct UPDATE query - UPDATE
             * _referencing_relation_ SET Fkey1 null [, Fkey2 null [...]]
@@ -500,15 +512,15 @@ check_foreign_key()
                elog(ERROR, "check_foreign_key: SPI_saveplan returned %d", SPI_result);
 
            plan->splan[r] = pplan;
-                        
+
            args2 += nkeys + 1; /* to the next relation */
        }
        plan->nplans = nrefs;
-#ifdef  DEBUG_QUERY                                    
-                elog(NOTICE,"Check_foreign_key Debug Query is :  %s ", sql);
+#ifdef DEBUG_QUERY
+       elog(NOTICE, "Check_foreign_key Debug Query is :  %s ", sql);
 #endif
    }
-        
+
    /*
     * If UPDATE and key is not changed ...
     */
index 03b7169a54a68bf5c0a056f6634b9094a7c6864a..a83203887c85145647513e6562c3967153678caa 100644 (file)
@@ -352,14 +352,15 @@ c_charin(char *str)
 {
    return (string_input(str, 1, 0, NULL));
 }
+
 #endif
 
 /* end of file */
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index 1ac0f2fb165c817efa0130390a0fa30652234389..b4a900bbb965cb761284dcc1228a3482a36a6d5d 100644 (file)
@@ -14,14 +14,15 @@ char       *c_varcharout(char *s);
 #if 0
 struct varlena *c_textin(char *str);
 char      *c_char16in(char *str);
+
 #endif
 
 #endif
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index 745f28d5bc966baa524a6f031882d042ef6f4675..c3a6e8676bba6098e03330d7b7f9468b49228c70 100644 (file)
@@ -29,7 +29,7 @@ user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
    LOCKTAG     tag;
 
    memset(&tag, 0, sizeof(LOCKTAG));
-   tag.dbId  = MyDatabaseId;
+   tag.dbId = MyDatabaseId;
    tag.relId = 0;
    tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
    tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
@@ -44,7 +44,7 @@ user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
    LOCKTAG     tag;
 
    memset(&tag, 0, sizeof(LOCKTAG));
-   tag.dbId  = MyDatabaseId;
+   tag.dbId = MyDatabaseId;
    tag.relId = 0;
    tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
    tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
@@ -99,8 +99,8 @@ user_unlock_all()
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index 0a8f55cbdd8001746a72df5d0c443b42eb42f686..ae77839f37d3082fab54bd71d112678767a3f407 100644 (file)
@@ -13,8 +13,8 @@ int           user_unlock_all(void);
 
 /*
  * Local variables:
- *  tab-width: 4
- *  c-indent-level: 4
- *  c-basic-offset: 4
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
  * End:
  */
index 8b893f26e2c3389797a36ee8fca1ec8978abca11..b954c4d9b575b05d28a46a73c3e46a11ef2de312 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.1 1999/04/10 16:48:05 peter Exp $
+ *   $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.2 1999/05/25 16:06:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #define BUFSIZE            1024
 
-int vacuumlo(char *,int);
+int            vacuumlo(char *, int);
 
 
 /*
  * This vacuums a database. It returns 1 on success, -1 on failure.
  */
-int vacuumlo(char *database,int verbose)
+int
+vacuumlo(char *database, int verbose)
 {
-    PGconn     *conn;
-    PGresult   *res, *res2;
-    char buf[BUFSIZE];
-    int matched=0; /* Number matched per scan */
-    int i;
-    
-    conn = PQsetdb(NULL, NULL, NULL, NULL, database);
-    
-    /* check to see that the backend connection was successfully made */
-    if (PQstatus(conn) == CONNECTION_BAD)
+   PGconn     *conn;
+   PGresult   *res,
+              *res2;
+   char        buf[BUFSIZE];
+   int         matched = 0;    /* Number matched per scan */
+   int         i;
+
+   conn = PQsetdb(NULL, NULL, NULL, NULL, database);
+
+   /* check to see that the backend connection was successfully made */
+   if (PQstatus(conn) == CONNECTION_BAD)
    {
-       fprintf(stderr, "Connection to database '%s' failed.\n", database);
-       fprintf(stderr, "%s", PQerrorMessage(conn));
-       return -1;
+       fprintf(stderr, "Connection to database '%s' failed.\n", database);
+       fprintf(stderr, "%s", PQerrorMessage(conn));
+       return -1;
    }
-    
-    if(verbose)
-   fprintf(stdout,"Connected to %s\n",database);
-    
-    /*
-     * First we create and populate the lo temp table
-     */
-    buf[0]='\0';
-    strcat(buf,"SELECT oid AS lo ");
-    strcat(buf,"INTO TEMP TABLE vacuum_l ");
-    strcat(buf,"FROM pg_class ");
-    strcat(buf,"WHERE relkind='l'");
-    if(!(res = PQexec(conn,buf))) {
-   fprintf(stderr,"Failed to create temp table.\n");
-   PQfinish(conn);
-   return -1;
-    }
-    PQclear(res);
-    
-    /*
-     * Now find any candidate tables who have columns of type oid (the column
-     * oid is ignored, as it has attnum < 1)
-     */
-    buf[0]='\0';
-    strcat(buf,"SELECT c.relname, a.attname ");
-    strcat(buf,"FROM pg_class c, pg_attribute a, pg_type t ");
-    strcat(buf,"WHERE a.attnum > 0 ");
-    strcat(buf,"      AND a.attrelid = c.oid ");
-    strcat(buf,"      AND a.atttypid = t.oid ");
-    strcat(buf,"      AND t.typname = 'oid' ");
-    strcat(buf,"      AND c.relname NOT LIKE 'pg_%'");
-    if(!(res = PQexec(conn,buf))) {
-   fprintf(stderr,"Failed to create temp table.\n");
-   PQfinish(conn);
-   return -1;
-    }
-    for(i=0;i<PQntuples(res);i++)
+
+   if (verbose)
+       fprintf(stdout, "Connected to %s\n", database);
+
+   /*
+    * First we create and populate the lo temp table
+    */
+   buf[0] = '\0';
+   strcat(buf, "SELECT oid AS lo ");
+   strcat(buf, "INTO TEMP TABLE vacuum_l ");
+   strcat(buf, "FROM pg_class ");
+   strcat(buf, "WHERE relkind='l'");
+   if (!(res = PQexec(conn, buf)))
    {
-       char *table,*field;
-       
-       table = PQgetvalue(res,i,0);
-       field = PQgetvalue(res,i,1);
-       
-       if(verbose) {
-       fprintf(stdout,"Checking %s in %s: ",field,table);
-       fflush(stdout);
-       }
-       
-       res2 = PQexec(conn, "begin");
-       PQclear(res2);
-       
-       buf[0] = '\0';
-       strcat(buf,"DELETE FROM vacuum_l ");
-       strcat(buf,"WHERE lo IN (");
-       strcat(buf,"SELECT ");
-       strcat(buf,field);
-       strcat(buf," FROM ");
-       strcat(buf,table);
-       strcat(buf,");");
-       if(!(res2 = PQexec(conn,buf))) {
-       fprintf(stderr,"Failed to check %s in table %s\n",field,table);
-       PQclear(res);
+       fprintf(stderr, "Failed to create temp table.\n");
        PQfinish(conn);
        return -1;
-       }
-       if(PQresultStatus(res2)!=PGRES_COMMAND_OK) {
-       fprintf(stderr,
-           "Failed to check %s in table %s\n%s\n",
-           field,table,
-           PQerrorMessage(conn)
-           );
-       PQclear(res2);
-       PQclear(res);
+   }
+   PQclear(res);
+
+   /*
+    * Now find any candidate tables who have columns of type oid (the
+    * column oid is ignored, as it has attnum < 1)
+    */
+   buf[0] = '\0';
+   strcat(buf, "SELECT c.relname, a.attname ");
+   strcat(buf, "FROM pg_class c, pg_attribute a, pg_type t ");
+   strcat(buf, "WHERE a.attnum > 0 ");
+   strcat(buf, "      AND a.attrelid = c.oid ");
+   strcat(buf, "      AND a.atttypid = t.oid ");
+   strcat(buf, "      AND t.typname = 'oid' ");
+   strcat(buf, "      AND c.relname NOT LIKE 'pg_%'");
+   if (!(res = PQexec(conn, buf)))
+   {
+       fprintf(stderr, "Failed to create temp table.\n");
        PQfinish(conn);
        return -1;
-       }
-       PQclear(res2);
+   }
+   for (i = 0; i < PQntuples(res); i++)
+   {
+       char       *table,
+                  *field;
+
+       table = PQgetvalue(res, i, 0);
+       field = PQgetvalue(res, i, 1);
+
+       if (verbose)
+       {
+           fprintf(stdout, "Checking %s in %s: ", field, table);
+           fflush(stdout);
+       }
+
+       res2 = PQexec(conn, "begin");
+       PQclear(res2);
+
+       buf[0] = '\0';
+       strcat(buf, "DELETE FROM vacuum_l ");
+       strcat(buf, "WHERE lo IN (");
+       strcat(buf, "SELECT ");
+       strcat(buf, field);
+       strcat(buf, " FROM ");
+       strcat(buf, table);
+       strcat(buf, ");");
+       if (!(res2 = PQexec(conn, buf)))
+       {
+           fprintf(stderr, "Failed to check %s in table %s\n", field, table);
+           PQclear(res);
+           PQfinish(conn);
+           return -1;
+       }
+       if (PQresultStatus(res2) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr,
+                   "Failed to check %s in table %s\n%s\n",
+                   field, table,
+                   PQerrorMessage(conn)
+               );
+           PQclear(res2);
+           PQclear(res);
+           PQfinish(conn);
+           return -1;
+       }
+       PQclear(res2);
+
+       res2 = PQexec(conn, "end");
+       PQclear(res2);
 
-       res2 = PQexec(conn, "end");
-       PQclear(res2);
-       
    }
-    PQclear(res);
-    
-    /* Start the transaction */
-    res = PQexec(conn, "begin");
-    PQclear(res);
-    
-    /*
-     * Finally, those entries remaining in vacuum_l are orphans.
-     */
-    buf[0]='\0';
-    strcat(buf,"SELECT lo ");
-    strcat(buf,"FROM vacuum_l");
-    if(!(res = PQexec(conn,buf))) {
-   fprintf(stderr,"Failed to read temp table.\n");
-   PQfinish(conn);
-   return -1;
-    }
-    matched=PQntuples(res);
-    for(i=0;i<matched;i++)
+   PQclear(res);
+
+   /* Start the transaction */
+   res = PQexec(conn, "begin");
+   PQclear(res);
+
+   /*
+    * Finally, those entries remaining in vacuum_l are orphans.
+    */
+   buf[0] = '\0';
+   strcat(buf, "SELECT lo ");
+   strcat(buf, "FROM vacuum_l");
+   if (!(res = PQexec(conn, buf)))
    {
-       Oid lo = (Oid) atoi(PQgetvalue(res,i,0));
-       
-       if(verbose) {
-       fprintf(stdout,"\rRemoving lo %6d \n",lo);
-       fflush(stdout);
-       }
-       
-       if(lo_unlink(conn,lo)<0) {
-       fprintf(stderr,"Failed to remove lo %d\n",lo);
-       }
+       fprintf(stderr, "Failed to read temp table.\n");
+       PQfinish(conn);
+       return -1;
+   }
+   matched = PQntuples(res);
+   for (i = 0; i < matched; i++)
+   {
+       Oid         lo = (Oid) atoi(PQgetvalue(res, i, 0));
+
+       if (verbose)
+       {
+           fprintf(stdout, "\rRemoving lo %6d \n", lo);
+           fflush(stdout);
+       }
+
+       if (lo_unlink(conn, lo) < 0)
+           fprintf(stderr, "Failed to remove lo %d\n", lo);
    }
-    PQclear(res);
-    
-    /*
-     * That's all folks!
-     */
-    res = PQexec(conn, "end");
-    PQclear(res);
-    PQfinish(conn);
-    
-    if(verbose)
-   fprintf(stdout,"\rRemoved %d large objects from %s.\n",matched,database);
-    
-    return 0;
+   PQclear(res);
+
+   /*
+    * That's all folks!
+    */
+   res = PQexec(conn, "end");
+   PQclear(res);
+   PQfinish(conn);
+
+   if (verbose)
+       fprintf(stdout, "\rRemoved %d large objects from %s.\n", matched, database);
+
+   return 0;
 }
 
 int
 main(int argc, char **argv)
 {
-    int verbose = 0;
-    int arg;
-    int rc=0;
-    
-    if (argc < 2)
+   int         verbose = 0;
+   int         arg;
+   int         rc = 0;
+
+   if (argc < 2)
    {
-       fprintf(stderr, "Usage: %s [-v] database_name [db2 ... dbn]\n",
-           argv[0]);
-       exit(1);
+       fprintf(stderr, "Usage: %s [-v] database_name [db2 ... dbn]\n",
+               argv[0]);
+       exit(1);
    }
-    
-    for(arg=1;arg<argc;arg++) {
-   if(strcmp("-v",argv[arg])==0)
-       verbose=!verbose;
-   else
-       rc += vacuumlo(argv[arg],verbose);
-    }
-    
-    return rc;
+
+   for (arg = 1; arg < argc; arg++)
+   {
+       if (strcmp("-v", argv[arg]) == 0)
+           verbose = !verbose;
+       else
+           rc += vacuumlo(argv[arg], verbose);
+   }
+
+   return rc;
 }
index be7254180217d0323863ee1d0596f6d960c9b1ef..2a07be49f8e3d8511f4c083a3aefe6cdaeda9a78 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.50 1999/03/14 20:17:20 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.51 1999/05/25 16:06:35 momjian Exp $
  *
  * NOTES
  *   The old interface functions have been converted to macros
@@ -124,7 +124,7 @@ DataFill(char *data,
            *bitP |= bitmask;
        }
 
-       data = (char *)att_align((long)data, att[i]->attlen, att[i]->attalign);
+       data = (char *) att_align((long) data, att[i]->attlen, att[i]->attalign);
        switch (att[i]->attlen)
        {
            case -1:
@@ -151,7 +151,7 @@ DataFill(char *data,
                        att[i]->attlen);
                break;
        }
-       data = (char *)att_addlength((long)data, att[i]->attlen, value[i]);
+       data = (char *) att_addlength((long) data, att[i]->attlen, value[i]);
    }
 }
 
@@ -210,7 +210,7 @@ heap_attisnull(HeapTuple tup, int attnum)
 int
 heap_sysattrlen(AttrNumber attno)
 {
-   HeapTupleHeader f = NULL;
+   HeapTupleHeader f = NULL;
 
    switch (attno)
    {
@@ -301,6 +301,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
    }
    return (Datum) NULL;
 }
+
 #endif
 
 /* ----------------
@@ -328,11 +329,11 @@ nocachegetattr(HeapTuple tuple,
               TupleDesc tupleDesc,
               bool *isnull)
 {
-   char               *tp;                     /* ptr to att in tuple */
-   HeapTupleHeader     tup = tuple->t_data;
-   bits8              *bp = tup->t_bits;       /* ptr to att in tuple */
-   Form_pg_attribute  *att = tupleDesc->attrs;
-   int                 slow = 0;               /* do we have to walk nulls? */
+   char       *tp;             /* ptr to att in tuple */
+   HeapTupleHeader tup = tuple->t_data;
+   bits8      *bp = tup->t_bits;       /* ptr to att in tuple */
+   Form_pg_attribute *att = tupleDesc->attrs;
+   int         slow = 0;       /* do we have to walk nulls? */
 
 
 #if IN_MACRO
@@ -376,6 +377,7 @@ nocachegetattr(HeapTuple tuple,
    }
    else
    {
+
        /*
         * there's a null somewhere in the tuple
         */
@@ -404,12 +406,13 @@ nocachegetattr(HeapTuple tuple,
            int         finalbit = attnum & 0x07;
 
            /* check for nulls "before" final bit of last byte */
-           if ((~ bp[byte]) & ((1 << finalbit) - 1))
+           if ((~bp[byte]) & ((1 << finalbit) - 1))
                slow = 1;
            else
            {
                /* check for nulls in any "earlier" bytes */
-               int     i;
+               int         i;
+
                for (i = 0; i < byte; i++)
                {
                    if (bp[i] != 0xFF)
@@ -439,6 +442,7 @@ nocachegetattr(HeapTuple tuple,
        else if (!HeapTupleAllFixed(tuple))
        {
            int         j;
+
            /*
             * In for(), we make this <= and not < because we want to test
             * if we can go past it in initializing offsets.
@@ -456,9 +460,9 @@ nocachegetattr(HeapTuple tuple,
 
    /*
     * If slow is zero, and we got here, we know that we have a tuple with
-    * no nulls or varlenas before the target attribute.
-    * If possible, we also want to initialize the remainder of the
-    * attribute cached offset values.
+    * no nulls or varlenas before the target attribute. If possible, we
+    * also want to initialize the remainder of the attribute cached
+    * offset values.
     */
    if (!slow)
    {
@@ -570,7 +574,7 @@ heap_copytuple(HeapTuple tuple)
    newTuple->t_len = tuple->t_len;
    newTuple->t_self = tuple->t_self;
    newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
-   memmove((char *) newTuple->t_data, 
+   memmove((char *) newTuple->t_data,
            (char *) tuple->t_data, (int) tuple->t_len);
    return newTuple;
 }
@@ -589,11 +593,11 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
        dest->t_data = NULL;
        return;
    }
-   
+
    dest->t_len = src->t_len;
    dest->t_self = src->t_self;
    dest->t_data = (HeapTupleHeader) palloc(src->t_len);
-   memmove((char *) dest->t_data, 
+   memmove((char *) dest->t_data,
            (char *) src->t_data, (int) src->t_len);
    return;
 }
@@ -657,14 +661,14 @@ heap_formtuple(TupleDesc tupleDescriptor,
               Datum *value,
               char *nulls)
 {
-   HeapTuple       tuple;          /* return tuple */
-   HeapTupleHeader td;             /* tuple data */
-   int             bitmaplen;
-   long            len;
-   int             hoff;
-   bool            hasnull = false;
-   int             i;
-   int             numberOfAttributes = tupleDescriptor->natts;
+   HeapTuple   tuple;          /* return tuple */
+   HeapTupleHeader td;         /* tuple data */
+   int         bitmaplen;
+   long        len;
+   int         hoff;
+   bool        hasnull = false;
+   int         i;
+   int         numberOfAttributes = tupleDescriptor->natts;
 
    len = offsetof(HeapTupleHeaderData, t_bits);
 
@@ -760,9 +764,9 @@ heap_modifytuple(HeapTuple tuple,
        if (repl[attoff] == ' ')
        {
            value[attoff] = heap_getattr(tuple,
-                            AttrOffsetGetAttrNumber(attoff),
-                            RelationGetDescr(relation),
-                            &isNull);
+                                        AttrOffsetGetAttrNumber(attoff),
+                                        RelationGetDescr(relation),
+                                        &isNull);
            nulls[attoff] = (isNull) ? 'n' : ' ';
 
        }
@@ -790,12 +794,12 @@ heap_modifytuple(HeapTuple tuple,
    infomask = newTuple->t_data->t_infomask;
    memmove((char *) &newTuple->t_data->t_oid,  /* XXX */
            (char *) &tuple->t_data->t_oid,
-           ((char *) &tuple->t_data->t_hoff - 
-               (char *) &tuple->t_data->t_oid));       /* XXX */
+           ((char *) &tuple->t_data->t_hoff -
+            (char *) &tuple->t_data->t_oid));  /* XXX */
    newTuple->t_data->t_infomask = infomask;
    newTuple->t_data->t_natts = numberOfAttributes;
    newTuple->t_self = tuple->t_self;
-   
+
    return newTuple;
 }
 
@@ -809,10 +813,10 @@ heap_addheader(uint32 natts,  /* max domain index */
               int structlen,   /* its length */
               char *structure) /* pointer to the struct */
 {
-   HeapTuple       tuple;
-   HeapTupleHeader td;             /* tuple data */
-   long            len;
-   int             hoff;
+   HeapTuple   tuple;
+   HeapTupleHeader td;         /* tuple data */
+   long        len;
+   int         hoff;
 
    AssertArg(natts > 0);
 
index 7615c79a748d6df2b1f734b4bb05da313011be36..0a2eee932f58bd30f63c1e0f024fbf35cb12a8bf 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.45 1999/05/10 00:44:50 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.46 1999/05/25 16:06:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -25,9 +25,9 @@
 #include "libpq/pqformat.h"
 #include "utils/syscache.h"
 
-static void printtup_setup(DestReceiver* self, TupleDesc typeinfo);
-static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self);
-static void printtup_cleanup(DestReceiver* self);
+static void printtup_setup(DestReceiver * self, TupleDesc typeinfo);
+static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self);
+static void printtup_cleanup(DestReceiver * self);
 
 /* ----------------------------------------------------------------
  *     printtup / debugtup support
@@ -43,7 +43,7 @@ static void printtup_cleanup(DestReceiver* self);
  * ----------------
  */
 int
-getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
+getTypeOutAndElem(Oid type, Oid *typOutput, Oid *typElem)
 {
    HeapTuple   typeTuple;
 
@@ -54,6 +54,7 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
    if (HeapTupleIsValid(typeTuple))
    {
        Form_pg_type pt = (Form_pg_type) GETSTRUCT(typeTuple);
+
        *typOutput = (Oid) pt->typoutput;
        *typElem = (Oid) pt->typelem;
        return OidIsValid(*typOutput);
@@ -70,27 +71,29 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
  *     Private state for a printtup destination object
  * ----------------
  */
-typedef struct {               /* Per-attribute information */
+typedef struct
+{                              /* Per-attribute information */
    Oid         typoutput;      /* Oid for the attribute's type output fn */
    Oid         typelem;        /* typelem value to pass to the output fn */
    FmgrInfo    finfo;          /* Precomputed call info for typoutput */
-} PrinttupAttrInfo;
+}          PrinttupAttrInfo;
 
-typedef struct {
-   DestReceiver        pub;        /* publicly-known function pointers */
-   TupleDesc           attrinfo;   /* The attr info we are set up for */
-   int                 nattrs;
-   PrinttupAttrInfo   *myinfo;     /* Cached info about each attr */
-} DR_printtup;
+typedef struct
+{
+   DestReceiver pub;           /* publicly-known function pointers */
+   TupleDesc   attrinfo;       /* The attr info we are set up for */
+   int         nattrs;
+   PrinttupAttrInfo *myinfo;   /* Cached info about each attr */
+}          DR_printtup;
 
 /* ----------------
  *     Initialize: create a DestReceiver for printtup
  * ----------------
  */
-DestReceiver*
+DestReceiver *
 printtup_create_DR()
 {
-   DR_printtup* self = (DR_printtup*) palloc(sizeof(DR_printtup));
+   DR_printtup *self = (DR_printtup *) palloc(sizeof(DR_printtup));
 
    self->pub.receiveTuple = printtup;
    self->pub.setup = printtup_setup;
@@ -100,42 +103,43 @@ printtup_create_DR()
    self->nattrs = 0;
    self->myinfo = NULL;
 
-   return (DestReceiver*) self;
+   return (DestReceiver *) self;
 }
 
 static void
-printtup_setup(DestReceiver* self, TupleDesc typeinfo)
+printtup_setup(DestReceiver * self, TupleDesc typeinfo)
 {
    /* ----------------
     * We could set up the derived attr info at this time, but we postpone it
     * until the first call of printtup, for 3 reasons:
     * 1. We don't waste time (compared to the old way) if there are no
-    *    tuples at all to output.
+    *    tuples at all to output.
     * 2. Checking in printtup allows us to handle the case that the tuples
-    *    change type midway through (although this probably can't happen in
-    *    the current executor).
+    *    change type midway through (although this probably can't happen in
+    *    the current executor).
     * 3. Right now, ExecutorRun passes a NULL for typeinfo anyway :-(
     * ----------------
     */
 }
 
 static void
-printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs)
+printtup_prepare_info(DR_printtup * myState, TupleDesc typeinfo, int numAttrs)
 {
-   int i;
+   int         i;
 
    if (myState->myinfo)
-       pfree(myState->myinfo); /* get rid of any old data */
+       pfree(myState->myinfo); /* get rid of any old data */
    myState->myinfo = NULL;
    myState->attrinfo = typeinfo;
    myState->nattrs = numAttrs;
    if (numAttrs <= 0)
        return;
-   myState->myinfo = (PrinttupAttrInfo*)
+   myState->myinfo = (PrinttupAttrInfo *)
        palloc(numAttrs * sizeof(PrinttupAttrInfo));
    for (i = 0; i < numAttrs; i++)
    {
-       PrinttupAttrInfo* thisState = myState->myinfo + i;
+       PrinttupAttrInfo *thisState = myState->myinfo + i;
+
        if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
                              &thisState->typoutput, &thisState->typelem))
            fmgr_info(thisState->typoutput, &thisState->finfo);
@@ -147,9 +151,9 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs)
  * ----------------
  */
 static void
-printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
+printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self)
 {
-   DR_printtup *myState = (DR_printtup*) self;
+   DR_printtup *myState = (DR_printtup *) self;
    StringInfoData buf;
    int         i,
                j,
@@ -178,7 +182,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
    k = 1 << 7;
    for (i = 0; i < tuple->t_data->t_natts; ++i)
    {
-       if (! heap_attisnull(tuple, i + 1))
+       if (!heap_attisnull(tuple, i + 1))
            j |= k;             /* set bit if not null */
        k >>= 1;
        if (k == 0)             /* end of byte? */
@@ -197,7 +201,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
     */
    for (i = 0; i < tuple->t_data->t_natts; ++i)
    {
-       PrinttupAttrInfo* thisState = myState->myinfo + i;
+       PrinttupAttrInfo *thisState = myState->myinfo + i;
+
        attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
        if (isnull)
            continue;
@@ -223,9 +228,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
  * ----------------
  */
 static void
-printtup_cleanup(DestReceiver* self)
+printtup_cleanup(DestReceiver * self)
 {
-   DR_printtup* myState = (DR_printtup*) self;
+   DR_printtup *myState = (DR_printtup *) self;
+
    if (myState->myinfo)
        pfree(myState->myinfo);
    pfree(myState);
@@ -274,7 +280,7 @@ showatts(char *name, TupleDesc tupleDesc)
  * ----------------
  */
 void
-debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
+debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self)
 {
    int         i;
    Datum       attr;
@@ -310,7 +316,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
  * ----------------
  */
 void
-printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
+printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self)
 {
    StringInfoData buf;
    int         i,
@@ -334,7 +340,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
    k = 1 << 7;
    for (i = 0; i < tuple->t_data->t_natts; ++i)
    {
-       if (! heap_attisnull(tuple, i + 1))
+       if (!heap_attisnull(tuple, i + 1))
            j |= k;             /* set bit if not null */
        k >>= 1;
        if (k == 0)             /* end of byte? */
index bd3e047e6a719a5bb0a91c7fac9d7487c3af2d82..7dd9b6a9206c658ad647375e83e8128ae10cde42 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.13 1999/02/13 23:14:13 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.14 1999/05/25 16:06:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 #include <access/skey.h>
 
 /*
- * ScanKeyEntryIsLegal 
+ * ScanKeyEntryIsLegal
  *     True iff the scan key entry is legal.
  */
 #define ScanKeyEntryIsLegal(entry) \
@@ -28,7 +28,7 @@
 )
 
 /*
- * ScanKeyEntrySetIllegal 
+ * ScanKeyEntrySetIllegal
  *     Marks a scan key entry as illegal.
  */
 void
@@ -43,7 +43,7 @@ ScanKeyEntrySetIllegal(ScanKey entry)
 }
 
 /*
- * ScanKeyEntryInitialize 
+ * ScanKeyEntryInitialize
  *     Initializes an scan key entry.
  *
  * Note:
index 656b997404d843789384dbbd241041ebde8beadd..71e8db45a43dbcdf4957b6db42cbfe9ab6c4c096 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.48 1999/02/13 23:14:14 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.49 1999/05/25 16:06:42 momjian Exp $
  *
  * NOTES
  *   some of the executor utility code such as "ExecTypeFromTL" should be
@@ -487,7 +487,7 @@ BuildDescForRelation(List *schema, char *relname)
        {
            /* array of XXX is _XXX */
            snprintf(typename, NAMEDATALEN,
-                            "_%.*s", NAMEDATALEN - 2, entry->typename->name);
+                    "_%.*s", NAMEDATALEN - 2, entry->typename->name);
            attdim = length(arry);
        }
        else
index 1342bc6aec8d301a4627a525139502c90ae4afc4..06321990a8da7d48b81e36c9ba387f50c9421e9f 100644 (file)
@@ -344,7 +344,7 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
    /*
     * Notes in ExecUtils:ExecOpenIndices()
     *
-   RelationSetLockForWrite(r);
+    * RelationSetLockForWrite(r);
     */
 
    res = gistdoinsert(r, itup, &giststate);
@@ -1106,10 +1106,10 @@ gistdelete(Relation r, ItemPointer tid)
    Page        page;
 
    /*
-    * Notes in ExecUtils:ExecOpenIndices()
-    * Also note that only vacuum deletes index tuples now...
+    * Notes in ExecUtils:ExecOpenIndices() Also note that only vacuum
+    * deletes index tuples now...
     *
-   RelationSetLockForWrite(r);
+    * RelationSetLockForWrite(r);
     */
 
    blkno = ItemPointerGetBlockNumber(tid);
index 92353d71b2bf5a08dfa27c4e98008b86796057c0..d26387d8280c944c1a80ce9ec2c3475a97b4ecd6 100644 (file)
@@ -68,7 +68,7 @@ gistbeginscan(Relation r,
    /*
     * Let index_beginscan does its work...
     *
-   RelationSetLockForRead(r);
+    * RelationSetLockForRead(r);
     */
 
    s = RelationGetIndexScan(r, fromEnd, nkeys, key);
index 122c9ad3797d58024c6ba7b91e8c5788a217caa0..65d04658c50435e62502f0d453c1add20ea78941 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.25 1999/02/13 23:14:17 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.26 1999/05/25 16:06:54 momjian Exp $
  *
  * NOTES
  *   This file contains only the public interface routines.
@@ -485,9 +485,9 @@ hashrestrpos(IndexScanDesc scan)
    /* bump lock on currentMarkData and copy to currentItemData */
    if (ItemPointerIsValid(&(scan->currentMarkData)))
    {
-       so->hashso_curbuf =_hash_getbuf(scan->relation,
-                        BufferGetBlockNumber(so->hashso_mrkbuf),
-                        HASH_READ);
+       so->hashso_curbuf = _hash_getbuf(scan->relation,
+                                BufferGetBlockNumber(so->hashso_mrkbuf),
+                                        HASH_READ);
 
        scan->currentItemData = scan->currentMarkData;
    }
index c8be6dc60eda95f1cc40b1cb60ebce8ce391ed3a..f5605a3f1097045cdba2776af3d654476a523d9a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.16 1999/03/14 16:27:59 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.17 1999/05/25 16:06:56 momjian Exp $
  *
  * NOTES
  *   These functions are stored in pg_amproc.  For each operator class
@@ -34,9 +34,9 @@ hashint4(uint32 key)
 }
 
 uint32
-hashint8(int64 *key)
+hashint8(int64 * key)
 {
-   return ~((uint32)*key);
+   return ~((uint32) *key);
 }
 
 /* Hash function from Chris Torek. */
index 7c81e7ab5c18e834259eb08fb6ed33955597974f..bcda5f85e735ab3a6009c304fa0e17587679a3fa 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.19 1999/02/13 23:14:20 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.20 1999/05/25 16:06:58 momjian Exp $
  *
  * NOTES
  *   Postgres hash pages look like ordinary relation pages.  The opaque
@@ -321,7 +321,7 @@ _hash_setpagelock(Relation rel,
    {
        switch (access)
        {
-           case HASH_WRITE:
+               case HASH_WRITE:
                LockPage(rel, blkno, ExclusiveLock);
                break;
            case HASH_READ:
@@ -345,7 +345,7 @@ _hash_unsetpagelock(Relation rel,
    {
        switch (access)
        {
-           case HASH_WRITE:
+               case HASH_WRITE:
                UnlockPage(rel, blkno, ExclusiveLock);
                break;
            case HASH_READ:
index 63fd52d124f7b16851caf068a1fc39a9419be391..1ea78ec86333c7fa347b7656e9fb6911f0e62d7b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.42 1999/03/28 20:31:56 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.43 1999/05/25 16:07:04 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -117,7 +117,7 @@ initscan(HeapScanDesc scan,
         *  relation is empty
         * ----------------
         */
-       scan->rs_ntup.t_data = scan->rs_ctup.t_data = 
+       scan->rs_ntup.t_data = scan->rs_ctup.t_data =
        scan->rs_ptup.t_data = NULL;
        scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
    }
@@ -216,15 +216,15 @@ heapgettup(Relation relation,
           int nkeys,
           ScanKey key)
 {
-   ItemId          lpp;
-   Page            dp;
-   int             page;
-   int             pages;
-   int             lines;
-   OffsetNumber    lineoff;
-   int             linesleft;
-   ItemPointer     tid = (tuple->t_data == NULL) ? 
-                           (ItemPointer) NULL : &(tuple->t_self);
+   ItemId      lpp;
+   Page        dp;
+   int         page;
+   int         pages;
+   int         lines;
+   OffsetNumber lineoff;
+   int         linesleft;
+   ItemPointer tid = (tuple->t_data == NULL) ?
+   (ItemPointer) NULL : &(tuple->t_self);
 
    /* ----------------
     *  increment access statistics
@@ -290,8 +290,8 @@ heapgettup(Relation relation,
            return;
        }
        *buffer = RelationGetBufferWithBuffer(relation,
-                                          ItemPointerGetBlockNumber(tid),
-                                          *buffer);
+                                         ItemPointerGetBlockNumber(tid),
+                                             *buffer);
 
        if (!BufferIsValid(*buffer))
            elog(ERROR, "heapgettup: failed ReadBuffer");
@@ -439,7 +439,8 @@ heapgettup(Relation relation,
            }
            else
            {
-               ++lpp;          /* move forward in this page's ItemId array */
+               ++lpp;          /* move forward in this page's ItemId
+                                * array */
                ++lineoff;
            }
        }
@@ -816,6 +817,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
        }
        else
        {                       /* NONTUP */
+
            /*
             * Don't release scan->rs_cbuf at this point, because
             * heapgettup doesn't increase PrivateRefCount if it is
@@ -897,6 +899,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
        }
        else
        {                       /* NONTUP */
+
            /*
             * Don't release scan->rs_cbuf at this point, because
             * heapgettup doesn't increase PrivateRefCount if it is
@@ -966,11 +969,11 @@ heap_fetch(Relation relation,
           HeapTuple tuple,
           Buffer *userbuf)
 {
-   ItemId          lp;
-   Buffer          buffer;
-   PageHeader      dp;
-   ItemPointer     tid = &(tuple->t_self);
-   OffsetNumber    offnum;
+   ItemId      lp;
+   Buffer      buffer;
+   PageHeader  dp;
+   ItemPointer tid = &(tuple->t_self);
+   OffsetNumber offnum;
 
    AssertMacro(PointerIsValid(userbuf));       /* see comments above */
 
@@ -1093,9 +1096,7 @@ heap_insert(Relation relation, HeapTuple tup)
    RelationPutHeapTupleAtEnd(relation, tup);
 
    if (IsSystemRelationName(RelationGetRelationName(relation)->data))
-   {
        RelationInvalidateHeapTuple(relation, tup);
-   }
 
    return tup->t_data->t_oid;
 }
@@ -1106,11 +1107,11 @@ heap_insert(Relation relation, HeapTuple tup)
 int
 heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
 {
-   ItemId          lp;
-   HeapTupleData   tp;
-   PageHeader      dp;
-   Buffer          buffer;
-   int             result;
+   ItemId      lp;
+   HeapTupleData tp;
+   PageHeader  dp;
+   Buffer      buffer;
+   int         result;
 
    /* increment access statistics */
    IncrHeapAccessStat(local_delete);
@@ -1130,10 +1131,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
    tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
    tp.t_len = ItemIdGetLength(lp);
    tp.t_self = *tid;
-   
+
 l1:
    result = HeapTupleSatisfiesUpdate(&tp);
-   
+
    if (result == HeapTupleInvisible)
    {
        LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
@@ -1142,7 +1143,7 @@ l1:
    }
    else if (result == HeapTupleBeingUpdated)
    {
-       TransactionId   xwait = tp.t_data->t_xmax;
+       TransactionId xwait = tp.t_data->t_xmax;
 
        /* sleep untill concurrent transaction ends */
        LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
@@ -1177,8 +1178,8 @@ l1:
    /* store transaction information of xact deleting the tuple */
    TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax));
    tp.t_data->t_cmax = GetCurrentCommandId();
-   tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | 
-                              HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
+   tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
+                            HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
 
    LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
 
@@ -1194,14 +1195,14 @@ l1:
  * heap_replace    - replace a tuple
  */
 int
-heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup, 
-               ItemPointer ctid)
+heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup,
+            ItemPointer ctid)
 {
-   ItemId          lp;
-   HeapTupleData   oldtup;
-   PageHeader      dp;
-   Buffer          buffer;
-   int             result;
+   ItemId      lp;
+   HeapTupleData oldtup;
+   PageHeader  dp;
+   Buffer      buffer;
+   int         result;
 
    /* increment access statistics */
    IncrHeapAccessStat(local_replace);
@@ -1223,7 +1224,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup,
 
 l2:
    result = HeapTupleSatisfiesUpdate(&oldtup);
-   
+
    if (result == HeapTupleInvisible)
    {
        LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
@@ -1232,7 +1233,7 @@ l2:
    }
    else if (result == HeapTupleBeingUpdated)
    {
-       TransactionId   xwait = oldtup.t_data->t_xmax;
+       TransactionId xwait = oldtup.t_data->t_xmax;
 
        /* sleep untill concurrent transaction ends */
        LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
@@ -1275,19 +1276,20 @@ l2:
    /* logically delete old item */
    TransactionIdStore(GetCurrentTransactionId(), &(oldtup.t_data->t_xmax));
    oldtup.t_data->t_cmax = GetCurrentCommandId();
-   oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | 
-                                  HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
+   oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
+                            HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
 
    /* insert new item */
    if ((unsigned) DOUBLEALIGN(newtup->t_len) <= PageGetFreeSpace((Page) dp))
        RelationPutHeapTuple(relation, buffer, newtup);
    else
    {
+
        /*
-        * New item won't fit on same page as old item, have to look
-        * for a new place to put it. Note that we have to unlock
-        * current buffer context - not good but RelationPutHeapTupleAtEnd
-        * uses extend lock.
+        * New item won't fit on same page as old item, have to look for a
+        * new place to put it. Note that we have to unlock current buffer
+        * context - not good but RelationPutHeapTupleAtEnd uses extend
+        * lock.
         */
        LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
        RelationPutHeapTupleAtEnd(relation, newtup);
@@ -1295,8 +1297,8 @@ l2:
    }
 
    /*
-    * New item in place, now record address of new tuple in
-    * t_ctid of old one.
+    * New item in place, now record address of new tuple in t_ctid of old
+    * one.
     */
    oldtup.t_data->t_ctid = newtup->t_self;
 
@@ -1316,10 +1318,10 @@ l2:
 int
 heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
 {
-   ItemPointer     tid = &(tuple->t_self);
-   ItemId          lp;
-   PageHeader      dp;
-   int             result;
+   ItemPointer tid = &(tuple->t_self);
+   ItemId      lp;
+   PageHeader  dp;
+   int         result;
 
    /* increment access statistics */
    IncrHeapAccessStat(local_mark4update);
@@ -1336,10 +1338,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
    lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
    tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
    tuple->t_len = ItemIdGetLength(lp);
-   
+
 l3:
    result = HeapTupleSatisfiesUpdate(tuple);
-   
+
    if (result == HeapTupleInvisible)
    {
        LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
@@ -1348,7 +1350,7 @@ l3:
    }
    else if (result == HeapTupleBeingUpdated)
    {
-       TransactionId   xwait = tuple->t_data->t_xmax;
+       TransactionId xwait = tuple->t_data->t_xmax;
 
        /* sleep untill concurrent transaction ends */
        LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
index f991b206d4426f147e4bac3242c6f0aa61dfa2b9..682c072c19920b6844dde8cad3d07bcb871fbb29 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Id: hio.c,v 1.19 1999/05/07 01:22:53 vadim Exp $
+ *   $Id: hio.c,v 1.20 1999/05/25 16:07:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,11 +39,11 @@ RelationPutHeapTuple(Relation relation,
                     Buffer buffer,
                     HeapTuple tuple)
 {
-   Page            pageHeader;
-   OffsetNumber    offnum;
-   unsigned int    len;
-   ItemId          itemId;
-   Item            item;
+   Page        pageHeader;
+   OffsetNumber offnum;
+   unsigned int len;
+   ItemId      itemId;
+   Item        item;
 
    /* ----------------
     *  increment access statistics
@@ -62,13 +62,13 @@ RelationPutHeapTuple(Relation relation,
    itemId = PageGetItemId((Page) pageHeader, offnum);
    item = PageGetItem((Page) pageHeader, itemId);
 
-   ItemPointerSet(&((HeapTupleHeader) item)->t_ctid, 
-                   BufferGetBlockNumber(buffer), offnum);
+   ItemPointerSet(&((HeapTupleHeader) item)->t_ctid,
+                  BufferGetBlockNumber(buffer), offnum);
 
    /*
     * Let the caller do this!
     *
-   WriteBuffer(buffer);
+    * WriteBuffer(buffer);
     */
 
    /* return an accurate tuple */
@@ -111,8 +111,8 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
    Item        item;
 
    /*
-    * Lock relation for extention. We can use LockPage here as long as 
-    * in all other places we use page-level locking for indices only.
+    * Lock relation for extention. We can use LockPage here as long as in
+    * all other places we use page-level locking for indices only.
     * Alternatevely, we could define pseudo-table as we do for
     * transactions with XactLockTable.
     */
@@ -132,6 +132,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
    {
        buffer = ReadBuffer(relation, lastblock);
        pageHeader = (Page) BufferGetPage(buffer);
+
        /*
         * There was IF instead of ASSERT here ?!
         */
index 5752f2cf4431efdaa7ffccc3ef82179c03ff4ab4..70b9ae2a4b04b2533677beacb2ad27ef8cf1feec 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.16 1999/02/13 23:14:29 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.17 1999/05/25 16:07:12 momjian Exp $
  *
  * NOTES
  *   many of the old access method routines have been turned into
@@ -270,5 +270,5 @@ IndexScanRestorePosition(IndexScanDesc scan)
 
    scan->flags = 0x0;          /* XXX should have a symbolic name */
 }
-#endif
 
+#endif
index e0b4e61a15b033b7f874746e94373ed9fda08335..61cbe560656c36c54d593fd4944e3badae4c5424 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.31 1999/02/13 23:14:30 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.32 1999/05/25 16:07:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -57,7 +57,7 @@ static bool StrategyTermIsValid(StrategyTerm term,
  */
 
 /*
- * StrategyMapGetScanKeyEntry 
+ * StrategyMapGetScanKeyEntry
  *     Returns a scan key entry of a index strategy mapping member.
  *
  * Note:
@@ -75,7 +75,7 @@ StrategyMapGetScanKeyEntry(StrategyMap map,
 }
 
 /*
- * IndexStrategyGetStrategyMap 
+ * IndexStrategyGetStrategyMap
  *     Returns an index strategy mapping of an index strategy.
  *
  * Note:
@@ -97,7 +97,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy,
 }
 
 /*
- * AttributeNumberGetIndexStrategySize 
+ * AttributeNumberGetIndexStrategySize
  *     Computes the size of an index strategy.
  */
 Size
@@ -294,8 +294,8 @@ RelationGetStrategy(Relation relation,
    Assert(RegProcedureIsValid(procedure));
 
    strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(relation),
-                                   evaluation->maxStrategy,
-                                   attributeNumber);
+                                             evaluation->maxStrategy,
+                                             attributeNumber);
 
    /* get a strategy number for the procedure ignoring flags for now */
    for (index = 0; index < evaluation->maxStrategy; index += 1)
@@ -526,7 +526,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
 
 
 /*
- * IndexSupportInitialize 
+ * IndexSupportInitialize
  *     Initializes an index strategy and associated support procedures.
  */
 void
index 127f2b035760b96fddf774cde0097da4d6e8b2e5..796087f812f10016fb311680defcda1844ef1486 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.22 1999/03/14 05:08:56 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.23 1999/05/25 16:07:21 momjian Exp $
  *
  * NOTES
  *     These functions are stored in pg_amproc.  For each operator class
@@ -40,7 +40,7 @@ btint4cmp(int32 a, int32 b)
 }
 
 int32
-btint8cmp(int64 *a, int64 *b)
+btint8cmp(int64 * a, int64 * b)
 {
    if (*a > *b)
        return 1;
index 265a658363ae456fd0f17b08aa49d9fe0d651ada..3cc67661cd264c95e198b87e375084dda63facb4 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.39 1999/05/01 16:09:45 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.40 1999/05/25 16:07:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -99,13 +99,13 @@ l1:
        /* key on the page before trying to compare it */
        if (!PageIsEmpty(page) && offset <= maxoff)
        {
-           TupleDesc       itupdesc;
-           BTItem          cbti;
-           HeapTupleData   htup;
-           BTPageOpaque    opaque;
-           Buffer          nbuf;
-           BlockNumber     blkno;
-           bool            chtup = true;
+           TupleDesc   itupdesc;
+           BTItem      cbti;
+           HeapTupleData htup;
+           BTPageOpaque opaque;
+           Buffer      nbuf;
+           BlockNumber blkno;
+           bool        chtup = true;
 
            itupdesc = RelationGetDescr(rel);
            nbuf = InvalidBuffer;
@@ -122,15 +122,16 @@ l1:
             */
            while (_bt_isequal(itupdesc, page, offset, natts, itup_scankey))
            {                   /* they're equal */
+
                /*
-                * Have to check is inserted heap tuple deleted one
-                * (i.e. just moved to another place by vacuum)!
+                * Have to check is inserted heap tuple deleted one (i.e.
+                * just moved to another place by vacuum)!
                 */
                if (chtup)
                {
                    htup.t_self = btitem->bti_itup.t_tid;
                    heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
-                   if (htup.t_data == NULL)    /* YES! */
+                   if (htup.t_data == NULL)    /* YES! */
                        break;
                    /* Live tuple was inserted */
                    ReleaseBuffer(buffer);
@@ -139,11 +140,11 @@ l1:
                cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
                htup.t_self = cbti->bti_itup.t_tid;
                heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
-               if (htup.t_data != NULL)    /* it is a duplicate */
+               if (htup.t_data != NULL)        /* it is a duplicate */
                {
-                   TransactionId xwait = 
-                       (TransactionIdIsValid(SnapshotDirty->xmin)) ? 
-                       SnapshotDirty->xmin : SnapshotDirty->xmax;
+                   TransactionId xwait =
+                   (TransactionIdIsValid(SnapshotDirty->xmin)) ?
+                   SnapshotDirty->xmin : SnapshotDirty->xmax;
 
                    /*
                     * If this tuple is being updated by other transaction
@@ -156,7 +157,7 @@ l1:
                            _bt_relbuf(rel, nbuf, BT_READ);
                        _bt_relbuf(rel, buf, BT_WRITE);
                        XactLockTableWait(xwait);
-                       goto l1;    /* continue from the begin */
+                       goto l1;/* continue from the begin */
                    }
                    elog(ERROR, "Cannot insert a duplicate key into a unique index");
                }
@@ -571,10 +572,10 @@ _bt_insertonpg(Relation rel,
         * reasoning).
         */
 
-l_spl:;
+l_spl: ;
        if (stack == (BTStack) NULL)
        {
-           if (!is_root)   /* if this page was not root page */
+           if (!is_root)       /* if this page was not root page */
            {
                elog(DEBUG, "btree: concurrent ROOT page split");
                stack = (BTStack) palloc(sizeof(BTStackData));
@@ -1144,8 +1145,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
    lpage = BufferGetPage(lbuf);
    rpage = BufferGetPage(rbuf);
 
-   ((BTPageOpaque) PageGetSpecialPointer(lpage))->btpo_parent = 
-   ((BTPageOpaque) PageGetSpecialPointer(rpage))->btpo_parent = 
+   ((BTPageOpaque) PageGetSpecialPointer(lpage))->btpo_parent =
+       ((BTPageOpaque) PageGetSpecialPointer(rpage))->btpo_parent =
        rootbknum;
 
    /*
index daff4e6bdd4f3f347da17d1f137059646014f2da..5a93616054980a136369c140097e77b74868c927 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.20 1999/04/22 08:19:59 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.21 1999/05/25 16:07:26 momjian Exp $
  *
  * NOTES
  *    Postgres btree pages look like ordinary relation pages.  The opaque
@@ -421,7 +421,7 @@ _bt_pageinit(Page page, Size size)
    MemSet(page, 0, size);
 
    PageInit(page, size, sizeof(BTPageOpaqueData));
-   ((BTPageOpaque) PageGetSpecialPointer(page))->btpo_parent = 
+   ((BTPageOpaque) PageGetSpecialPointer(page))->btpo_parent =
        InvalidBlockNumber;
 }
 
@@ -494,17 +494,16 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
    opaque = (BTPageOpaque) PageGetSpecialPointer(page);
    maxoff = PageGetMaxOffsetNumber(page);
 
-   if (stack->bts_offset == InvalidOffsetNumber || 
+   if (stack->bts_offset == InvalidOffsetNumber ||
        maxoff >= stack->bts_offset)
    {
+
        /*
-        * _bt_insertonpg set bts_offset to InvalidOffsetNumber
-        * in the case of concurrent ROOT page split
+        * _bt_insertonpg set bts_offset to InvalidOffsetNumber in the
+        * case of concurrent ROOT page split
         */
        if (stack->bts_offset == InvalidOffsetNumber)
-       {
            i = P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY;
-       }
        else
        {
            itemid = PageGetItemId(page, stack->bts_offset);
@@ -524,7 +523,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
        }
 
        /* if the item has just moved right on this page, we're done */
-       for ( ;
+       for (;
             i <= maxoff;
             i = OffsetNumberNext(i))
        {
index 2ded78b1a679c733722832eaaebddcab67b42b18..b45d189a8558a943550ffd1ab6714f9f5e7707a7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.37 1999/03/28 20:31:58 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.38 1999/05/25 16:07:27 momjian Exp $
  *
  * NOTES
  *   This file contains only the public interface routines.
@@ -367,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
    btitem = _bt_formitem(itup);
 
    res = _bt_doinsert(rel, btitem,
-                            IndexIsUnique(RelationGetRelid(rel)), heapRel);
+                      IndexIsUnique(RelationGetRelid(rel)), heapRel);
 
    pfree(btitem);
    pfree(itup);
@@ -391,9 +391,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir)
 
    if (ItemPointerIsValid(&(scan->currentItemData)))
    {
+
        /*
-        * Restore scan position using heap TID returned 
-        * by previous call to btgettuple().
+        * Restore scan position using heap TID returned by previous call
+        * to btgettuple().
         */
        _bt_restscan(scan);
        res = _bt_next(scan, dir);
@@ -623,16 +624,15 @@ _bt_restscan(IndexScanDesc scan)
    BlockNumber blkno;
 
    /*
-    * We use this as flag when first index tuple on page
-    * is deleted but we do not move left (this would
-    * slowdown vacuum) - so we set current->ip_posid
-    * before first index tuple on the current page
+    * We use this as flag when first index tuple on page is deleted but
+    * we do not move left (this would slowdown vacuum) - so we set
+    * current->ip_posid before first index tuple on the current page
     * (_bt_step will move it right)...
     */
    if (!ItemPointerIsValid(&target))
    {
-       ItemPointerSetOffsetNumber(&(scan->currentItemData), 
-           OffsetNumberPrev(P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY));
+       ItemPointerSetOffsetNumber(&(scan->currentItemData),
+          OffsetNumberPrev(P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY));
        return;
    }
 
index a2a6707d1951d8f0fb2b4b1c074cfcfd85b34fcf..79e0c879d044dcdfd3e0230e1105d9b92b586262 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.20 1999/03/28 20:31:58 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.21 1999/05/25 16:07:29 momjian Exp $
  *
  *
  * NOTES
@@ -112,12 +112,12 @@ _bt_adjscans(Relation rel, ItemPointer tid)
 static void
 _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
 {
-   ItemPointer     current;
-   Buffer          buf;
-   BTScanOpaque    so;
-   OffsetNumber    start;
-   Page            page;
-   BTPageOpaque    opaque;
+   ItemPointer current;
+   Buffer      buf;
+   BTScanOpaque so;
+   OffsetNumber start;
+   Page        page;
+   BTPageOpaque opaque;
 
    so = (BTScanOpaque) scan->opaque;
    buf = so->btso_curbuf;
@@ -140,7 +140,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
            {
                Page        pg = BufferGetPage(buf);
                BTItem      btitem = (BTItem) PageGetItem(pg,
-                  PageGetItemId(pg, ItemPointerGetOffsetNumber(current)));
+                PageGetItemId(pg, ItemPointerGetOffsetNumber(current)));
 
                so->curHeapIptr = btitem->bti_itup.t_tid;
            }
@@ -181,7 +181,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
            {
                Page        pg = BufferGetPage(buf);
                BTItem      btitem = (BTItem) PageGetItem(pg,
-                  PageGetItemId(pg, ItemPointerGetOffsetNumber(current)));
+                PageGetItemId(pg, ItemPointerGetOffsetNumber(current)));
 
                so->mrkHeapIptr = btitem->bti_itup.t_tid;
            }
index 1ea080abd721638aad7da2cbbe2db0c59aff0107..cc3fc7475b4456955a11d9f14a615e8ceeeeb47a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.43 1999/04/13 17:18:28 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.44 1999/05/25 16:07:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -706,7 +706,7 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
    so = (BTScanOpaque) scan->opaque;
    current = &(scan->currentItemData);
 
-   Assert (BufferIsValid(so->btso_curbuf));
+   Assert(BufferIsValid(so->btso_curbuf));
 
    /* we still have the buffer pinned and locked */
    buf = so->btso_curbuf;
@@ -733,8 +733,8 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
            return res;
        }
 
-   } while (keysok >= so->numberOfFirstKeys || 
-        (keysok == -1 && ScanDirectionIsBackward(dir)));
+   } while (keysok >= so->numberOfFirstKeys ||
+            (keysok == -1 && ScanDirectionIsBackward(dir)));
 
    ItemPointerSetInvalid(current);
    so->btso_curbuf = InvalidBuffer;
@@ -776,8 +776,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
    BTScanOpaque so;
    ScanKeyData skdata;
    Size        keysok;
-   int     i;
-   int     nKeyIndex = -1;
+   int         i;
+   int         nKeyIndex = -1;
 
    rel = scan->relation;
    so = (BTScanOpaque) scan->opaque;
@@ -795,27 +795,27 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 
        if (ScanDirectionIsBackward(dir))
        {
-           for (i=0; i<so->numberOfKeys; i++)
+           for (i = 0; i < so->numberOfKeys; i++)
            {
                if (so->keyData[i].sk_attno != 1)
                    break;
-               strat = _bt_getstrat(rel, so->keyData[i].sk_attno, 
-                   so->keyData[i].sk_procedure);
+               strat = _bt_getstrat(rel, so->keyData[i].sk_attno,
+                                    so->keyData[i].sk_procedure);
                if (strat == BTLessStrategyNumber ||
-                   strat == BTLessEqualStrategyNumber||
-                   strat == BTEqualStrategyNumber)
+                   strat == BTLessEqualStrategyNumber ||
+                   strat == BTEqualStrategyNumber)
                {
                    nKeyIndex = i;
                    break;
                }
            }
        }
-       else 
+       else
        {
            strat = _bt_getstrat(rel, 1, so->keyData[0].sk_procedure);
 
            if (strat == BTLessStrategyNumber ||
-               strat == BTLessEqualStrategyNumber)
+               strat == BTLessEqualStrategyNumber)
                ;
            else
                nKeyIndex = 0;
@@ -850,7 +850,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
    }
    proc = index_getprocid(rel, 1, BTORDER_PROC);
    ScanKeyEntryInitialize(&skdata, so->keyData[nKeyIndex].sk_flags,
-               1, proc, so->keyData[nKeyIndex].sk_argument);
+                          1, proc, so->keyData[nKeyIndex].sk_argument);
 
    stack = _bt_search(rel, 1, &skdata, &buf);
    _bt_freestack(stack);
@@ -1104,9 +1104,10 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
 
    rel = scan->relation;
    current = &(scan->currentItemData);
+
    /*
-    * Don't use ItemPointerGetOffsetNumber or you risk to get
-    * assertion due to ability of ip_posid to be equal 0.
+    * Don't use ItemPointerGetOffsetNumber or you risk to get assertion
+    * due to ability of ip_posid to be equal 0.
     */
    offnum = current->ip_posid;
    page = BufferGetPage(*bufP);
index c8c494d3f943b18f608cfe3a0fdc8522939e0c43..d5c2c30bef88c903b9f4f9130d635ca77823db2b 100644 (file)
@@ -5,7 +5,7 @@
  *
  *
  * IDENTIFICATION
- *   $Id: nbtsort.c,v 1.38 1999/05/09 00:53:19 tgl Exp $
+ *   $Id: nbtsort.c,v 1.39 1999/05/25 16:07:34 momjian Exp $
  *
  * NOTES
  *
@@ -552,16 +552,16 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique)
    btspool->bts_tape = 0;
    btspool->isunique = isunique;
 
-   btspool->bts_itape =(BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes);
-   btspool->bts_otape =(BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes);
+   btspool->bts_itape = (BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes);
+   btspool->bts_otape = (BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes);
    if (btspool->bts_itape == (BTTapeBlock **) NULL ||
        btspool->bts_otape == (BTTapeBlock **) NULL)
        elog(ERROR, "_bt_spoolinit: out of memory");
 
    for (i = 0; i < ntapes; ++i)
    {
-       btspool->bts_itape[i] = _bt_tapecreate();
-       btspool->bts_otape[i] = _bt_tapecreate();
+       btspool->bts_itape[i] = _bt_tapecreate();
+       btspool->bts_otape[i] = _bt_tapecreate();
    }
 
    _bt_isortcmpinit(index, btspool);
index 57e894245005063d720c15035439040723206eaa..f62a4bf648a1b0aed26b52b29fa9d5bb344a964d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.31 1999/02/13 23:14:42 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.32 1999/05/25 16:07:38 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -307,7 +307,7 @@ rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation he
    /*
     * Notes in ExecUtils:ExecOpenIndices()
     *
-   RelationSetLockForWrite(r);
+    * RelationSetLockForWrite(r);
     */
 
    res = rtdoinsert(r, itup, &rtState);
@@ -947,10 +947,10 @@ rtdelete(Relation r, ItemPointer tid)
    Page        page;
 
    /*
-    * Notes in ExecUtils:ExecOpenIndices()
-    * Also note that only vacuum deletes index tuples now...
+    * Notes in ExecUtils:ExecOpenIndices() Also note that only vacuum
+    * deletes index tuples now...
     *
-   RelationSetLockForWrite(r);
+    * RelationSetLockForWrite(r);
     */
 
    blkno = ItemPointerGetBlockNumber(tid);
index 596972960bdbf8a909790c9d810c7ac7ffb71796..b74a341304a7a97e8cecf45f150df9d05fb377fc 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.22 1999/02/13 23:14:43 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.23 1999/05/25 16:07:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -69,7 +69,7 @@ rtbeginscan(Relation r,
    /*
     * Let index_beginscan does its work...
     *
-   RelationSetLockForRead(r);
+    * RelationSetLockForRead(r);
     */
 
    s = RelationGetIndexScan(r, fromEnd, nkeys, key);
index 35f07e6185a75e1ffc0943811d993302452b6ade..fe1d57d769c0945d1e30137727eb5b4a35b1e4c0 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.25 1999/03/30 01:37:21 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.26 1999/05/25 16:07:45 momjian Exp $
  *
  * NOTES
  *   This file contains the high level access-method interface to the
@@ -221,7 +221,7 @@ TransactionLogUpdate(TransactionId transactionId,       /* trans id to update */
    /*
     * update (invalidate) our single item TransactionLogTest cache.
     *
-   if (status != XID_COMMIT)
+    * if (status != XID_COMMIT)
     *
     * What's the hell ?! Why != XID_COMMIT ?!
     */
@@ -374,7 +374,7 @@ TransRecover(Relation logRelation)
  */
 
 /*
- * InitializeTransactionLog 
+ * InitializeTransactionLog
  *     Initializes transaction logging.
  */
 void
@@ -484,7 +484,7 @@ InitializeTransactionLog(void)
  */
 
 /*
- * TransactionIdDidCommit 
+ * TransactionIdDidCommit
  *     True iff transaction associated with the identifier did commit.
  *
  * Note:
@@ -500,7 +500,7 @@ TransactionIdDidCommit(TransactionId transactionId)
 }
 
 /*
- * TransactionIdDidAborted 
+ * TransactionIdDidAborted
  *     True iff transaction associated with the identifier did abort.
  *
  * Note:
@@ -541,7 +541,7 @@ TransactionIdIsInProgress(TransactionId transactionId)
  */
 
 /*
- * TransactionIdCommit 
+ * TransactionIdCommit
  *     Commits the transaction associated with the identifier.
  *
  * Note:
@@ -557,7 +557,7 @@ TransactionIdCommit(TransactionId transactionId)
 }
 
 /*
- * TransactionIdAbort 
+ * TransactionIdAbort
  *     Aborts the transaction associated with the identifier.
  *
  * Note:
index f910ea5f0f1d32cee6d3429311657ddf1a17c2ed..4bcc55bb92c7e4ed1cad72a3d87b386036700b54 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.19 1999/02/13 23:14:48 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.20 1999/05/25 16:07:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -260,7 +260,7 @@ VariableRelationPutNextOid(Oid *oidP)
  *     In the version 2 transaction system, transaction id's are
  *     restricted in several ways.
  *
- *     -- Old comments removed 
+ *     -- Old comments removed
  *
  *     Second, since we may someday preform compression of the data
  *     in the log and time relations, we cause the numbering of the
index f125baed6db73edc89f3196c93ad00cf04477e09..000abbc7ecbe9fbb312bb988d7c297b2e5fefad4 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.35 1999/05/13 00:34:57 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.36 1999/05/25 16:07:50 momjian Exp $
  *
  * NOTES
  *     Transaction aborts can now occur two ways:
@@ -194,8 +194,8 @@ TransactionStateData CurrentTransactionStateData = {
 
 TransactionState CurrentTransactionState = &CurrentTransactionStateData;
 
-int    DefaultXactIsoLevel = XACT_READ_COMMITTED;
-int    XactIsoLevel;
+int            DefaultXactIsoLevel = XACT_READ_COMMITTED;
+int            XactIsoLevel;
 
 /* ----------------
  *     info returned when the system is disabled
@@ -299,6 +299,7 @@ IsTransactionState(void)
     */
    return false;
 }
+
 #endif
 
 /* --------------------------------
@@ -516,7 +517,7 @@ CommandCounterIncrement()
    AtStart_Cache();
 
    TransactionIdFlushCache();
-   
+
 }
 
 void
@@ -695,9 +696,9 @@ AtCommit_Memory()
 
    /* ----------------
     *  Release memory in the blank portal.
-    *  Since EndPortalAllocMode implicitly works on the current context,
-    *  first make real sure that the blank portal is the selected context.
-    *  (This is probably not necessary, but seems like a good idea...)
+    *  Since EndPortalAllocMode implicitly works on the current context,
+    *  first make real sure that the blank portal is the selected context.
+    *  (This is probably not necessary, but seems like a good idea...)
     * ----------------
     */
    portal = GetPortalByName(NULL);
@@ -789,9 +790,9 @@ AtAbort_Memory()
 
    /* ----------------
     *  Release memory in the blank portal.
-    *  Since EndPortalAllocMode implicitly works on the current context,
-    *  first make real sure that the blank portal is the selected context.
-    *  (This is ESSENTIAL in case we aborted from someplace where it wasn't.)
+    *  Since EndPortalAllocMode implicitly works on the current context,
+    *  first make real sure that the blank portal is the selected context.
+    *  (This is ESSENTIAL in case we aborted from someplace where it wasn't.)
     * ----------------
     */
    portal = GetPortalByName(NULL);
@@ -1074,7 +1075,7 @@ StartTransactionCommand()
            break;
 
            /* ----------------
-            *      As with BEGIN, we should never experience this 
+            *      As with BEGIN, we should never experience this
             *      if we do it means the END state was not changed in the
             *      previous CommitTransactionCommand().  If we get it, we
             *      print a warning, commit the transaction, start a new
@@ -1509,6 +1510,7 @@ AbortOutOfAnyTransaction()
     */
    if (s->state != TRANS_DEFAULT)
        AbortTransaction();
+
    /*
     * Now reset the high-level state
     */
index e7b68d48e7f5b8f2497f5c05b0eba958dfa0539a..2b15fec1bf64c30a752d9dc7f379d9e7fd4ac877 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- *  $Id: xid.c,v 1.21 1999/02/13 23:14:49 momjian Exp $
+ * $Id: xid.c,v 1.22 1999/05/25 16:07:52 momjian Exp $
  *
  * OLD COMMENTS
  * XXX WARNING
index 80f1142949fc476b116d22527fe3ccb2527e413c..6c7e7c16fa1e084a1e00c80c897e561fbb39a00b 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.59 1999/05/10 00:44:52 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.60 1999/05/25 16:07:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -182,7 +182,7 @@ static char *relname;           /* current relation name */
 Form_pg_attribute attrtypes[MAXATTR];  /* points to attribute info */
 static char *values[MAXATTR];  /* cooresponding attribute values */
 int            numattr;            /* number of attributes for cur. rel */
-extern bool    disableFsync;           /* do not fsync the database */
+extern bool disableFsync;      /* do not fsync the database */
 
 int            DebugMode;
 static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
@@ -587,7 +587,9 @@ DefineAttr(char *name, char *type, int attnum)
            printf("<%s %s> ", attrtypes[attnum]->attname.data, type);
        attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
        attlen = attrtypes[attnum]->attlen = Procid[typeoid].len;
-       /* Cheat like mad to fill in these items from the length only.
+
+       /*
+        * Cheat like mad to fill in these items from the length only.
         * This only has to work for types used in the system catalogs...
         */
        switch (attlen)
index 8e0953809c47b5e77200971329c4667ac8a15228..5e7207143545fd81333ddbe60e743e8aa4361446 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.20 1999/02/13 23:14:55 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.21 1999/05/25 16:08:01 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,8 +29,8 @@
 char *
 relpath(char *relname)
 {
-   char    *path;
-   int     bufsize = 0;
+   char       *path;
+   int         bufsize = 0;
 
    if (IsSharedSystemRelationName(relname))
    {
@@ -43,7 +43,7 @@ relpath(char *relname)
 }
 
 /*
- * IsSystemRelationName 
+ * IsSystemRelationName
  *     True iff name is the name of a system catalog relation.
  *
  *     We now make a new requirement where system catalog relns must begin
@@ -64,7 +64,7 @@ IsSystemRelationName(char *relname)
 }
 
 /*
- * IsSharedSystemRelationName 
+ * IsSharedSystemRelationName
  *     True iff name is the name of a shared system catalog relation.
  */
 bool
index c82a258a3b24c1540f6b7247b8f049661f7d1132..89e45fb2bfc86add13b0c9a2d4f1bb3e9e903b41 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.84 1999/05/22 04:12:24 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.85 1999/05/25 16:08:03 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -70,8 +70,8 @@
 #endif
 
 static void AddNewRelationTuple(Relation pg_class_desc,
-                  Relation new_rel_desc, Oid new_rel_oid, unsigned natts,
-                  char relkind, char *temp_relname);
+                 Relation new_rel_desc, Oid new_rel_oid, unsigned natts,
+                   char relkind, char *temp_relname);
 static void AddToNoNameRelList(Relation r);
 static void DeleteAttributeTuples(Relation rel);
 static void DeleteRelationTuple(Relation rel);
@@ -185,7 +185,7 @@ heap_create(char *relname,
    bool        nailme = false;
    int         natts = tupDesc->natts;
    static unsigned int uniqueId = 0;
-   
+
    extern GlobalMemory CacheCxt;
    MemoryContext oldcxt;
 
@@ -240,23 +240,21 @@ heap_create(char *relname,
        nailme = true;
    }
    else
-   {
        relid = newoid();
-   }
 
    if (isnoname)
    {
        Assert(!relname);
        relname = palloc(NAMEDATALEN);
        snprintf(relname, NAMEDATALEN, "pg_noname.%d.%u",
-           (int) MyProcPid, uniqueId++);
+                (int) MyProcPid, uniqueId++);
    }
 
    if (istemp)
    {
        /* replace relname of caller */
        snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u",
-           (int) MyProcPid, uniqueId++);
+                (int) MyProcPid, uniqueId++);
    }
 
    /* ----------------
@@ -272,7 +270,7 @@ heap_create(char *relname,
 
    /*
     * create a new tuple descriptor from the one passed in
-   */
+    */
    rel->rd_att = CreateTupleDescCopyConstr(tupDesc);
 
    /* ----------------
@@ -321,7 +319,7 @@ heap_create(char *relname,
     * ----------------
     */
 
-   rel->rd_nonameunlinked = TRUE; /* change once table is created */
+   rel->rd_nonameunlinked = TRUE;      /* change once table is created */
    rel->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rel);
    rel->rd_nonameunlinked = FALSE;
 
@@ -479,8 +477,8 @@ RelnameFindRelid(char *relname)
    if (!IsBootstrapProcessingMode())
    {
        tuple = SearchSysCacheTuple(RELNAME,
-                                 PointerGetDatum(relname),
-                                 0, 0, 0);
+                                   PointerGetDatum(relname),
+                                   0, 0, 0);
        if (HeapTupleIsValid(tuple))
            relid = tuple->t_data->t_oid;
        else
@@ -488,10 +486,10 @@ RelnameFindRelid(char *relname)
    }
    else
    {
-       Relation pg_class_desc;
+       Relation    pg_class_desc;
        ScanKeyData key;
        HeapScanDesc pg_class_scan;
-       
+
        pg_class_desc = heap_openr(RelationRelationName);
 
        /* ----------------
@@ -504,7 +502,7 @@ RelnameFindRelid(char *relname)
                               (AttrNumber) Anum_pg_class_relname,
                               (RegProcedure) F_NAMEEQ,
                               (Datum) relname);
-   
+
        /* ----------------
         *  begin the scan
         * ----------------
@@ -514,14 +512,14 @@ RelnameFindRelid(char *relname)
                                       SnapshotNow,
                                       1,
                                       &key);
-   
+
        /* ----------------
         *  get a tuple.  if the tuple is NULL then it means we
         *  didn't find an existing relation.
         * ----------------
         */
        tuple = heap_getnext(pg_class_scan, 0);
-   
+
        if (HeapTupleIsValid(tuple))
            relid = tuple->t_data->t_oid;
        else
@@ -594,7 +592,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
                             (char *) *dpp);
 
        heap_insert(rel, tup);
-           
+
        if (hasindex)
            CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
 
@@ -643,11 +641,11 @@ AddNewAttributeTuples(Oid new_rel_oid,
  */
 static void
 AddNewRelationTuple(Relation pg_class_desc,
-                  Relation new_rel_desc,
-                  Oid new_rel_oid,
-                  unsigned natts,
-                  char relkind,
-                  char *temp_relname)
+                   Relation new_rel_desc,
+                   Oid new_rel_oid,
+                   unsigned natts,
+                   char relkind,
+                   char *temp_relname)
 {
    Form_pg_class new_rel_reltup;
    HeapTuple   tup;
@@ -678,12 +676,12 @@ AddNewRelationTuple(Relation pg_class_desc,
     * the table has been proven to be small by VACUUM or CREATE INDEX.
     * (NOTE: if user does CREATE TABLE, then CREATE INDEX, then loads
     * the table, he still loses until he vacuums, because CREATE INDEX
-    * will set reltuples to zero.  Can't win 'em all.  Maintaining the
+    * will set reltuples to zero.  Can't win 'em all.  Maintaining the
     * stats on-the-fly would solve the problem, but the overhead of that
     * would likely cost more than it'd save.)
     * ----------------
     */
-   new_rel_reltup->relpages = 10; /* bogus estimates */
+   new_rel_reltup->relpages = 10;      /* bogus estimates */
    new_rel_reltup->reltuples = 1000;
 
    new_rel_reltup->relowner = GetUserId();
@@ -716,9 +714,10 @@ AddNewRelationTuple(Relation pg_class_desc,
 
    if (temp_relname)
        create_temp_relation(temp_relname, tup);
-   
+
    if (!isBootstrap)
    {
+
        /*
         * First, open the catalog indices and insert index tuples for the
         * new relation.
@@ -730,7 +729,7 @@ AddNewRelationTuple(Relation pg_class_desc,
        /* now restore processing mode */
        SetProcessingMode(NormalProcessing);
    }
-   
+
    pfree(tup);
 }
 
@@ -788,8 +787,8 @@ heap_create_with_catalog(char *relname,
    Relation    new_rel_desc;
    Oid         new_rel_oid;
    int         natts = tupdesc->natts;
-   char        *temp_relname = NULL;
-   
+   char       *temp_relname = NULL;
+
    /* ----------------
     *  sanity checks
     * ----------------
@@ -804,33 +803,34 @@ heap_create_with_catalog(char *relname,
 
    /* temp tables can mask non-temp tables */
    if ((!istemp && RelnameFindRelid(relname)) ||
-      (istemp && get_temp_rel_by_name(relname) != NULL))
+       (istemp && get_temp_rel_by_name(relname) != NULL))
        elog(ERROR, "Relation '%s' already exists", relname);
 
    /* invalidate cache so non-temp table is masked by temp */
    if (istemp)
    {
-       Oid relid = RelnameFindRelid(relname);
+       Oid         relid = RelnameFindRelid(relname);
 
        if (relid != InvalidOid)
        {
+
            /*
-            *  This is heavy-handed, but appears necessary bjm 1999/02/01
-            *  SystemCacheRelationFlushed(relid) is not enough either.
+            * This is heavy-handed, but appears necessary bjm 1999/02/01
+            * SystemCacheRelationFlushed(relid) is not enough either.
             */
            RelationForgetRelation(relid);
            ResetSystemCache();
-       }   
+       }
    }
-   
+
    /* save user relation name because heap_create changes it */
    if (istemp)
    {
-       temp_relname = pstrdup(relname); /* save original value */
+       temp_relname = pstrdup(relname);        /* save original value */
        relname = palloc(NAMEDATALEN);
-       strcpy(relname, temp_relname); /* heap_create will change this */
+       strcpy(relname, temp_relname);  /* heap_create will change this */
    }
-   
+
    /* ----------------
     *  ok, relation does not already exist so now we
     *  create an uncataloged relation and pull its relation oid
@@ -838,7 +838,7 @@ heap_create_with_catalog(char *relname,
     *
     *  Note: The call to heap_create() does all the "real" work
     *  of creating the disk file for the relation.
-    *  This changes relname for noname and temp tables.
+    *  This changes relname for noname and temp tables.
     * ----------------
     */
    new_rel_desc = heap_create(relname, tupdesc, false, istemp);
@@ -866,11 +866,11 @@ heap_create_with_catalog(char *relname,
    pg_class_desc = heap_openr(RelationRelationName);
 
    AddNewRelationTuple(pg_class_desc,
-                      new_rel_desc,
-                      new_rel_oid,
-                      natts,
-                      relkind,
-                      temp_relname);
+                       new_rel_desc,
+                       new_rel_oid,
+                       natts,
+                       relkind,
+                       temp_relname);
 
    StoreConstraints(new_rel_desc);
 
@@ -1320,7 +1320,7 @@ heap_destroy_with_catalog(char *relname)
 
    if (istemp)
        remove_temp_relation(rid);
-       
+
    /* ----------------
     *  delete type tuple.  here we want to see the effects
     *  of the deletions we just did, so we use setheapoverride().
@@ -1334,7 +1334,7 @@ heap_destroy_with_catalog(char *relname)
     *  delete relation tuple
     * ----------------
     */
-    /* must delete fake tuple in cache */
+   /* must delete fake tuple in cache */
    DeleteRelationTuple(rel);
 
    /*
@@ -1516,10 +1516,12 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef)
    extern GlobalMemory CacheCxt;
 
 start:
-   /* Surround table name with double quotes to allow mixed-case and
+
+   /*
+    * Surround table name with double quotes to allow mixed-case and
     * whitespaces in names. - BGA 1998-11-14
     */
-   snprintf(str, MAX_PARSE_BUFFER, 
+   snprintf(str, MAX_PARSE_BUFFER,
             "select %s%s from \"%.*s\"", attrdef->adsrc, cast,
             NAMEDATALEN, rel->rd_rel->relname.data);
    setheapoverride(true);
@@ -1539,16 +1541,16 @@ start:
    if (type != atp->atttypid)
    {
        if (IS_BINARY_COMPATIBLE(type, atp->atttypid))
-           ; /* use without change */
+           ;                   /* use without change */
        else if (can_coerce_type(1, &(type), &(atp->atttypid)))
-           expr = coerce_type(NULL, (Node *)expr, type, atp->atttypid,
-                                                        atp->atttypmod);
+           expr = coerce_type(NULL, (Node *) expr, type, atp->atttypid,
+                              atp->atttypmod);
        else if (IsA(expr, Const))
        {
            if (*cast != 0)
                elog(ERROR, "DEFAULT clause const type '%s' mismatched with column type '%s'",
                     typeidTypeName(type), typeidTypeName(atp->atttypid));
-           snprintf(cast, 2*NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid));
+           snprintf(cast, 2 * NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid));
            goto start;
        }
        else
@@ -1598,12 +1600,13 @@ StoreRelCheck(Relation rel, ConstrCheck *check)
    char        nulls[4] = {' ', ' ', ' ', ' '};
    extern GlobalMemory CacheCxt;
 
-   /* Check for table's existance. Surround table name with double-quotes
+   /*
+    * Check for table's existance. Surround table name with double-quotes
     * to allow mixed-case and whitespace names. - thomas 1998-11-12
     */
-   snprintf(str, MAX_PARSE_BUFFER, 
-           "select 1 from \"%.*s\" where %s",
-           NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
+   snprintf(str, MAX_PARSE_BUFFER,
+            "select 1 from \"%.*s\" where %s",
+            NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
    setheapoverride(true);
    planTree_list = pg_parse_and_plan(str, NULL, 0,
                                      &queryTree_list, None, FALSE);
index 7fc6cb0464a37e8d1474a4425ccf7c2944a46228..93f34ce0749d25bebcf2b951b930c25dde97d78d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.74 1999/05/17 00:27:45 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.75 1999/05/25 16:08:06 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -60,8 +60,8 @@
 #define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
 
 /* non-export function prototypes */
-static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
-                               bool istemp);
+static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
+                  bool istemp);
 static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
 static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
                         List *attributeList,
@@ -77,7 +77,7 @@ static void
 static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
                    FuncIndexInfo *funcInfo, int natts,
                    AttrNumber *attNums, Oid *classOids, Node *predicate,
-                   List *attributeList, bool islossy, bool unique, bool primary);
+          List *attributeList, bool islossy, bool unique, bool primary);
 static void DefaultBuild(Relation heapRelation, Relation indexRelation,
             int numberOfAttributes, AttrNumber *attributeNumber,
             IndexStrategy indexStrategy, uint16 parameterCount,
@@ -126,11 +126,11 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp)
    Oid         indoid;
    Oid         heapoid;
 
-   
+
    indoid = RelnameFindRelid(indexRelationName);
 
    if ((!istemp && OidIsValid(indoid)) ||
-       (istemp && get_temp_rel_by_name(indexRelationName) != NULL))
+       (istemp && get_temp_rel_by_name(indexRelationName) != NULL))
        elog(ERROR, "Cannot create index: '%s' already exists",
             indexRelationName);
 
@@ -139,7 +139,7 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp)
    if (!OidIsValid(heapoid))
        elog(ERROR, "Cannot create index on '%s': relation does not exist",
             heapRelationName);
-            
+
    return heapoid;
 }
 
@@ -356,7 +356,7 @@ ConstructTupleDescriptor(Oid heapoid,
 }
 
 /* ----------------------------------------------------------------
- * AccessMethodObjectIdGetForm 
+ * AccessMethodObjectIdGetForm
  *     Returns the formated access method tuple given its object identifier.
  *
  * XXX ADD INDEXING
@@ -482,7 +482,7 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname)
 
    if (temp_relname)
        create_temp_relation(temp_relname, tuple);
-   
+
    /*
     * During normal processing, we need to make sure that the system
     * catalog indices are correct.  Bootstrap (initdb) time doesn't
@@ -571,7 +571,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
    value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
 
    init_tuple = heap_addheader(Natts_pg_attribute,
-                   ATTRIBUTE_TUPLE_SIZE,
+                               ATTRIBUTE_TUPLE_SIZE,
                             (char *) (indexRelation->rd_att->attrs[0]));
 
    hasind = false;
@@ -611,7 +611,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
         */
        memmove(GETSTRUCT(cur_tuple),
                (char *) indexTupDesc->attrs[i],
-                   ATTRIBUTE_TUPLE_SIZE);
+               ATTRIBUTE_TUPLE_SIZE);
 
        value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1);
 
@@ -657,7 +657,7 @@ UpdateIndexRelation(Oid indexoid,
                    List *attributeList,
                    bool islossy,
                    bool unique,
-                    bool primary)
+                   bool primary)
 {
    Form_pg_index indexForm;
    IndexElem  *IndexKey;
@@ -686,7 +686,7 @@ UpdateIndexRelation(Oid indexoid,
    predLen = VARSIZE(predText);
    itupLen = predLen + sizeof(FormData_pg_index);
    indexForm = (Form_pg_index) palloc(itupLen);
-   memset (indexForm, 0, sizeof(FormData_pg_index));
+   memset(indexForm, 0, sizeof(FormData_pg_index));
 
    memmove((char *) &indexForm->indpred, (char *) predText, predLen);
 
@@ -939,7 +939,7 @@ index_create(char *heapRelationName,
             Node *predicate,
             bool islossy,
             bool unique,
-             bool primary)
+            bool primary)
 {
    Relation    heapRelation;
    Relation    indexRelation;
@@ -948,15 +948,15 @@ index_create(char *heapRelationName,
    Oid         indexoid;
    PredInfo   *predInfo;
    bool        istemp = (get_temp_rel_by_name(heapRelationName) != NULL);
-   char        *temp_relname = NULL;
-   
+   char       *temp_relname = NULL;
+
    /* ----------------
     *  check parameters
     * ----------------
     */
    if (numatts < 1)
        elog(ERROR, "must index at least one attribute");
-       
+
    /* ----------------
     *    get heap relation oid and open the heap relation
     *    XXX ADD INDEXING
@@ -987,25 +987,27 @@ index_create(char *heapRelationName,
    /* invalidate cache so possible non-temp index is masked by temp */
    if (istemp)
    {
-       Oid relid = RelnameFindRelid(indexRelationName);
+       Oid         relid = RelnameFindRelid(indexRelationName);
 
        if (relid != InvalidOid)
        {
+
            /*
-            *  This is heavy-handed, but appears necessary bjm 1999/02/01
-            *  SystemCacheRelationFlushed(relid) is not enough either.
+            * This is heavy-handed, but appears necessary bjm 1999/02/01
+            * SystemCacheRelationFlushed(relid) is not enough either.
             */
            RelationForgetRelation(relid);
            ResetSystemCache();
        }
    }
-   
+
    /* save user relation name because heap_create changes it */
    if (istemp)
    {
-       temp_relname = pstrdup(indexRelationName); /* save original value */
+       temp_relname = pstrdup(indexRelationName);      /* save original value */
        indexRelationName = palloc(NAMEDATALEN);
-       strcpy(indexRelationName, temp_relname); /* heap_create will change this */
+       strcpy(indexRelationName, temp_relname);        /* heap_create will
+                                                        * change this */
    }
 
    /* ----------------
@@ -1122,8 +1124,8 @@ index_destroy(Oid indexId)
    Relation    relationRelation;
    Relation    attributeRelation;
    HeapTuple   tuple;
-   int16       attnum;
-   
+   int16       attnum;
+
    Assert(OidIsValid(indexId));
 
    /* Open now to obtain lock by referencing table?  bjm */
@@ -1166,7 +1168,7 @@ index_destroy(Oid indexId)
 
    /* does something only if it is a temp index */
    remove_temp_relation(indexId);
-       
+
    /* ----------------
     * fix INDEX relation
     * ----------------
index 89230f16c0b3ad313031a5fc72ca20ba0f4f729a..a7a1dda444cd8a8ea0e2f2f92a823e685cb3dc26 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.37 1999/05/10 00:44:55 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.38 1999/05/25 16:08:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
  */
 
 char      *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
-           AttributeNumIndex,
-           AttributeRelidIndex};
+   AttributeNumIndex,
+AttributeRelidIndex};
 char      *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
-           ProcedureOidIndex,
-           ProcedureSrcIndex};
+   ProcedureOidIndex,
+ProcedureSrcIndex};
 char      *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
-           TypeOidIndex};
+TypeOidIndex};
 char      *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
-           ClassOidIndex};
+ClassOidIndex};
 char      *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
 
 char      *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
@@ -63,9 +63,9 @@ char     *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
 
 
 static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,
-                                       Relation idesc,
-                                       ScanKey skey,
-                                       int16 num_keys);
+                      Relation idesc,
+                      ScanKey skey,
+                      int16 num_keys);
 
 
 /*
@@ -126,13 +126,13 @@ CatalogIndexInsert(Relation *idescs,
 
        index_tup = SearchSysCacheTupleCopy(INDEXRELID,
                                      ObjectIdGetDatum(idescs[i]->rd_id),
-                                            0, 0, 0);
+                                           0, 0, 0);
        Assert(index_tup);
        index_form = (Form_pg_index) GETSTRUCT(index_tup);
 
        if (index_form->indproc != InvalidOid)
        {
-           int fatts;
+           int         fatts;
 
            /*
             * Compute the number of attributes we are indexing upon.
@@ -152,7 +152,7 @@ CatalogIndexInsert(Relation *idescs,
            natts = RelationGetDescr(idescs[i])->natts;
            finfoP = (FuncIndexInfo *) NULL;
        }
-       
+
        FormIndexDatum(natts,
                       (AttrNumber *) index_form->indkey,
                       heapTuple,
@@ -229,11 +229,11 @@ CatalogIndexFetchTuple(Relation heapRelation,
                       ScanKey skey,
                       int16 num_keys)
 {
-   IndexScanDesc       sd;
+   IndexScanDesc sd;
    RetrieveIndexResult indexRes;
-   HeapTupleData       tuple;
-   HeapTuple           result = NULL;
-   Buffer              buffer;
+   HeapTupleData tuple;
+   HeapTuple   result = NULL;
+   Buffer      buffer;
 
    sd = index_beginscan(idesc, false, num_keys, skey);
    tuple.t_data = NULL;
@@ -462,7 +462,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
     */
    if ((tuple = get_temp_rel_by_name(relName)) != NULL)
        return heap_copytuple(tuple);
-       
+
    ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
index b3b11f845ade6a8e13a615dda8e622c9c410d138..58c87302d0a3e952e9b646437cbd7f11a6c94e2b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.36 1999/05/10 00:44:56 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.37 1999/05/25 16:08:09 momjian Exp $
  *
  * NOTES
  *   these routines moved here from commands/define.c and somewhat cleaned up.
 #endif
 
 static Oid OperatorGetWithOpenRelation(Relation pg_operator_desc,
-                                      const char *operatorName,
-                                      Oid leftObjectId,
-                                      Oid rightObjectId,
-                                      bool *defined);
+                           const char *operatorName,
+                           Oid leftObjectId,
+                           Oid rightObjectId,
+                           bool *defined);
 
 static Oid OperatorGet(char *operatorName,
-                      char *leftTypeName,
-                      char *rightTypeName,
-                      bool *defined);
+           char *leftTypeName,
+           char *rightTypeName,
+           bool *defined);
 
 static Oid OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
                                  char *operatorName,
@@ -135,6 +135,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
    if (HeapTupleIsValid(tup))
    {
        regproc     oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode;
+
        operatorObjectId = tup->t_data->t_oid;
        *defined = RegProcedureIsValid(oprcode);
    }
@@ -259,7 +260,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
 
    /* ----------------
     *  initialize *values with the operator name and input data types.
-    *  Note that oprcode is set to InvalidOid, indicating it's a shell.
+    *  Note that oprcode is set to InvalidOid, indicating it's a shell.
     * ----------------
     */
    i = 0;
@@ -356,9 +357,9 @@ OperatorShellMake(char *operatorName,
     * ----------------
     */
    operatorObjectId = OperatorShellMakeWithOpenRelation(pg_operator_desc,
-                                         operatorName,
-                                         leftObjectId,
-                                         rightObjectId);
+                                                        operatorName,
+                                                        leftObjectId,
+                                                        rightObjectId);
    /* ----------------
     *  close the operator relation and return the oid.
     * ----------------
@@ -506,8 +507,9 @@ OperatorDef(char *operatorName,
        elog(ERROR, "OperatorDef: operator \"%s\" already defined",
             operatorName);
 
-   /* At this point, if operatorObjectId is not InvalidOid then
-    * we are filling in a previously-created shell.
+   /*
+    * At this point, if operatorObjectId is not InvalidOid then we are
+    * filling in a previously-created shell.
     */
 
    /* ----------------
@@ -580,7 +582,7 @@ OperatorDef(char *operatorName,
 
    values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_data->t_oid);
    values[Anum_pg_operator_oprresult - 1] = ObjectIdGetDatum(((Form_pg_proc)
-                         GETSTRUCT(tup))->prorettype);
+                                           GETSTRUCT(tup))->prorettype);
 
    /* ----------------
     *  find restriction
@@ -648,7 +650,8 @@ OperatorDef(char *operatorName,
    values[i++] = ObjectIdGetDatum(leftTypeId);
    values[i++] = ObjectIdGetDatum(rightTypeId);
 
-   ++i;                        /* Skip "oprresult", it was filled in above */
+   ++i;                        /* Skip "oprresult", it was filled in
+                                * above */
 
    /*
     * Set up the other operators.  If they do not currently exist, create
@@ -663,16 +666,16 @@ OperatorDef(char *operatorName,
    {
        if (name[j])
        {
-           char   *otherLeftTypeName = NULL;
-           char   *otherRightTypeName = NULL;
-           Oid     otherLeftTypeId = InvalidOid;
-           Oid     otherRightTypeId = InvalidOid;
-           Oid     other_oid = InvalidOid;
-           bool    otherDefined = false;
+           char       *otherLeftTypeName = NULL;
+           char       *otherRightTypeName = NULL;
+           Oid         otherLeftTypeId = InvalidOid;
+           Oid         otherRightTypeId = InvalidOid;
+           Oid         other_oid = InvalidOid;
+           bool        otherDefined = false;
 
            switch (j)
            {
-               case 0:         /* commutator has reversed arg types */
+               case 0: /* commutator has reversed arg types */
                    otherLeftTypeName = rightTypeName;
                    otherRightTypeName = leftTypeName;
                    otherLeftTypeId = rightTypeId;
@@ -683,7 +686,7 @@ OperatorDef(char *operatorName,
                                            &otherDefined);
                    commutatorId = other_oid;
                    break;
-               case 1:         /* negator has same arg types */
+               case 1: /* negator has same arg types */
                    otherLeftTypeName = leftTypeName;
                    otherRightTypeName = rightTypeName;
                    otherLeftTypeId = leftTypeId;
@@ -694,7 +697,7 @@ OperatorDef(char *operatorName,
                                            &otherDefined);
                    negatorId = other_oid;
                    break;
-               case 2:         /* left sort op takes left-side data type */
+               case 2: /* left sort op takes left-side data type */
                    otherLeftTypeName = leftTypeName;
                    otherRightTypeName = leftTypeName;
                    otherLeftTypeId = leftTypeId;
@@ -704,7 +707,8 @@ OperatorDef(char *operatorName,
                                            otherRightTypeName,
                                            &otherDefined);
                    break;
-               case 3:         /* right sort op takes right-side data type */
+               case 3: /* right sort op takes right-side data
+                                * type */
                    otherLeftTypeName = rightTypeName;
                    otherRightTypeName = rightTypeName;
                    otherLeftTypeId = rightTypeId;
@@ -737,8 +741,10 @@ OperatorDef(char *operatorName,
            }
            else
            {
-               /* self-linkage to this operator; will fix below.
-                * Note that only self-linkage for commutation makes sense.
+
+               /*
+                * self-linkage to this operator; will fix below. Note
+                * that only self-linkage for commutation makes sense.
                 */
                if (j != 0)
                    elog(ERROR,
@@ -804,15 +810,14 @@ OperatorDef(char *operatorName,
 
    /*
     * If a commutator and/or negator link is provided, update the other
-    * operator(s) to point at this one, if they don't already have a link.
-    * This supports an alternate style of operator definition wherein the
-    * user first defines one operator without giving negator or
-    * commutator, then defines the other operator of the pair with the
-    * proper commutator or negator attribute.  That style doesn't require
-    * creation of a shell, and it's the only style that worked right before
-    * Postgres version 6.5.
-    * This code also takes care of the situation where the new operator
-    * is its own commutator.
+    * operator(s) to point at this one, if they don't already have a
+    * link. This supports an alternate style of operator definition
+    * wherein the user first defines one operator without giving negator
+    * or commutator, then defines the other operator of the pair with the
+    * proper commutator or negator attribute.  That style doesn't require
+    * creation of a shell, and it's the only style that worked right
+    * before Postgres version 6.5. This code also takes care of the
+    * situation where the new operator is its own commutator.
     */
    if (selfCommutator)
        commutatorId = operatorObjectId;
@@ -869,7 +874,8 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 
    tup = heap_getnext(pg_operator_scan, 0);
 
-   /* if the commutator and negator are the same operator, do one update.
+   /*
+    * if the commutator and negator are the same operator, do one update.
     * XXX this is probably useless code --- I doubt it ever makes sense
     * for commutator and negator to be the same thing...
     */
@@ -1008,7 +1014,7 @@ OperatorCreate(char *operatorName,
    if (!leftTypeName && !rightTypeName)
        elog(ERROR, "OperatorCreate: at least one of leftarg or rightarg must be defined");
 
-   if (! (leftTypeName && rightTypeName))
+   if (!(leftTypeName && rightTypeName))
    {
        /* If it's not a binary op, these things mustn't be set: */
        if (commutatorName)
index 7c22ce007cd086095c584b0ad5bfbe3f46034ac3..3d31741cfe049449b4b594079180bf0ebcb2f321 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.28 1999/05/13 07:28:27 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.29 1999/05/25 16:08:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -226,11 +226,11 @@ ProcedureCreate(char *procedureName,
     * function name (the 'prosrc' value) is a known builtin function.
     *
     * NOTE: in Postgres versions before 6.5, the SQL name of the created
-    * function could not be different from the internal name, and 'prosrc'
-    * wasn't used.  So there is code out there that does CREATE FUNCTION
-    * xyz AS '' LANGUAGE 'internal'.  To preserve some modicum of
-    * backwards compatibility, accept an empty 'prosrc' value as meaning
-    * the supplied SQL function name.
+    * function could not be different from the internal name, and
+    * 'prosrc' wasn't used.  So there is code out there that does CREATE
+    * FUNCTION xyz AS '' LANGUAGE 'internal'.  To preserve some modicum
+    * of backwards compatibility, accept an empty 'prosrc' value as
+    * meaning the supplied SQL function name.
     */
 
    if (strcmp(languageName, "internal") == 0)
@@ -239,7 +239,7 @@ ProcedureCreate(char *procedureName,
            prosrc = procedureName;
        if (fmgr_lookupByName(prosrc) == (func_ptr) NULL)
            elog(ERROR,
-                "ProcedureCreate: there is no builtin function named \"%s\"",
+           "ProcedureCreate: there is no builtin function named \"%s\"",
                 prosrc);
    }
 
index 4d108a825ffc3f8b5bc1086da520159c0540685e..54856d4b76d5533c9b07a08d75189f6d7f93c361 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.36 1999/04/20 03:51:14 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.37 1999/05/25 16:08:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -400,8 +400,8 @@ TypeCreate(char *typeName,
        procname = procs[j];
 
        /*
-        * First look for a 1-argument func with all argtypes 0.
-        * This is valid for all four kinds of procedure.
+        * First look for a 1-argument func with all argtypes 0. This is
+        * valid for all four kinds of procedure.
         */
        MemSet(argList, 0, 8 * sizeof(Oid));
 
@@ -413,20 +413,23 @@ TypeCreate(char *typeName,
 
        if (!HeapTupleIsValid(tup))
        {
+
            /*
-            * For array types, the input procedures may take 3 args
-            * (data value, element OID, atttypmod); the pg_proc
-            * argtype signature is 0,0,INT4OID.  The output procedures
-            * may take 2 args (data value, element OID).
+            * For array types, the input procedures may take 3 args (data
+            * value, element OID, atttypmod); the pg_proc argtype
+            * signature is 0,0,INT4OID.  The output procedures may take 2
+            * args (data value, element OID).
             */
            if (OidIsValid(elementObjectId))
            {
-               int nargs;
+               int         nargs;
+
                if (j % 2)
                {
                    /* output proc */
                    nargs = 2;
-               } else
+               }
+               else
                {
                    /* input proc */
                    nargs = 3;
index b3ec01b91585355f6e61b91337bd8ed6c2e2a356..997c02d85da59153f5e96d6e1a65a1583cf97828 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.2 1999/03/16 04:25:46 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.3 1999/05/25 16:08:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -121,18 +121,18 @@ static QueryTreeList *tg_parseTeeNode(TgRecipe * r,
 void
 beginRecipe(RecipeStmt *stmt)
 {
-   TgRecipe            *r;
-   int                     i,
-                               numTees;
+   TgRecipe   *r;
+   int         i,
+               numTees;
    QueryTreeList *qList;
-   char                    portalName[1024];
+   char        portalName[1024];
 
-   Plan                    *plan;
-   TupleDesc           attinfo;
-   QueryDesc           *queryDesc;
-   Query                   *parsetree;
+   Plan       *plan;
+   TupleDesc   attinfo;
+   QueryDesc  *queryDesc;
+   Query      *parsetree;
 
-   TeeInfo             *teeInfo;
+   TeeInfo    *teeInfo;
 
    /*
     * retrieveRecipe() reads the recipe from the database and returns a
@@ -808,21 +808,21 @@ tg_parseTeeNode(TgRecipe * r,
 static QueryTreeList *
 tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
 {
-   TgElement           *elem;
-   char                    *funcName;
-   Oid                     typev[8],       /* eight arguments maximum  */
-                               relid;
-   int                     i,
-                               parameterCount;
+   TgElement  *elem;
+   char       *funcName;
+   Oid         typev[8],       /* eight arguments maximum  */
+               relid;
+   int         i,
+               parameterCount;
 
    QueryTreeList *qList;       /* the parse tree of the nodeElement */
    QueryTreeList *inputQlist;  /* the list of parse trees for the inputs
                                 * to this node */
    QueryTreeList *q;
-   TgNode              *child;
-   Relation            rel;
-   unsigned int    len;
-   TupleDesc           tupdesc;
+   TgNode     *child;
+   Relation    rel;
+   unsigned int len;
+   TupleDesc   tupdesc;
 
    qList = NULL;
 
index 9cb98cc5b3b612d6d37d3bd024f92b75ccb48513..6eddfdccfaf9f7c0755c9348e65d4f6d41ff1661 100644 (file)
@@ -5,17 +5,17 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * The version stuff has not been tested under postgres95 and probably 
+ * The version stuff has not been tested under postgres95 and probably
  * doesn't work! - jolly 8/19/95
  *
  *
- *  $Id: version.c,v 1.18 1999/02/13 23:15:12 momjian Exp $
+ * $Id: version.c,v 1.19 1999/05/25 16:08:32 momjian Exp $
  *
  * NOTES
  * At the point the version is defined, 2 physical relations are created
  * <vname>_added and <vname>_deleted.
  *
- * In addition, 4 rules are defined which govern the semantics of 
+ * In addition, 4 rules are defined which govern the semantics of
  * versions w.r.t retrieves, appends, replaces and deletes.
  *
  *-------------------------------------------------------------------------
index fb1c116bc476ec486107f30ab734441af634ab24..0e3cb83aa934a8199812ff419c5493f590fb1b41 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.46 1999/04/25 19:27:43 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.47 1999/05/25 16:08:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
  *   relname to a list of outstanding NOTIFY requests.  Actual processing
  *   happens if and only if we reach transaction commit.  At that time (in
  *   routine AtCommit_Notify) we scan pg_listener for matching relnames.
- *    If the listenerPID in a matching tuple is ours, we just send a notify
+ *   If the listenerPID in a matching tuple is ours, we just send a notify
  *   message to our own front end.  If it is not ours, and "notification"
  *   is not already nonzero, we set notification to our own PID and send a
  *   SIGUSR2 signal to the receiving process (indicated by listenerPID).
  *   BTW: if the signal operation fails, we presume that the listener backend
- *    crashed without removing this tuple, and remove the tuple for it.
+ *   crashed without removing this tuple, and remove the tuple for it.
  *
  * 4. Upon receipt of a SIGUSR2 signal, the signal handler can call inbound-
  *   notify processing immediately if this backend is idle (ie, it is
  *   waiting for a frontend command and is not within a transaction block).
- *    Otherwise the handler may only set a flag, which will cause the
+ *   Otherwise the handler may only set a flag, which will cause the
  *   processing to occur just before we next go idle.
  *
  * 5. Inbound-notify processing consists of scanning pg_listener for tuples
@@ -53,7 +53,7 @@
  *
  * Note that the system's use of pg_listener is confined to very short
  * intervals at the end of a transaction that contains NOTIFY statements,
- * or during the transaction caused by an inbound SIGUSR2.  So the fact that
+ * or during the transaction caused by an inbound SIGUSR2. So the fact that
  * pg_listener is a global resource shouldn't cause too much performance
  * problem.  But application authors ought to be discouraged from doing
  * LISTEN or UNLISTEN near the start of a long transaction --- that would
@@ -109,8 +109,8 @@ extern CommandDest whereToSendOutput;
 
 /*
  * State for outbound notifies consists of a list of all relnames NOTIFYed
- * in the current transaction.  We do not actually perform a NOTIFY until
- * and unless the transaction commits.  pendingNotifies is NULL if no
+ * in the current transaction. We do not actually perform a NOTIFY until
+ * and unless the transaction commits. pendingNotifies is NULL if no
  * NOTIFYs have been done in the current transaction.
  */
 static Dllist *pendingNotifies = NULL;
@@ -125,8 +125,8 @@ static Dllist *pendingNotifies = NULL;
  * does not grok "volatile", you'd be best advised to compile this file
  * with all optimization turned off.
  */
-static volatile int    notifyInterruptEnabled = 0;
-static volatile int    notifyInterruptOccurred = 0;
+static volatile int notifyInterruptEnabled = 0;
+static volatile int notifyInterruptOccurred = 0;
 
 /* True if we've registered an on_shmem_exit cleanup (or at least tried to). */
 static int unlistenExitRegistered = 0;
@@ -142,7 +142,7 @@ static void ClearPendingNotifies(void);
 
 /*
  *--------------------------------------------------------------
- * Async_Notify 
+ * Async_Notify
  *
  *     This is executed by the SQL notify command.
  *
@@ -164,28 +164,29 @@ Async_Notify(char *relname)
 
    /*
     * We allocate list memory from the global malloc pool to ensure that
-    * it will live until we want to use it.  This is probably not necessary
-    * any longer, since we will use it before the end of the transaction.
-    * DLList only knows how to use malloc() anyway, but we could probably
-    * palloc() the strings...
+    * it will live until we want to use it.  This is probably not
+    * necessary any longer, since we will use it before the end of the
+    * transaction. DLList only knows how to use malloc() anyway, but we
+    * could probably palloc() the strings...
     */
    if (!pendingNotifies)
        pendingNotifies = DLNewList();
    notifyName = strdup(relname);
    DLAddHead(pendingNotifies, DLNewElem(notifyName));
+
    /*
     * NOTE: we could check to see if pendingNotifies already has an entry
-    * for relname, and thus avoid making duplicate entries.  However, most
-    * apps probably don't notify the same name multiple times per transaction,
-    * so we'd likely just be wasting cycles to make such a check.
-    * AsyncExistsPendingNotify() doesn't really care whether the list
-    * contains duplicates...
+    * for relname, and thus avoid making duplicate entries.  However,
+    * most apps probably don't notify the same name multiple times per
+    * transaction, so we'd likely just be wasting cycles to make such a
+    * check. AsyncExistsPendingNotify() doesn't really care whether the
+    * list contains duplicates...
     */
 }
 
 /*
  *--------------------------------------------------------------
- * Async_Listen 
+ * Async_Listen
  *
  *     This is executed by the SQL listen command.
  *
@@ -274,7 +275,7 @@ Async_Listen(char *relname, int pid)
    /*
     * now that we are listening, make sure we will unlisten before dying.
     */
-   if (! unlistenExitRegistered)
+   if (!unlistenExitRegistered)
    {
        if (on_shmem_exit(Async_UnlistenOnExit, (caddr_t) NULL) < 0)
            elog(NOTICE, "Async_Listen: out of shmem_exit slots");
@@ -284,7 +285,7 @@ Async_Listen(char *relname, int pid)
 
 /*
  *--------------------------------------------------------------
- * Async_Unlisten 
+ * Async_Unlisten
  *
  *     This is executed by the SQL unlisten command.
  *
@@ -326,14 +327,16 @@ Async_Unlisten(char *relname, int pid)
        UnlockRelation(lRel, AccessExclusiveLock);
        heap_close(lRel);
    }
-   /* We do not complain about unlistening something not being listened;
+
+   /*
+    * We do not complain about unlistening something not being listened;
     * should we?
     */
 }
 
 /*
  *--------------------------------------------------------------
- * Async_UnlistenAll 
+ * Async_UnlistenAll
  *
  *     Unlisten all relations for this backend.
  *
@@ -379,7 +382,7 @@ Async_UnlistenAll()
 
 /*
  *--------------------------------------------------------------
- * Async_UnlistenOnExit 
+ * Async_UnlistenOnExit
  *
  *     Clean up the pg_listener table at backend exit.
  *
@@ -398,11 +401,12 @@ Async_UnlistenAll()
 static void
 Async_UnlistenOnExit()
 {
+
    /*
-    * We need to start/commit a transaction for the unlisten,
-    * but if there is already an active transaction we had better
-    * abort that one first.  Otherwise we'd end up committing changes
-    * that probably ought to be discarded.
+    * We need to start/commit a transaction for the unlisten, but if
+    * there is already an active transaction we had better abort that one
+    * first.  Otherwise we'd end up committing changes that probably
+    * ought to be discarded.
     */
    AbortOutOfAnyTransaction();
    /* Now we can do the unlisten */
@@ -413,7 +417,7 @@ Async_UnlistenOnExit()
 
 /*
  *--------------------------------------------------------------
- * AtCommit_Notify 
+ * AtCommit_Notify
  *
  *     This is called at transaction commit.
  *
@@ -450,12 +454,14 @@ AtCommit_Notify()
    int32       listenerPID;
 
    if (!pendingNotifies)
-       return;                 /* no NOTIFY statements in this transaction */
+       return;                 /* no NOTIFY statements in this
+                                * transaction */
 
-   /* NOTIFY is disabled if not normal processing mode.
-    * This test used to be in xact.c, but it seems cleaner to do it here.
+   /*
+    * NOTIFY is disabled if not normal processing mode. This test used to
+    * be in xact.c, but it seems cleaner to do it here.
     */
-   if (! IsNormalProcessingMode())
+   if (!IsNormalProcessingMode())
    {
        ClearPendingNotifies();
        return;
@@ -487,10 +493,13 @@ AtCommit_Notify()
 
            if (listenerPID == MyProcPid)
            {
-               /* Self-notify: no need to bother with table update.
+
+               /*
+                * Self-notify: no need to bother with table update.
                 * Indeed, we *must not* clear the notification field in
-                * this path, or we could lose an outside notify, which'd be
-                * bad for applications that ignore self-notify messages.
+                * this path, or we could lose an outside notify, which'd
+                * be bad for applications that ignore self-notify
+                * messages.
                 */
                TPRINTF(TRACE_NOTIFY, "AtCommit_Notify: notifying self");
                NotifyMyFrontEnd(relname, listenerPID);
@@ -499,23 +508,27 @@ AtCommit_Notify()
            {
                TPRINTF(TRACE_NOTIFY, "AtCommit_Notify: notifying pid %d",
                        listenerPID);
+
                /*
-                * If someone has already notified this listener,
-                * we don't bother modifying the table, but we do still send
-                * SIGUSR2 signal, just in case that backend missed the
-                * earlier signal for some reason.  It's OK to send the signal
-                * first, because the other guy can't read pg_listener until
-                * we unlock it.
+                * If someone has already notified this listener, we don't
+                * bother modifying the table, but we do still send a
+                * SIGUSR2 signal, just in case that backend missed the
+                * earlier signal for some reason.  It's OK to send the
+                * signal first, because the other guy can't read
+                * pg_listener until we unlock it.
                 */
 #ifdef HAVE_KILL
                if (kill(listenerPID, SIGUSR2) < 0)
                {
-                   /* Get rid of pg_listener entry if it refers to a PID
+
+                   /*
+                    * Get rid of pg_listener entry if it refers to a PID
                     * that no longer exists.  Presumably, that backend
                     * crashed without deleting its pg_listener entries.
-                    * This code used to only delete the entry if errno==ESRCH,
-                    * but as far as I can see we should just do it for any
-                    * failure (certainly at least for EPERM too...)
+                    * This code used to only delete the entry if
+                    * errno==ESRCH, but as far as I can see we should
+                    * just do it for any failure (certainly at least for
+                    * EPERM too...)
                     */
                    heap_delete(lRel, &lTuple->t_self, NULL);
                }
@@ -536,6 +549,7 @@ AtCommit_Notify()
    }
 
    heap_endscan(sRel);
+
    /*
     * We do not do RelationUnsetLockForWrite(lRel) here, because the
     * transaction is about to be committed anyway.
@@ -549,7 +563,7 @@ AtCommit_Notify()
 
 /*
  *--------------------------------------------------------------
- * AtAbort_Notify 
+ * AtAbort_Notify
  *
  *     This is called at transaction abort.
  *
@@ -569,7 +583,7 @@ AtAbort_Notify()
 
 /*
  *--------------------------------------------------------------
- * Async_NotifyHandler 
+ * Async_NotifyHandler
  *
  *     This is the signal handler for SIGUSR2.
  *
@@ -588,25 +602,30 @@ AtAbort_Notify()
 void
 Async_NotifyHandler(SIGNAL_ARGS)
 {
+
    /*
-    * Note: this is a SIGNAL HANDLER.  You must be very wary what you do here.
-    * Some helpful soul had this routine sprinkled with TPRINTFs, which would
-    * likely lead to corruption of stdio buffers if they were ever turned on.
+    * Note: this is a SIGNAL HANDLER.  You must be very wary what you do
+    * here. Some helpful soul had this routine sprinkled with TPRINTFs,
+    * which would likely lead to corruption of stdio buffers if they were
+    * ever turned on.
     */
 
    if (notifyInterruptEnabled)
    {
-       /* I'm not sure whether some flavors of Unix might allow another
-        * SIGUSR2 occurrence to recursively interrupt this routine.
-        * To cope with the possibility, we do the same sort of dance that
-        * EnableNotifyInterrupt must do --- see that routine for comments.
+
+       /*
+        * I'm not sure whether some flavors of Unix might allow another
+        * SIGUSR2 occurrence to recursively interrupt this routine. To
+        * cope with the possibility, we do the same sort of dance that
+        * EnableNotifyInterrupt must do --- see that routine for
+        * comments.
         */
        notifyInterruptEnabled = 0;     /* disable any recursive signal */
        notifyInterruptOccurred = 1;    /* do at least one iteration */
        for (;;)
        {
            notifyInterruptEnabled = 1;
-           if (! notifyInterruptOccurred)
+           if (!notifyInterruptOccurred)
                break;
            notifyInterruptEnabled = 0;
            if (notifyInterruptOccurred)
@@ -621,14 +640,18 @@ Async_NotifyHandler(SIGNAL_ARGS)
    }
    else
    {
-       /* In this path it is NOT SAFE to do much of anything, except this: */
+
+       /*
+        * In this path it is NOT SAFE to do much of anything, except
+        * this:
+        */
        notifyInterruptOccurred = 1;
    }
 }
 
 /*
  * --------------------------------------------------------------
- * EnableNotifyInterrupt 
+ * EnableNotifyInterrupt
  *
  *     This is called by the PostgresMain main loop just before waiting
  *     for a frontend command.  If we are truly idle (ie, *not* inside
@@ -652,26 +675,27 @@ EnableNotifyInterrupt(void)
     * notifyInterruptOccurred and then set notifyInterruptEnabled, we
     * could fail to respond promptly to a signal that happens in between
     * those two steps.  (A very small time window, perhaps, but Murphy's
-    * Law says you can hit it...)  Instead, we first set the enable flag,
-    * then test the occurred flag.  If we see an unserviced interrupt
-    * has occurred, we re-clear the enable flag before going off to do
-    * the service work.  (That prevents re-entrant invocation of
-    * ProcessIncomingNotify() if another interrupt occurs.)
-    * If an interrupt comes in between the setting and clearing of
-    * notifyInterruptEnabled, then it will have done the service
-    * work and left notifyInterruptOccurred zero, so we have to check
-    * again after clearing enable.  The whole thing has to be in a loop
-    * in case another interrupt occurs while we're servicing the first.
-    * Once we get out of the loop, enable is set and we know there is no
+    * Law says you can hit it...)  Instead, we first set the enable flag,
+    * then test the occurred flag.  If we see an unserviced interrupt has
+    * occurred, we re-clear the enable flag before going off to do the
+    * service work.  (That prevents re-entrant invocation of
+    * ProcessIncomingNotify() if another interrupt occurs.) If an
+    * interrupt comes in between the setting and clearing of
+    * notifyInterruptEnabled, then it will have done the service work and
+    * left notifyInterruptOccurred zero, so we have to check again after
+    * clearing enable.  The whole thing has to be in a loop in case
+    * another interrupt occurs while we're servicing the first. Once we
+    * get out of the loop, enable is set and we know there is no
     * unserviced interrupt.
     *
     * NB: an overenthusiastic optimizing compiler could easily break this
-    * code.  Hopefully, they all understand what "volatile" means these days.
+    * code.  Hopefully, they all understand what "volatile" means these
+    * days.
     */
    for (;;)
    {
        notifyInterruptEnabled = 1;
-       if (! notifyInterruptOccurred)
+       if (!notifyInterruptOccurred)
            break;
        notifyInterruptEnabled = 0;
        if (notifyInterruptOccurred)
@@ -686,7 +710,7 @@ EnableNotifyInterrupt(void)
 
 /*
  * --------------------------------------------------------------
- * DisableNotifyInterrupt 
+ * DisableNotifyInterrupt
  *
  *     This is called by the PostgresMain main loop just after receiving
  *     a frontend command.  Signal handler execution of inbound notifies
@@ -702,7 +726,7 @@ DisableNotifyInterrupt(void)
 
 /*
  * --------------------------------------------------------------
- * ProcessIncomingNotify 
+ * ProcessIncomingNotify
  *
  *     Deal with arriving NOTIFYs from other backends.
  *     This is called either directly from the SIGUSR2 signal handler,
@@ -777,6 +801,7 @@ ProcessIncomingNotify(void)
        }
    }
    heap_endscan(sRel);
+
    /*
     * We do not do RelationUnsetLockForWrite(lRel) here, because the
     * transaction is about to be committed anyway.
@@ -785,7 +810,10 @@ ProcessIncomingNotify(void)
 
    CommitTransactionCommand();
 
-   /* Must flush the notify messages to ensure frontend gets them promptly. */
+   /*
+    * Must flush the notify messages to ensure frontend gets them
+    * promptly.
+    */
    pq_flush();
 
    PS_SET_STATUS("idle");
@@ -800,20 +828,22 @@ NotifyMyFrontEnd(char *relname, int32 listenerPID)
    if (whereToSendOutput == Remote)
    {
        StringInfoData buf;
+
        pq_beginmessage(&buf);
        pq_sendbyte(&buf, 'A');
        pq_sendint(&buf, listenerPID, sizeof(int32));
        pq_sendstring(&buf, relname);
        pq_endmessage(&buf);
-       /* NOTE: we do not do pq_flush() here.  For a self-notify, it will
+
+       /*
+        * NOTE: we do not do pq_flush() here.  For a self-notify, it will
         * happen at the end of the transaction, and for incoming notifies
-        * ProcessIncomingNotify will do it after finding all the notifies.
+        * ProcessIncomingNotify will do it after finding all the
+        * notifies.
         */
    }
    else
-   {
        elog(NOTICE, "NOTIFY for %s", relname);
-   }
 }
 
 /* Does pendingNotifies include the given relname?
@@ -847,10 +877,12 @@ ClearPendingNotifies()
 
    if (pendingNotifies)
    {
-       /* Since the referenced strings are malloc'd, we have to scan the
+
+       /*
+        * Since the referenced strings are malloc'd, we have to scan the
         * list and delete them individually.  If we used palloc for the
-        * strings then we could just do DLFreeList to get rid of both
-        * the list nodes and the list base...
+        * strings then we could just do DLFreeList to get rid of both the
+        * list nodes and the list base...
         */
        while ((p = DLRemHead(pendingNotifies)) != NULL)
        {
index ae6cafa7b7c51c33ebdd5fe36158b89bf37e2eb6..29fb0d9a490c40149c9fd6f4bc872d9c5611da3a 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.38 1999/02/13 23:15:02 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.39 1999/05/25 16:08:16 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -236,17 +236,17 @@ copy_heap(Oid OIDOldHeap)
 static void
 copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
 {
-   Relation            OldIndex,
-                               NewHeap;
-   HeapTuple           Old_pg_index_Tuple,
-                               Old_pg_index_relation_Tuple,
-                               pg_proc_Tuple;
+   Relation    OldIndex,
+               NewHeap;
+   HeapTuple   Old_pg_index_Tuple,
+               Old_pg_index_relation_Tuple,
+               pg_proc_Tuple;
    Form_pg_index Old_pg_index_Form;
    Form_pg_class Old_pg_index_relation_Form;
-   Form_pg_proc    pg_proc_Form;
-   char                    *NewIndexName;
-   AttrNumber      *attnumP;
-   int                     natts;
+   Form_pg_proc pg_proc_Form;
+   char       *NewIndexName;
+   AttrNumber *attnumP;
+   int         natts;
    FuncIndexInfo *finfo;
 
    NewHeap = heap_open(OIDNewHeap);
@@ -259,14 +259,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
     */
    Old_pg_index_Tuple = SearchSysCacheTuple(INDEXRELID,
                            ObjectIdGetDatum(RelationGetRelid(OldIndex)),
-                           0, 0, 0);
+                                            0, 0, 0);
 
    Assert(Old_pg_index_Tuple);
    Old_pg_index_Form = (Form_pg_index) GETSTRUCT(Old_pg_index_Tuple);
 
    Old_pg_index_relation_Tuple = SearchSysCacheTuple(RELOID,
                            ObjectIdGetDatum(RelationGetRelid(OldIndex)),
-                           0, 0, 0);
+                                                     0, 0, 0);
 
    Assert(Old_pg_index_relation_Tuple);
    Old_pg_index_relation_Form = (Form_pg_class) GETSTRUCT(Old_pg_index_relation_Tuple);
@@ -296,7 +296,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
 
        pg_proc_Tuple = SearchSysCacheTuple(PROOID,
                            ObjectIdGetDatum(Old_pg_index_Form->indproc),
-                               0, 0, 0);
+                                           0, 0, 0);
 
        Assert(pg_proc_Tuple);
        pg_proc_Form = (Form_pg_proc) GETSTRUCT(pg_proc_Tuple);
@@ -319,7 +319,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
                 (uint16) 0, (Datum) NULL, NULL,
                 Old_pg_index_Form->indislossy,
                 Old_pg_index_Form->indisunique,
-                 Old_pg_index_Form->indisprimary);
+                Old_pg_index_Form->indisprimary);
 
    heap_close(OldIndex);
    heap_close(NewHeap);
@@ -329,14 +329,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
 static void
 rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
 {
-   Relation            LocalNewHeap,
-                       LocalOldHeap,
-                       LocalOldIndex;
-   IndexScanDesc       ScanDesc;
-   RetrieveIndexResult ScanResult;
-   HeapTupleData       LocalHeapTuple;
-   Buffer              LocalBuffer;
-   Oid                 OIDNewHeapInsert;
+   Relation    LocalNewHeap,
+               LocalOldHeap,
+               LocalOldIndex;
+   IndexScanDesc ScanDesc;
+   RetrieveIndexResult ScanResult;
+   HeapTupleData LocalHeapTuple;
+   Buffer      LocalBuffer;
+   Oid         OIDNewHeapInsert;
 
    /*
     * Open the relations I need. Scan through the OldHeap on the OldIndex
index 7d8f72d51f94575a8f5bc1c03c57311358c15f80..f4c0f2115a70c248ada56f470b57a3ee1b336e0f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.44 1999/05/10 00:44:56 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.45 1999/05/25 16:08:17 momjian Exp $
  *
  * NOTES
  *   The PortalExecutorHeapMemory crap needs to be eliminated
@@ -117,18 +117,18 @@ PerformPortalFetch(char *name,
    }
 
    /* ----------------
-    *  Create a const node from the given count value
+    *  Create a const node from the given count value
     * ----------------
     */
    memset(&limcount, 0, sizeof(limcount));
-   limcount.type       = T_Const;
-   limcount.consttype  = INT4OID;
-   limcount.constlen   = sizeof(int4);
-   limcount.constvalue = (Datum)count;
-   limcount.constisnull    = FALSE;
+   limcount.type = T_Const;
+   limcount.consttype = INT4OID;
+   limcount.constlen = sizeof(int4);
+   limcount.constvalue = (Datum) count;
+   limcount.constisnull = FALSE;
    limcount.constbyval = TRUE;
    limcount.constisset = FALSE;
-   limcount.constiscast    = FALSE;
+   limcount.constiscast = FALSE;
 
 
    /* ----------------
@@ -193,8 +193,8 @@ PerformPortalFetch(char *name,
     */
    PortalExecutorHeapMemory = (MemoryContext) PortalGetHeapMemory(portal);
 
-   ExecutorRun(queryDesc, PortalGetState(portal), feature, 
-               (Node *)NULL, (Node *)&limcount);
+   ExecutorRun(queryDesc, PortalGetState(portal), feature,
+               (Node *) NULL, (Node *) &limcount);
 
    if (dest == None)           /* MOVE */
        pfree(queryDesc);
@@ -211,7 +211,7 @@ PerformPortalFetch(char *name,
     * ----------------
     */
    MemoryContextSwitchTo(
-               (MemoryContext) PortalGetHeapMemory(GetPortalByName(NULL)));
+            (MemoryContext) PortalGetHeapMemory(GetPortalByName(NULL)));
 }
 
 /* --------------------------------
@@ -503,7 +503,7 @@ PerformAddAttribute(char *relationName,
    heap_replace(rel, &reltup->t_self, reltup, NULL);
 
    {
-       HeapTuple temptup;
+       HeapTuple   temptup;
 
        if ((temptup = get_temp_rel_by_name(relationName)) != NULL)
            ((Form_pg_class) GETSTRUCT(temptup))->relnatts = maxatts;
@@ -519,7 +519,7 @@ PerformAddAttribute(char *relationName,
 }
 
 void
-LockTableCommand(LockStmt *lockstmt)
+LockTableCommand(LockStmt * lockstmt)
 {
    Relation    rel;
    int         aclresult;
index 9347c6d67dda07abde0252a52a614eccc5f5df29..d2b98ec4bc19616ea4bfd8eadb4d96556619caaa 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.76 1999/05/10 00:44:58 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.77 1999/05/25 16:08:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,111 +70,138 @@ static int    CountTuples(Relation relation);
 
 static int lineno;
 
-/* 
+/*
  * Internal communications functions
  */
 inline void CopySendData(void *databuf, int datasize, FILE *fp);
 inline void CopySendString(char *str, FILE *fp);
 inline void CopySendChar(char c, FILE *fp);
 inline void CopyGetData(void *databuf, int datasize, FILE *fp);
-inline int CopyGetChar(FILE *fp);
-inline int CopyGetEof(FILE *fp);
-inline int CopyPeekChar(FILE *fp);
+inline int CopyGetChar(FILE *fp);
+inline int CopyGetEof(FILE *fp);
+inline int CopyPeekChar(FILE *fp);
 inline void CopyDonePeek(FILE *fp, int c, int pickup);
 
 /*
  * CopySendData sends output data either to the file
- *  specified by fp or, if fp is NULL, using the standard
- *  backend->frontend functions
+ * specified by fp or, if fp is NULL, using the standard
+ * backend->frontend functions
  *
  * CopySendString does the same for null-terminated strings
  * CopySendChar does the same for single characters
  *
  * NB: no data conversion is applied by these functions
  */
-inline void CopySendData(void *databuf, int datasize, FILE *fp) {
-  if (!fp)
-     pq_putbytes((char*) databuf, datasize);
-  else
-     fwrite(databuf, datasize, 1, fp);
+inline void
+CopySendData(void *databuf, int datasize, FILE *fp)
+{
+   if (!fp)
+       pq_putbytes((char *) databuf, datasize);
+   else
+       fwrite(databuf, datasize, 1, fp);
 }
-    
-inline void CopySendString(char *str, FILE *fp) {
-  CopySendData(str,strlen(str),fp);
+
+inline void
+CopySendString(char *str, FILE *fp)
+{
+   CopySendData(str, strlen(str), fp);
 }
 
-inline void CopySendChar(char c, FILE *fp) {
-  CopySendData(&c,1,fp);
+inline void
+CopySendChar(char c, FILE *fp)
+{
+   CopySendData(&c, 1, fp);
 }
 
 /*
  * CopyGetData reads output data either from the file
- *  specified by fp or, if fp is NULL, using the standard
- *  backend->frontend functions
+ * specified by fp or, if fp is NULL, using the standard
+ * backend->frontend functions
  *
  * CopyGetChar does the same for single characters
  * CopyGetEof checks if it's EOF on the input
  *
  * NB: no data conversion is applied by these functions
  */
-inline void CopyGetData(void *databuf, int datasize, FILE *fp) {
-  if (!fp)
-    pq_getbytes((char*) databuf, datasize); 
-  else 
-    fread(databuf, datasize, 1, fp);
+inline void
+CopyGetData(void *databuf, int datasize, FILE *fp)
+{
+   if (!fp)
+       pq_getbytes((char *) databuf, datasize);
+   else
+       fread(databuf, datasize, 1, fp);
 }
 
-inline int CopyGetChar(FILE *fp) {
-  if (!fp) 
-  {
-     unsigned char ch;
-     if (pq_getbytes((char*) &ch, 1))
-         return EOF;
-     return ch;
-  }
-  else
-    return getc(fp);
+inline int
+CopyGetChar(FILE *fp)
+{
+   if (!fp)
+   {
+       unsigned char ch;
+
+       if (pq_getbytes((char *) &ch, 1))
+           return EOF;
+       return ch;
+   }
+   else
+       return getc(fp);
 }
 
-inline int CopyGetEof(FILE *fp) {
-  if (!fp)
-    return 0; /* Never return EOF when talking to frontend ? */
-  else
-    return feof(fp);
+inline int
+CopyGetEof(FILE *fp)
+{
+   if (!fp)
+       return 0;               /* Never return EOF when talking to
+                                * frontend ? */
+   else
+       return feof(fp);
 }
 
 /*
  * CopyPeekChar reads a byte in "peekable" mode.
  * after each call to CopyPeekChar, a call to CopyDonePeek _must_
  * follow.
- * CopyDonePeek will either take the peeked char off the steam 
+ * CopyDonePeek will either take the peeked char off the steam
  * (if pickup is != 0) or leave it on the stream (if pickup == 0)
  */
-inline int CopyPeekChar(FILE *fp) {
-  if (!fp) 
-    return pq_peekbyte();
-  else
-    return getc(fp);
+inline int
+CopyPeekChar(FILE *fp)
+{
+   if (!fp)
+       return pq_peekbyte();
+   else
+       return getc(fp);
 }
 
-inline void CopyDonePeek(FILE *fp, int c, int pickup) {
-  if (!fp) {
-    if (pickup) {
-      /* We want to pick it up - just receive again into dummy buffer */
-      char c;
-      pq_getbytes(&c, 1);
-    }
-    /* If we didn't want to pick it up, just leave it where it sits */
-  }
-  else {
-    if (!pickup) {
-      /* We don't want to pick it up - so put it back in there */
-      ungetc(c,fp);
-    }
-    /* If we wanted to pick it up, it's already there */
-  }
+inline void
+CopyDonePeek(FILE *fp, int c, int pickup)
+{
+   if (!fp)
+   {
+       if (pickup)
+       {
+
+           /*
+            * We want to pick it up - just receive again into dummy
+            * buffer
+            */
+           char        c;
+
+           pq_getbytes(&c, 1);
+       }
+       /* If we didn't want to pick it up, just leave it where it sits */
+   }
+   else
+   {
+       if (!pickup)
+       {
+           /* We don't want to pick it up - so put it back in there */
+           ungetc(c, fp);
+       }
+       /* If we wanted to pick it up, it's already there */
+   }
 }
-    
+
 
 
 /*
@@ -317,7 +344,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
        else if (!from)
        {
            if (!binary)
-               CopySendData("\\.\n",3,fp);
+               CopySendData("\\.\n", 3, fp);
            if (IsUnderPostmaster)
                pq_endcopyout(false);
        }
@@ -395,8 +422,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 
        if (oids && !binary)
        {
-               CopySendString(oidout(tuple->t_data->t_oid),fp);
-           CopySendChar(delim[0],fp);
+           CopySendString(oidout(tuple->t_data->t_oid), fp);
+           CopySendChar(delim[0], fp);
        }
 
        for (i = 0; i < attr_count; i++)
@@ -466,8 +493,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
                    }
                }
            }
-           CopySendData((char *) tuple->t_data + tuple->t_data->t_hoff, 
-                   length, fp);
+           CopySendData((char *) tuple->t_data + tuple->t_data->t_hoff,
+                        length, fp);
        }
    }
 
@@ -521,7 +548,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
    Node      **indexPred = NULL;
    TupleDesc   rtupdesc;
    ExprContext *econtext = NULL;
-   EState      *estate = makeNode(EState); /* for ExecConstraints() */
+   EState     *estate = makeNode(EState);      /* for ExecConstraints() */
 
 #ifndef OMIT_PARTIAL_INDEX
    TupleTable  tupleTable;
@@ -566,11 +593,11 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
                itupdescArr[i] = RelationGetDescr(index_rels[i]);
                pgIndexTup = SearchSysCacheTuple(INDEXRELID,
                       ObjectIdGetDatum(RelationGetRelid(index_rels[i])),
-                                       0, 0, 0);
+                                                0, 0, 0);
                Assert(pgIndexTup);
                pgIndexP[i] = (Form_pg_index) GETSTRUCT(pgIndexTup);
                for (attnumP = &(pgIndexP[i]->indkey[0]), natts = 0;
-                    natts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber;
+                natts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber;
                     attnumP++, natts++);
                if (pgIndexP[i]->indproc != InvalidOid)
                {
@@ -777,7 +804,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
                    }
                    else if (nulls[i] != 'n')
                    {
-                       ptr = (char *)att_align(ptr, attr[i]->attlen, attr[i]->attalign);
+                       ptr = (char *) att_align(ptr, attr[i]->attlen, attr[i]->attalign);
                        values[i] = (Datum) ptr;
                        ptr = att_addlength(ptr, attr[i]->attlen, ptr);
                    }
@@ -888,7 +915,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
    pfree(index_nulls);
    pfree(idatum);
    pfree(byval);
-   
+
    if (!binary)
    {
        pfree(in_functions);
@@ -903,7 +930,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
        {
            if (index_rels[i] == NULL)
                continue;
-           if ((index_rels[i])->rd_rel->relam != BTREE_AM_OID && 
+           if ((index_rels[i])->rd_rel->relam != BTREE_AM_OID &&
                (index_rels[i])->rd_rel->relam != HASH_AM_OID)
                UnlockRelation(index_rels[i], AccessExclusiveLock);
            index_close(index_rels[i]);
@@ -1022,12 +1049,12 @@ GetIndexRelations(Oid main_relation_oid,
    {
 
        index_relation_oid = (Oid) DatumGetInt32(heap_getattr(tuple, 2,
-                                            tupDesc, &isnull));
+                                                     tupDesc, &isnull));
        if (index_relation_oid == main_relation_oid)
        {
            scan->index_rel_oid = (Oid) DatumGetInt32(heap_getattr(tuple,
-                                                Anum_pg_index_indexrelid,
-                                                tupDesc, &isnull));
+                                               Anum_pg_index_indexrelid,
+                                                     tupDesc, &isnull));
            (*n_indices)++;
            scan->next = (RelationList *) palloc(sizeof(RelationList));
            scan = scan->next;
@@ -1047,7 +1074,7 @@ GetIndexRelations(Oid main_relation_oid,
    {
        (*index_rels)[i] = index_open(scan->index_rel_oid);
        /* comments in execUtils.c */
-       if ((*index_rels)[i] != NULL && 
+       if ((*index_rels)[i] != NULL &&
            ((*index_rels)[i])->rd_rel->relam != BTREE_AM_OID &&
            ((*index_rels)[i])->rd_rel->relam != HASH_AM_OID)
            LockRelation((*index_rels)[i], AccessExclusiveLock);
@@ -1176,26 +1203,29 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
                        if (ISOCTAL(c))
                        {
                            val = (val << 3) + VALUE(c);
-                           CopyDonePeek(fp, c, 1); /* Pick up the character! */
+                           CopyDonePeek(fp, c, 1);     /* Pick up the
+                                                        * character! */
                            c = CopyPeekChar(fp);
-                           if (ISOCTAL(c)) {
-                                   CopyDonePeek(fp,c,1); /* pick up! */
+                           if (ISOCTAL(c))
+                           {
+                               CopyDonePeek(fp, c, 1); /* pick up! */
                                val = (val << 3) + VALUE(c);
                            }
                            else
                            {
-                                   if (CopyGetEof(fp)) {
-                                       CopyDonePeek(fp,c,1); /* pick up */
+                               if (CopyGetEof(fp))
+                               {
+                                   CopyDonePeek(fp, c, 1);     /* pick up */
                                    return NULL;
                                }
-                               CopyDonePeek(fp,c,0); /* Return to stream! */
+                               CopyDonePeek(fp, c, 0); /* Return to stream! */
                            }
                        }
                        else
                        {
                            if (CopyGetEof(fp))
                                return NULL;
-                           CopyDonePeek(fp,c,0); /* Return to stream! */
+                           CopyDonePeek(fp, c, 0);     /* Return to stream! */
                        }
                        c = val & 0377;
                    }
index 0d4c3fc8b8721f5bd73b61bff67e8053b651a4b8..e9c5fdcd8940efc05fb515cc84b44d9338b79b24 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.40 1999/02/13 23:15:05 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.41 1999/05/25 16:08:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -39,7 +39,7 @@ static List *MergeAttributes(List *schema, List *supers, List **supconstr);
 static void StoreCatalogInheritance(Oid relationId, List *supers);
 
 /* ----------------------------------------------------------------
- *     DefineRelation 
+ *     DefineRelation
  *             Creates a new relation.
  * ----------------------------------------------------------------
  */
@@ -90,10 +90,10 @@ DefineRelation(CreateStmt *stmt, char relkind)
 
    if (constraints != NIL)
    {
-       List                *entry;
-       int                 nconstr = length(constraints),
-                               ncheck = 0,
-                               i;
+       List       *entry;
+       int         nconstr = length(constraints),
+                   ncheck = 0,
+                   i;
        ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck));
 
        foreach(entry, constraints)
@@ -107,9 +107,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
                    for (i = 0; i < ncheck; i++)
                    {
                        if (strcmp(check[i].ccname, cdef->name) == 0)
-                           elog(ERROR, 
-                               "DefineRelation: name (%s) of CHECK constraint duplicated", 
-                               cdef->name);
+                           elog(ERROR,
+                                "DefineRelation: name (%s) of CHECK constraint duplicated",
+                                cdef->name);
                    }
                    check[ncheck].ccname = cdef->name;
                }
@@ -145,7 +145,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
 }
 
 /*
- * RemoveRelation 
+ * RemoveRelation
  *     Deletes a new relation.
  *
  * Exceptions:
@@ -164,7 +164,7 @@ RemoveRelation(char *name)
 
 
 /*
- * MergeAttributes 
+ * MergeAttributes
  *     Returns new schema given initial schema and supers.
  *
  *
@@ -276,8 +276,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
             */
            attributeName = (attribute->attname).data;
            tuple = SearchSysCacheTuple(TYPOID,
-                                   ObjectIdGetDatum(attribute->atttypid),
-                                   0, 0, 0);
+                                  ObjectIdGetDatum(attribute->atttypid),
+                                       0, 0, 0);
            Assert(HeapTupleIsValid(tuple));
            attributeType = (((Form_pg_type) GETSTRUCT(tuple))->typname).data;
 
@@ -365,7 +365,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
 }
 
 /*
- * StoreCatalogInheritance 
+ * StoreCatalogInheritance
  *     Updates the system catalogs with proper inheritance information.
  */
 static void
@@ -411,9 +411,9 @@ StoreCatalogInheritance(Oid relationId, List *supers)
         */
        idList = lappendi(idList, tuple->t_data->t_oid);
 
-       datum[0] = ObjectIdGetDatum(relationId);            /* inhrel */
-       datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid);  /* inhparent */
-       datum[2] = Int16GetDatum(seqNumber);                /* inhseqno */
+       datum[0] = ObjectIdGetDatum(relationId);        /* inhrel */
+       datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid);      /* inhparent */
+       datum[2] = Int16GetDatum(seqNumber);    /* inhseqno */
 
        nullarr[0] = ' ';
        nullarr[1] = ' ';
@@ -467,8 +467,8 @@ StoreCatalogInheritance(Oid relationId, List *supers)
                break;
 
            lnext(current) = lconsi(((Form_pg_inherits)
-                       GETSTRUCT(tuple))->inhparent,
-                      NIL);
+                                    GETSTRUCT(tuple))->inhparent,
+                                   NIL);
 
            current = lnext(current);
        }
index 943d7acb432a3b2f87f59fb9e89765d835392548..06f0a8115a52a38e1642250ee58d313c5a46d8fa 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.34 1999/05/10 00:44:59 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.35 1999/05/25 16:08:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,8 +47,8 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
    Oid         db_id;
    int4        user_id;
    char        buf[512];
-   char        *lp,
-                   loc[512];
+   char       *lp,
+               loc[512];
 
    /*
     * If this call returns, the database does not exist and we're allowed
@@ -80,13 +80,13 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
        elog(ERROR, "Unable to create database directory '%s'", lp);
 
    snprintf(buf, 512, "%s %s%cbase%ctemplate1%c* %s",
-           COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
+            COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
    system(buf);
 
-   snprintf(buf, 512, 
-           "insert into pg_database (datname, datdba, encoding, datpath)"
-           " values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
-           loc);
+   snprintf(buf, 512,
+          "insert into pg_database (datname, datdba, encoding, datpath)"
+         " values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
+            loc);
 
    pg_exec_query_dest(buf, dest, false);
 }
@@ -96,9 +96,9 @@ destroydb(char *dbname, CommandDest dest)
 {
    int4        user_id;
    Oid         db_id;
-   char        *path,
-                   dbpath[MAXPGPATH + 1],
-                   buf[512];
+   char       *path,
+               dbpath[MAXPGPATH + 1],
+               buf[512];
 
    /*
     * If this call returns, the database exists and we're allowed to
@@ -122,9 +122,9 @@ destroydb(char *dbname, CommandDest dest)
     * remove the pg_database tuple FIRST, this may fail due to
     * permissions problems
     */
-   snprintf(buf, 512, 
-           "delete from pg_database where pg_database.oid = \'%u\'::oid", db_id);
-   pg_exec_query_dest(buf ,dest, false);
+   snprintf(buf, 512,
+   "delete from pg_database where pg_database.oid = \'%u\'::oid", db_id);
+   pg_exec_query_dest(bufdest, false);
 
    /* drop pages for this database that are in the shared buffer cache */
    DropBuffers(db_id);
@@ -294,13 +294,13 @@ static void
 stop_vacuum(char *dbpath, char *dbname)
 {
    char        filename[256];
-   FILE        *fp;
+   FILE       *fp;
    int         pid;
 
    if (strchr(dbpath, SEP_CHAR) != 0)
    {
-       snprintf(filename, 256, "%s%cbase%c%s%c%s.vacuum", 
-               DataDir, SEP_CHAR, SEP_CHAR, dbname, SEP_CHAR, dbname);
+       snprintf(filename, 256, "%s%cbase%c%s%c%s.vacuum",
+                DataDir, SEP_CHAR, SEP_CHAR, dbname, SEP_CHAR, dbname);
    }
    else
        snprintf(filename, 256, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname);
index 04bd1e89638f45a7f6f81da1fc8445b818c1c8dd..34d322524c7da2f747020aa42b1ef7402f5c25cb 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.28 1999/04/09 22:35:41 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.29 1999/05/25 16:08:22 momjian Exp $
  *
  * DESCRIPTION
  *   The "DefineFoo" routines take the parse tree and pick out the
@@ -203,7 +203,7 @@ interpret_AS_clause(const char *languageName, const char *as,
 
 
 /*
- * CreateFunction 
+ * CreateFunction
  *  Execute a CREATE FUNCTION utility statement.
  *
  */
@@ -574,7 +574,7 @@ DefineAggregate(char *aggName, List *parameters)
 }
 
 /*
- * DefineType 
+ * DefineType
  *     Registers a new type.
  *
  */
index 6a04417964b2139c31e68cc7e3630e6f8054c32e..66fcd8647b05ba821f5bd7f0de0c05a8da7e9817 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (c) 1994-5, Regents of the University of California
  *
- *   $Id: explain.c,v 1.36 1999/05/09 23:31:45 tgl Exp $
+ *   $Id: explain.c,v 1.37 1999/05/25 16:08:23 momjian Exp $
  *
  */
 #include <stdio.h>
@@ -34,7 +34,7 @@ typedef struct ExplainState
 } ExplainState;
 
 static char *Explain_PlanToString(Plan *plan, ExplainState *es);
-static void printLongNotice(const char * header, const char * message);
+static void printLongNotice(const char *header, const char *message);
 static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest);
 
 
@@ -46,8 +46,8 @@ static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest);
 void
 ExplainQuery(Query *query, bool verbose, CommandDest dest)
 {
-   List    *rewritten;
-   List    *l;
+   List       *rewritten;
+   List       *l;
 
    /* rewriter and planner may not work in aborted state? */
    if (IsAbortedTransactionBlockState())
@@ -145,10 +145,10 @@ ExplainOneQuery(Query *query, bool verbose, CommandDest dest)
 static void
 explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
 {
-   List            *l;
+   List       *l;
    Relation    relation;
-   char            *pname;
-   int             i;
+   char       *pname;
+   int         i;
 
    if (plan == NULL)
    {
@@ -208,15 +208,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
        case T_IndexScan:
            appendStringInfo(str, " using ");
            i = 0;
-           foreach (l, ((IndexScan *) plan)->indxid)
+           foreach(l, ((IndexScan *) plan)->indxid)
            {
                relation = RelationIdCacheGetRelation((int) lfirst(l));
                if (++i > 1)
-               {
                    appendStringInfo(str, ", ");
-               }
-               appendStringInfo(str, 
-                   stringStringInfo((RelationGetRelationName(relation))->data));
+               appendStringInfo(str,
+                                stringStringInfo((RelationGetRelationName(relation))->data));
            }
        case T_SeqScan:
            if (((Scan *) plan)->scanrelid > 0)
@@ -227,7 +225,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
                if (strcmp(rte->refname, rte->relname) != 0)
                {
                    appendStringInfo(str, "%s ",
-                       stringStringInfo(rte->relname));
+                                    stringStringInfo(rte->relname));
                }
                appendStringInfo(str, stringStringInfo(rte->refname));
            }
@@ -238,7 +236,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
    if (es->printCost)
    {
        appendStringInfo(str, "  (cost=%.2f rows=%d width=%d)",
-               plan->cost, plan->plan_size, plan->plan_width);
+                        plan->cost, plan->plan_size, plan->plan_width);
    }
    appendStringInfo(str, "\n");
 
@@ -248,18 +246,14 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
        List       *saved_rtable = es->rtable;
        List       *lst;
 
-       for (i = 0; i < indent; i++) 
-       {
+       for (i = 0; i < indent; i++)
            appendStringInfo(str, "  ");
-       }
        appendStringInfo(str, "  InitPlan\n");
        foreach(lst, plan->initPlan)
        {
            es->rtable = ((SubPlan *) lfirst(lst))->rtable;
            for (i = 0; i < indent; i++)
-           {
                appendStringInfo(str, "  ");
-           }
            appendStringInfo(str, "    ->  ");
            explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 2, es);
        }
@@ -270,9 +264,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
    if (outerPlan(plan))
    {
        for (i = 0; i < indent; i++)
-       {
            appendStringInfo(str, "  ");
-       }
        appendStringInfo(str, "  ->  ");
        explain_outNode(str, outerPlan(plan), indent + 3, es);
    }
@@ -281,9 +273,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
    if (innerPlan(plan))
    {
        for (i = 0; i < indent; i++)
-       {
            appendStringInfo(str, "  ");
-       }
        appendStringInfo(str, "  ->  ");
        explain_outNode(str, innerPlan(plan), indent + 3, es);
    }
@@ -295,17 +285,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
        List       *lst;
 
        for (i = 0; i < indent; i++)
-       {
            appendStringInfo(str, "  ");
-       }
        appendStringInfo(str, "  SubPlan\n");
        foreach(lst, plan->subPlan)
        {
            es->rtable = ((SubPlan *) lfirst(lst))->rtable;
            for (i = 0; i < indent; i++)
-           {
                appendStringInfo(str, "  ");
-           }
            appendStringInfo(str, "    ->  ");
            explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 4, es);
        }
@@ -336,9 +322,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
                es->rtable = nth(whichplan, appendplan->unionrtables);
 
            for (i = 0; i < indent; i++)
-           {
                appendStringInfo(str, "  ");
-           }
            appendStringInfo(str, "    ->  ");
 
            explain_outNode(str, subnode, indent + 4, es);
@@ -353,7 +337,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
 static char *
 Explain_PlanToString(Plan *plan, ExplainState *es)
 {
-   StringInfoData  str;
+   StringInfoData str;
 
    /* see stringinfo.h for an explanation of this maneuver */
    initStringInfo(&str);
@@ -367,9 +351,9 @@ Explain_PlanToString(Plan *plan, ExplainState *es)
  * This is a crock ... there shouldn't be an upper limit to what you can elog().
  */
 static void
-printLongNotice(const char * header, const char * message)
+printLongNotice(const char *header, const char *message)
 {
-   int     len = strlen(message);
+   int         len = strlen(message);
 
    elog(NOTICE, "%.20s%.*s", header, ELOG_MAXLEN - 64, message);
    len -= ELOG_MAXLEN - 64;
index 5907205bd87129e28b04508195a0036ac4755c0d..e7f047477ca1de6f959ca4c11891f3265a6f6cfc 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.3 1999/05/10 00:44:59 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.4 1999/05/25 16:08:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,7 +53,7 @@ static void NormIndexAttrs(List *attList, AttrNumber *attNumP,
 static char *GetDefaultOpClass(Oid atttypid);
 
 /*
- * DefineIndex 
+ * DefineIndex
  *     Creates a new index.
  *
  * 'attributeList' is a list of IndexElem specifying either a functional
@@ -164,7 +164,7 @@ DefineIndex(char *heapRelationName,
        if (nargs > INDEX_MAX_KEYS)
        {
            elog(ERROR,
-                "Too many args to function, limit of %d", INDEX_MAX_KEYS);
+              "Too many args to function, limit of %d", INDEX_MAX_KEYS);
        }
 
        FIsetnArgs(&fInfo, nargs);
@@ -207,7 +207,7 @@ DefineIndex(char *heapRelationName,
 
 
 /*
- * ExtendIndex 
+ * ExtendIndex
  *     Extends a partial index.
  *
  * Exceptions:
@@ -304,7 +304,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
    predInfo->oldPred = oldPred;
 
    attributeNumberA = (AttrNumber *) palloc(numberOfAttributes *
-                             sizeof attributeNumberA[0]);
+                                            sizeof attributeNumberA[0]);
    classObjectId = (Oid *) palloc(numberOfAttributes * sizeof classObjectId[0]);
 
 
@@ -501,7 +501,7 @@ NormIndexAttrs(List *attList,   /* list of IndexElem's */
            /* we just set the type name because that is all we need */
            attribute->typename = makeNode(TypeName);
            attribute->typename->name = nameout(&((Form_pg_type) GETSTRUCT(tuple))->typname);
-           
+
            /* we all need the typmod for the char and varchar types. */
            attribute->typename->typmod = attform->atttypmod;
        }
@@ -547,7 +547,7 @@ GetDefaultOpClass(Oid atttypid)
 }
 
 /*
- * RemoveIndex 
+ * RemoveIndex
  *     Deletes an index.
  *
  * Exceptions:
index 5334bd347d230817887bdc95f7a42531e14252c1..7ae4c2c176d67dd049eb519ccad4ca087ace5219 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.32 1999/02/13 23:15:08 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.33 1999/05/25 16:08:25 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -36,7 +36,7 @@
 #endif
 
 /*
- * RemoveOperator 
+ * RemoveOperator
  *     Deletes an operator.
  *
  * Exceptions:
@@ -288,7 +288,7 @@ RemoveType(char *typeName)      /* type name to be removed */
 }
 
 /*
- * RemoveFunction 
+ * RemoveFunction
  *     Deletes a function.
  *
  * Exceptions:
index 457facdd8fcdb4847824437c1427ec7aa4379ce2..061534054a9491524311bd2c01749d4307cdc78b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.24 1999/05/17 18:24:48 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.25 1999/05/25 16:08:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -142,7 +142,7 @@ renameatt(char *relname,
        }
    }
 
-   
+
    if ((relid = RelnameFindRelid(relname)) == InvalidOid)
        elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
 
@@ -201,7 +201,7 @@ renameatt(char *relname,
 void
 renamerel(char *oldrelname, char *newrelname)
 {
-   int     i;
+   int         i;
    Relation    relrelation;    /* for RELATION relation */
    HeapTuple   oldreltup;
    char        oldpath[MAXPGPATH],
@@ -237,7 +237,7 @@ renamerel(char *oldrelname, char *newrelname)
    {
        sprintf(toldpath, "%s.%d", oldpath, i);
        sprintf(tnewpath, "%s.%d", newpath, i);
-       if(rename(toldpath, tnewpath) < 0)
+       if (rename(toldpath, tnewpath) < 0)
            break;
    }
 
index d76eb07481d65cad3e15e43a775517a676b18254..a6f18e01d3d732b33084031ba9c13ddd3ce0fd8c 100644 (file)
@@ -66,7 +66,7 @@ static void init_params(CreateSeqStmt *seq, Form_pg_sequence new);
 static int get_param(DefElem *def);
 
 /*
- * DefineSequence 
+ * DefineSequence
  *             Creates a new sequence relation
  */
 void
@@ -218,8 +218,8 @@ nextval(struct varlena * seqin)
        return elm->last;
    }
 
-   seq = read_info("nextval", elm, &buf);      /* lock page' buffer and read
-                                                * tuple */
+   seq = read_info("nextval", elm, &buf);      /* lock page' buffer and
+                                                * read tuple */
 
    next = result = seq->last_value;
    incby = seq->increment_by;
@@ -327,8 +327,8 @@ setval(struct varlena * seqin, int4 next)
 
    /* open and AccessShareLock sequence */
    elm = init_sequence("setval", seqname);
-   seq = read_info("setval", elm, &buf);       /* lock page' buffer and read
-                                                * tuple */
+   seq = read_info("setval", elm, &buf);       /* lock page' buffer and
+                                                * read tuple */
 
    if (seq->cache_value != 1)
    {
@@ -361,11 +361,11 @@ setval(struct varlena * seqin, int4 next)
 static Form_pg_sequence
 read_info(char *caller, SeqTable elm, Buffer *buf)
 {
-   PageHeader      page;
-   ItemId          lp;
-   HeapTupleData   tuple;
+   PageHeader  page;
+   ItemId      lp;
+   HeapTupleData tuple;
    sequence_magic *sm;
-   Form_pg_sequence    seq;
+   Form_pg_sequence seq;
 
    if (RelationGetNumberOfBlocks(elm->rel) != 1)
        elog(ERROR, "%s.%s: invalid number of blocks in sequence",
@@ -464,7 +464,7 @@ init_sequence(char *caller, char *name)
 
 
 /*
- * CloseSequences 
+ * CloseSequences
  *             is calling by xact mgr at commit/abort.
  */
 void
index 09b7fdcbc3d0816518a214e52a99666c3f988c0d..cc3d27599c19a9de4dddb9a9444a43915075e71e 100644 (file)
@@ -362,9 +362,9 @@ RelationBuildTriggers(Relation relation)
    Form_pg_trigger pg_trigger;
    Relation    irel;
    ScanKeyData skey;
-   HeapTupleData   tuple;
-   IndexScanDesc   sd;
-   RetrieveIndexResult indexRes;
+   HeapTupleData tuple;
+   IndexScanDesc sd;
+   RetrieveIndexResult indexRes;
    Buffer      buffer;
    struct varlena *val;
    bool        isnull;
@@ -659,14 +659,14 @@ ExecARInsertTriggers(Relation rel, HeapTuple trigtuple)
 bool
 ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
 {
-   Relation        rel = estate->es_result_relation_info->ri_RelationDesc;
-   TriggerData    *SaveTriggerData;
-   int             ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE];
-   Trigger       **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
-   HeapTuple       trigtuple;
-   HeapTuple       newtuple = NULL;
+   Relation    rel = estate->es_result_relation_info->ri_RelationDesc;
+   TriggerData *SaveTriggerData;
+   int         ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE];
+   Trigger   **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
+   HeapTuple   trigtuple;
+   HeapTuple   newtuple = NULL;
    TupleTableSlot *newSlot;
-   int             i;
+   int         i;
 
    trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot);
    if (trigtuple == NULL)
@@ -697,7 +697,7 @@ ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
 void
 ExecARDeleteTriggers(EState *estate, ItemPointer tupleid)
 {
-   Relation        rel = estate->es_result_relation_info->ri_RelationDesc;
+   Relation    rel = estate->es_result_relation_info->ri_RelationDesc;
    TriggerData *SaveTriggerData;
    int         ntrigs = rel->trigdesc->n_after_row[TRIGGER_EVENT_DELETE];
    Trigger   **trigger = rel->trigdesc->tg_after_row[TRIGGER_EVENT_DELETE];
@@ -727,23 +727,23 @@ ExecARDeleteTriggers(EState *estate, ItemPointer tupleid)
 HeapTuple
 ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
 {
-   Relation        rel = estate->es_result_relation_info->ri_RelationDesc;
-   TriggerData    *SaveTriggerData;
-   int             ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE];
-   Trigger       **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_UPDATE];
-   HeapTuple       trigtuple;
-   HeapTuple       oldtuple;
-   HeapTuple       intuple = newtuple;
+   Relation    rel = estate->es_result_relation_info->ri_RelationDesc;
+   TriggerData *SaveTriggerData;
+   int         ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE];
+   Trigger   **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_UPDATE];
+   HeapTuple   trigtuple;
+   HeapTuple   oldtuple;
+   HeapTuple   intuple = newtuple;
    TupleTableSlot *newSlot;
-   int             i;
+   int         i;
 
    trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot);
    if (trigtuple == NULL)
        return NULL;
 
    /*
-    * In READ COMMITTED isolevel it's possible that newtuple
-    * was changed due to concurrent update.
+    * In READ COMMITTED isolevel it's possible that newtuple was changed
+    * due to concurrent update.
     */
    if (newSlot != NULL)
        intuple = newtuple = ExecRemoveJunk(estate->es_junkFilter, newSlot);
@@ -772,7 +772,7 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
 void
 ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
 {
-   Relation        rel = estate->es_result_relation_info->ri_RelationDesc;
+   Relation    rel = estate->es_result_relation_info->ri_RelationDesc;
    TriggerData *SaveTriggerData;
    int         ntrigs = rel->trigdesc->n_after_row[TRIGGER_EVENT_UPDATE];
    Trigger   **trigger = rel->trigdesc->tg_after_row[TRIGGER_EVENT_UPDATE];
@@ -799,22 +799,22 @@ ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
    return;
 }
 
-extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
+extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
 
 static HeapTuple
 GetTupleForTrigger(EState *estate, ItemPointer tid, TupleTableSlot **newSlot)
 {
-   Relation        relation = estate->es_result_relation_info->ri_RelationDesc;
-   HeapTupleData   tuple;
-   HeapTuple       result;
-   Buffer          buffer;
+   Relation    relation = estate->es_result_relation_info->ri_RelationDesc;
+   HeapTupleData tuple;
+   HeapTuple   result;
+   Buffer      buffer;
 
    if (newSlot != NULL)
    {
-       int     test;
+       int         test;
 
        /*
-        *  mark tuple for update
+        * mark tuple for update
         */
        *newSlot = NULL;
        tuple.t_self = *tid;
@@ -824,7 +824,7 @@ ltrmark:;
        {
            case HeapTupleSelfUpdated:
                ReleaseBuffer(buffer);
-               return(NULL);
+               return (NULL);
 
            case HeapTupleMayBeUpdated:
                break;
@@ -835,9 +835,9 @@ ltrmark:;
                    elog(ERROR, "Can't serialize access due to concurrent update");
                else if (!(ItemPointerEquals(&(tuple.t_self), tid)))
                {
-                   TupleTableSlot *epqslot = EvalPlanQual(estate, 
-                       estate->es_result_relation_info->ri_RangeTableIndex, 
-                       &(tuple.t_self));
+                   TupleTableSlot *epqslot = EvalPlanQual(estate,
+                    estate->es_result_relation_info->ri_RangeTableIndex,
+                                                       &(tuple.t_self));
 
                    if (!(TupIsNull(epqslot)))
                    {
@@ -846,23 +846,23 @@ ltrmark:;
                        goto ltrmark;
                    }
                }
-               /* 
-                * if tuple was deleted or PlanQual failed
-                * for updated tuple - we have not process
-                * this tuple!
+
+               /*
+                * if tuple was deleted or PlanQual failed for updated
+                * tuple - we have not process this tuple!
                 */
-               return(NULL);
+               return (NULL);
 
            default:
                ReleaseBuffer(buffer);
                elog(ERROR, "Unknown status %u from heap_mark4update", test);
-               return(NULL);
+               return (NULL);
        }
    }
    else
    {
-       PageHeader      dp;
-       ItemId          lp;
+       PageHeader  dp;
+       ItemId      lp;
 
        buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
 
index 2b99c8efa89737330334d74cd143ab972414c06d..57ac35fb1f4d48c01827c4df3dc9360c5b790acc 100644 (file)
@@ -5,11 +5,11 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: user.c,v 1.27 1999/04/02 06:16:36 tgl Exp $
+ * $Id: user.c,v 1.28 1999/05/25 16:08:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
-#include <stdio.h>             
+#include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -35,7 +35,7 @@
 
 static void CheckPgUserAclNotNull(void);
 
-#define    SQL_LENGTH  512
+#define SQL_LENGTH 512
 
 /*---------------------------------------------------------------------
  * UpdatePgPwdFile
@@ -49,9 +49,9 @@ void
 UpdatePgPwdFile(char *sql, CommandDest dest)
 {
 
-   char    *filename,
-               *tempname;
-   int     bufsize;
+   char       *filename,
+              *tempname;
+   int         bufsize;
 
    /*
     * Create a temporary filename to be renamed later.  This prevents the
@@ -68,9 +68,9 @@ UpdatePgPwdFile(char *sql, CommandDest dest)
     * SEPCHAR character as the delimiter between fields.  Then rename the
     * file to its final name.
     */
-   snprintf(sql, SQL_LENGTH, 
-           "copy %s to '%s' using delimiters %s", 
-           ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
+   snprintf(sql, SQL_LENGTH,
+            "copy %s to '%s' using delimiters %s",
+            ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
    pg_exec_query_dest(sql, dest, false);
    rename(tempname, filename);
    pfree((void *) tempname);
@@ -94,19 +94,19 @@ UpdatePgPwdFile(char *sql, CommandDest dest)
 void
 DefineUser(CreateUserStmt *stmt, CommandDest dest)
 {
-   char               *pg_shadow,
-                       sql[SQL_LENGTH];
-   Relation            pg_shadow_rel;
-   TupleDesc           pg_shadow_dsc;
-   HeapScanDesc        scan;
-   HeapTuple           tuple;
-   Datum               datum;
-   bool                exists = false,
-                       n,
-                       inblock,
-                       havepassword,
-                       havevaluntil;
-   int                 max_id = -1;
+   char       *pg_shadow,
+               sql[SQL_LENGTH];
+   Relation    pg_shadow_rel;
+   TupleDesc   pg_shadow_dsc;
+   HeapScanDesc scan;
+   HeapTuple   tuple;
+   Datum       datum;
+   bool        exists = false,
+               n,
+               inblock,
+               havepassword,
+               havevaluntil;
+   int         max_id = -1;
 
    havepassword = stmt->password && stmt->password[0];
    havevaluntil = stmt->validUntil && stmt->validUntil[0];
@@ -161,21 +161,21 @@ DefineUser(CreateUserStmt *stmt, CommandDest dest)
        UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
        heap_close(pg_shadow_rel);
        UserAbortTransactionBlock();
-       elog(ERROR, 
-               "defineUser: user \"%s\" has already been created", stmt->user);
+       elog(ERROR,
+        "defineUser: user \"%s\" has already been created", stmt->user);
        return;
    }
 
    /*
     * Build the insert statement to be executed.
     *
-    * XXX Ugly as this code is, it still fails to cope with ' or \
-    * in any of the provided strings.
+    * XXX Ugly as this code is, it still fails to cope with ' or \ in any of
+    * the provided strings.
     */
-   snprintf(sql, SQL_LENGTH, 
+   snprintf(sql, SQL_LENGTH,
             "insert into %s (usename,usesysid,usecreatedb,usetrace,"
             "usesuper,usecatupd,passwd,valuntil) "
-            "values('%s',%d,'%c','t','%c','t',%s%s%s,%s%s%s)", 
+            "values('%s',%d,'%c','t','%c','t',%s%s%s,%s%s%s)",
             ShadowRelationName,
             stmt->user,
             max_id + 1,
@@ -216,12 +216,12 @@ extern void
 AlterUser(AlterUserStmt *stmt, CommandDest dest)
 {
 
-   char            *pg_shadow,
-                       sql[SQL_LENGTH];
+   char       *pg_shadow,
+               sql[SQL_LENGTH];
    Relation    pg_shadow_rel;
    TupleDesc   pg_shadow_dsc;
    HeapTuple   tuple;
-   bool            inblock;
+   bool        inblock;
 
    if (stmt->password)
        CheckPgUserAclNotNull();
@@ -272,34 +272,32 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
    snprintf(sql, SQL_LENGTH, "update %s set", ShadowRelationName);
 
    if (stmt->password)
-   {
        snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password);
-   }
 
    if (stmt->createdb)
    {
        snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
-               pstrdup(sql), stmt->password ? "," : "",
-               *stmt->createdb ? "t" : "f");
+                pstrdup(sql), stmt->password ? "," : "",
+                *stmt->createdb ? "t" : "f");
    }
 
    if (stmt->createuser)
    {
        snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
-               pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
-               *stmt->createuser ? "t" : "f");
+            pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
+                *stmt->createuser ? "t" : "f");
    }
 
    if (stmt->validUntil)
    {
        snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
-               pstrdup(sql),
-               (stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
-               stmt->validUntil);
+                pstrdup(sql),
+       (stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
+                stmt->validUntil);
    }
 
    snprintf(sql, SQL_LENGTH, "%s where usename = '%s'",
-               pstrdup(sql), stmt->user);
+            pstrdup(sql), stmt->user);
 
    pg_exec_query_dest(sql, dest, false);
 
@@ -393,8 +391,8 @@ RemoveUser(char *user, CommandDest dest)
            datum = heap_getattr(tuple, Anum_pg_database_datname, pg_dsc, &n);
            if (memcmp((void *) datum, "template1", 9))
            {
-               dbase = 
-                       (char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1));
+               dbase =
+                   (char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1));
                dbase[ndbase] = (char *) palloc(NAMEDATALEN + 1);
                memcpy((void *) dbase[ndbase], (void *) datum, NAMEDATALEN);
                dbase[ndbase++][NAMEDATALEN] = '\0';
@@ -435,8 +433,8 @@ RemoveUser(char *user, CommandDest dest)
    /*
     * Remove the user from the pg_shadow table
     */
-   snprintf(sql, SQL_LENGTH, 
-           "delete from %s where usename = '%s'", ShadowRelationName, user);
+   snprintf(sql, SQL_LENGTH,
+       "delete from %s where usename = '%s'", ShadowRelationName, user);
    pg_exec_query_dest(sql, dest, false);
 
    UpdatePgPwdFile(sql, dest);
index 82ba86f84e982d6dbb872f2aca1ee5dd48d6793a..8c929678b35b3dd85c4110bb2ab113392955c62c 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.103 1999/05/23 09:10:24 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.104 1999/05/25 16:08:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,7 +66,7 @@ static Portal vc_portal;
 
 static int MESSAGE_LEVEL;      /* message level */
 
-static TransactionId   XmaxRecent;
+static TransactionId XmaxRecent;
 
 #define swapLong(a,b)  {long tmp; tmp=a; a=b; b=tmp;}
 #define swapInt(a,b)   {int tmp; tmp=a; a=b; b=tmp;}
@@ -101,8 +101,8 @@ static void vc_free(VRelList vrl);
 static void vc_getindices(Oid relid, int *nindices, Relation **Irel);
 static void vc_clsindices(int nindices, Relation *Irel);
 static void vc_mkindesc(Relation onerel, int nindices, Relation *Irel, IndDesc **Idesc);
-static void *vc_find_eq(void *bot, int nelem, int size, void *elm, 
-                       int (*compar) (const void *, const void *));
+static void *vc_find_eq(void *bot, int nelem, int size, void *elm,
+          int (*compar) (const void *, const void *));
 static int vc_cmp_blk(const void *left, const void *right);
 static int vc_cmp_offno(const void *left, const void *right);
 static int vc_cmp_vtlinks(const void *left, const void *right);
@@ -222,14 +222,15 @@ vc_shutdown()
 {
    /* on entry, we are not in a transaction */
 
-   /* Flush the init file that relcache.c uses to save startup time.
-    * The next backend startup will rebuild the init file with up-to-date
-    * information from pg_class.  This lets the optimizer see the stats that
-    * we've collected for certain critical system indexes.  See relcache.c
-    * for more details.
+   /*
+    * Flush the init file that relcache.c uses to save startup time. The
+    * next backend startup will rebuild the init file with up-to-date
+    * information from pg_class.  This lets the optimizer see the stats
+    * that we've collected for certain critical system indexes.  See
+    * relcache.c for more details.
     *
-    * Ignore any failure to unlink the file, since it might not be there
-    * if no backend has been started since the last vacuum...
+    * Ignore any failure to unlink the file, since it might not be there if
+    * no backend has been started since the last vacuum...
     */
    unlink(RELCACHE_INIT_FILENAME);
 
@@ -578,7 +579,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
 
    /* update statistics in pg_class */
    vc_updstats(vacrelstats->relid, vacrelstats->num_pages,
-               vacrelstats->num_tuples, vacrelstats->hasindex, vacrelstats);
+           vacrelstats->num_tuples, vacrelstats->hasindex, vacrelstats);
 
    /* next command frees attribute stats */
    CommitTransactionCommand();
@@ -601,7 +602,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                blkno;
    ItemId      itemid;
    Buffer      buf;
-   HeapTupleData   tuple;
+   HeapTupleData tuple;
    Page        page,
                tempPage = NULL;
    OffsetNumber offnum,
@@ -712,7 +713,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                else if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
                {
                    if (TransactionIdDidCommit((TransactionId)
-                                               tuple.t_data->t_cmin))
+                                              tuple.t_data->t_cmin))
                    {
                        tuple.t_data->t_infomask |= HEAP_XMIN_INVALID;
                        tupgone = true;
@@ -759,7 +760,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                    else
                    {
                        elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
-                            relname, blkno, offnum, tuple.t_data->t_xmin);
+                          relname, blkno, offnum, tuple.t_data->t_xmin);
                        do_shrinking = false;
                    }
                }
@@ -799,6 +800,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                }
                else if (!TransactionIdIsInProgress(tuple.t_data->t_xmax))
                {
+
                    /*
                     * Not Aborted, Not Committed, Not in Progress - so it
                     * from crashed process. - vadim 06/02/97
@@ -812,11 +814,12 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                         relname, blkno, offnum, tuple.t_data->t_xmax);
                    do_shrinking = false;
                }
+
                /*
-                * If tuple is recently deleted then
-                * we must not remove it from relation.
+                * If tuple is recently deleted then we must not remove it
+                * from relation.
                 */
-               if (tupgone && tuple.t_data->t_xmax >= XmaxRecent && 
+               if (tupgone && tuple.t_data->t_xmax >= XmaxRecent &&
                    tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
                {
                    tupgone = false;
@@ -826,20 +829,21 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                        tuple.t_data->t_infomask |= HEAP_XMAX_COMMITTED;
                        pgchanged = true;
                    }
+
                    /*
                     * If we do shrinking and this tuple is updated one
                     * then remember it to construct updated tuple
                     * dependencies.
                     */
-                   if (do_shrinking && !(ItemPointerEquals(&(tuple.t_self), 
-                                               &(tuple.t_data->t_ctid))))
+                   if (do_shrinking && !(ItemPointerEquals(&(tuple.t_self),
+                                              &(tuple.t_data->t_ctid))))
                    {
                        if (free_vtlinks == 0)
                        {
                            free_vtlinks = 1000;
-                           vtlinks = (VTupleLink) repalloc(vtlinks, 
-                                           (free_vtlinks + num_vtlinks) * 
-                                           sizeof(VTupleLinkData));
+                           vtlinks = (VTupleLink) repalloc(vtlinks,
+                                          (free_vtlinks + num_vtlinks) *
+                                                sizeof(VTupleLinkData));
                        }
                        vtlinks[num_vtlinks].new_tid = tuple.t_data->t_ctid;
                        vtlinks[num_vtlinks].this_tid = tuple.t_self;
@@ -962,8 +966,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 
    if (usable_free_size > 0 && num_vtlinks > 0)
    {
-       qsort((char *) vtlinks, num_vtlinks, sizeof (VTupleLinkData), 
-           vc_cmp_vtlinks);
+       qsort((char *) vtlinks, num_vtlinks, sizeof(VTupleLinkData),
+             vc_cmp_vtlinks);
        vacrelstats->vtlinks = vtlinks;
        vacrelstats->num_vtlinks = num_vtlinks;
    }
@@ -980,10 +984,10 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 Tup %u: Vac %u, Keep/VTL %u/%u, Crash %u, UnUsed %u, MinLen %u, MaxLen %u; \
 Re-using: Free/Avail. Space %u/%u; EndEmpty/Avail. Pages %u/%u. \
 Elapsed %u/%u sec.",
-        nblocks, changed_pages, vacuum_pages->vpl_num_pages, empty_pages, 
-        new_pages, num_tuples, tups_vacuumed, 
-        nkeep, vacrelstats->num_vtlinks, ncrash, 
-        nunused, min_tlen, max_tlen, free_size, usable_free_size, 
+        nblocks, changed_pages, vacuum_pages->vpl_num_pages, empty_pages,
+        new_pages, num_tuples, tups_vacuumed,
+        nkeep, vacrelstats->num_vtlinks, ncrash,
+        nunused, min_tlen, max_tlen, free_size, usable_free_size,
         empty_end_pages, fraged_pages->vpl_num_pages,
         ru1.ru_stime.tv_sec - ru0.ru_stime.tv_sec,
         ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec);
@@ -1019,8 +1023,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                max_offset;
    ItemId      itemid,
                newitemid;
-   HeapTupleData   tuple,
-                   newtup;
+   HeapTupleData tuple,
+               newtup;
    TupleDesc   tupdesc = NULL;
    Datum      *idatum = NULL;
    char       *inulls = NULL;
@@ -1128,7 +1132,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
        else
            Assert(!isempty);
 
-       chain_tuple_moved = false;  /* no one chain-tuple was moved off this page, yet */
+       chain_tuple_moved = false;      /* no one chain-tuple was moved
+                                        * off this page, yet */
        vpc->vpd_blkno = blkno;
        maxoff = PageGetMaxOffsetNumber(page);
        for (offnum = FirstOffsetNumber;
@@ -1146,28 +1151,30 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
 
            if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
            {
-               if ((TransactionId)tuple.t_data->t_cmin != myXID)
+               if ((TransactionId) tuple.t_data->t_cmin != myXID)
                    elog(ERROR, "Invalid XID in t_cmin");
                if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
                    elog(ERROR, "HEAP_MOVED_IN was not expected");
-               /* 
-                * If this (chain) tuple is moved by me already then
-                * I have to check is it in vpc or not - i.e. is it 
-                * moved while cleaning this page or some previous one.
+
+               /*
+                * If this (chain) tuple is moved by me already then I
+                * have to check is it in vpc or not - i.e. is it moved
+                * while cleaning this page or some previous one.
                 */
                if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
                {
                    if (keep_tuples == 0)
                        continue;
-                   if (chain_tuple_moved)  /* some chains was moved while */
-                   {                       /* cleaning this page */
+                   if (chain_tuple_moved)      /* some chains was moved
+                                                * while */
+                   {           /* cleaning this page */
                        Assert(vpc->vpd_offsets_free > 0);
                        for (i = 0; i < vpc->vpd_offsets_free; i++)
                        {
                            if (vpc->vpd_offsets[i] == offnum)
                                break;
                        }
-                       if (i >= vpc->vpd_offsets_free) /* not found */
+                       if (i >= vpc->vpd_offsets_free) /* not found */
                        {
                            vpc->vpd_offsets[vpc->vpd_offsets_free++] = offnum;
                            keep_tuples--;
@@ -1184,29 +1191,29 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
            }
 
            /*
-            * If this tuple is in the chain of tuples created in 
-            * updates by "recent" transactions then we have to 
-            * move all chain of tuples to another places.
+            * If this tuple is in the chain of tuples created in updates
+            * by "recent" transactions then we have to move all chain of
+            * tuples to another places.
             */
-           if ((tuple.t_data->t_infomask & HEAP_UPDATED && 
+           if ((tuple.t_data->t_infomask & HEAP_UPDATED &&
                 tuple.t_data->t_xmin >= XmaxRecent) ||
-               (!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) && 
+               (!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) &&
                 !(ItemPointerEquals(&(tuple.t_self), &(tuple.t_data->t_ctid)))))
            {
-               Buffer          Cbuf = buf;
-               Page            Cpage;
-               ItemId          Citemid;
-               ItemPointerData Ctid;
-               HeapTupleData   tp = tuple;
-               Size            tlen = tuple_len;
-               VTupleMove      vtmove = (VTupleMove) 
-                                   palloc(100 * sizeof(VTupleMoveData));
-               int             num_vtmove = 0;
-               int             free_vtmove = 100;
-               VPageDescr      to_vpd = fraged_pages->vpl_pagedesc[0];
-               int             to_item = 0;
-               bool            freeCbuf = false;
-               int             ti;
+               Buffer      Cbuf = buf;
+               Page        Cpage;
+               ItemId      Citemid;
+               ItemPointerData Ctid;
+               HeapTupleData tp = tuple;
+               Size        tlen = tuple_len;
+               VTupleMove  vtmove = (VTupleMove)
+               palloc(100 * sizeof(VTupleMoveData));
+               int         num_vtmove = 0;
+               int         free_vtmove = 100;
+               VPageDescr  to_vpd = fraged_pages->vpl_pagedesc[0];
+               int         to_item = 0;
+               bool        freeCbuf = false;
+               int         ti;
 
                if (vacrelstats->vtlinks == NULL)
                    elog(ERROR, "No one parent tuple was found");
@@ -1215,22 +1222,23 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                    WriteBuffer(cur_buffer);
                    cur_buffer = InvalidBuffer;
                }
+
                /*
-                * If this tuple is in the begin/middle of the chain
-                * then we have to move to the end of chain.
+                * If this tuple is in the begin/middle of the chain then
+                * we have to move to the end of chain.
                 */
-               while (!(tp.t_data->t_infomask & HEAP_XMAX_INVALID) && 
-                   !(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid))))
+               while (!(tp.t_data->t_infomask & HEAP_XMAX_INVALID) &&
+               !(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid))))
                {
                    Ctid = tp.t_data->t_ctid;
                    if (freeCbuf)
                        ReleaseBuffer(Cbuf);
                    freeCbuf = true;
-                   Cbuf = ReadBuffer(onerel, 
-                           ItemPointerGetBlockNumber(&Ctid));
+                   Cbuf = ReadBuffer(onerel,
+                                     ItemPointerGetBlockNumber(&Ctid));
                    Cpage = BufferGetPage(Cbuf);
-                   Citemid = PageGetItemId(Cpage, 
-                           ItemPointerGetOffsetNumber(&Ctid));
+                   Citemid = PageGetItemId(Cpage,
+                                     ItemPointerGetOffsetNumber(&Ctid));
                    if (!ItemIdIsUsed(Citemid))
                        elog(ERROR, "Child itemid marked as unused");
                    tp.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
@@ -1238,16 +1246,16 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                    tlen = tp.t_len = ItemIdGetLength(Citemid);
                }
                /* first, can chain be moved ? */
-               for ( ; ; )
+               for (;;)
                {
                    if (!vc_enough_space(to_vpd, tlen))
                    {
                        if (to_vpd != last_fraged_page &&
-                           !vc_enough_space(to_vpd, vacrelstats->min_tlen))
+                        !vc_enough_space(to_vpd, vacrelstats->min_tlen))
                        {
                            Assert(num_fraged_pages > to_item + 1);
                            memmove(fraged_pages->vpl_pagedesc + to_item,
-                                   fraged_pages->vpl_pagedesc + to_item + 1,
+                               fraged_pages->vpl_pagedesc + to_item + 1,
                                    sizeof(VPageDescr *) * (num_fraged_pages - to_item - 1));
                            num_fraged_pages--;
                            Assert(last_fraged_page == fraged_pages->vpl_pagedesc[num_fraged_pages - 1]);
@@ -1257,7 +1265,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                            if (vc_enough_space(fraged_pages->vpl_pagedesc[i], tlen))
                                break;
                        }
-                       if (i == num_fraged_pages)  /* can't move item anywhere */
+                       if (i == num_fraged_pages)      /* can't move item
+                                                        * anywhere */
                        {
                            for (i = 0; i < num_vtmove; i++)
                            {
@@ -1277,9 +1286,9 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                    if (free_vtmove == 0)
                    {
                        free_vtmove = 1000;
-                       vtmove = (VTupleMove) repalloc(vtmove, 
-                                       (free_vtmove + num_vtmove) * 
-                                       sizeof(VTupleMoveData));
+                       vtmove = (VTupleMove) repalloc(vtmove,
+                                            (free_vtmove + num_vtmove) *
+                                                sizeof(VTupleMoveData));
                    }
                    vtmove[num_vtmove].tid = tp.t_self;
                    vtmove[num_vtmove].vpd = to_vpd;
@@ -1289,56 +1298,59 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                        vtmove[num_vtmove].cleanVpd = false;
                    free_vtmove--;
                    num_vtmove++;
+
                    /*
                     * All done ?
                     */
-                   if (!(tp.t_data->t_infomask & HEAP_UPDATED) || 
-                           tp.t_data->t_xmin < XmaxRecent)
+                   if (!(tp.t_data->t_infomask & HEAP_UPDATED) ||
+                       tp.t_data->t_xmin < XmaxRecent)
                        break;
+
                    /*
                     * Well, try to find tuple with old row version
                     */
-                   for ( ; ; )
+                   for (;;)
                    {
-                       Buffer          Pbuf;
-                       Page            Ppage;
-                       ItemId          Pitemid;
-                       HeapTupleData   Ptp;
-                       VTupleLinkData  vtld,
-                                      *vtlp;
+                       Buffer      Pbuf;
+                       Page        Ppage;
+                       ItemId      Pitemid;
+                       HeapTupleData Ptp;
+                       VTupleLinkData vtld,
+                                  *vtlp;
 
                        vtld.new_tid = tp.t_self;
-                       vtlp = (VTupleLink) 
-                               vc_find_eq((void *) (vacrelstats->vtlinks),
-                               vacrelstats->num_vtlinks, 
-                               sizeof(VTupleLinkData), 
-                               (void *) &vtld,
-                               vc_cmp_vtlinks);
+                       vtlp = (VTupleLink)
+                           vc_find_eq((void *) (vacrelstats->vtlinks),
+                                      vacrelstats->num_vtlinks,
+                                      sizeof(VTupleLinkData),
+                                      (void *) &vtld,
+                                      vc_cmp_vtlinks);
                        if (vtlp == NULL)
                            elog(ERROR, "Parent tuple was not found");
                        tp.t_self = vtlp->this_tid;
-                       Pbuf = ReadBuffer(onerel, 
+                       Pbuf = ReadBuffer(onerel,
                                ItemPointerGetBlockNumber(&(tp.t_self)));
                        Ppage = BufferGetPage(Pbuf);
-                       Pitemid = PageGetItemId(Ppage, 
-                               ItemPointerGetOffsetNumber(&(tp.t_self)));
+                       Pitemid = PageGetItemId(Ppage,
+                              ItemPointerGetOffsetNumber(&(tp.t_self)));
                        if (!ItemIdIsUsed(Pitemid))
                            elog(ERROR, "Parent itemid marked as unused");
                        Ptp.t_data = (HeapTupleHeader) PageGetItem(Ppage, Pitemid);
                        Assert(Ptp.t_data->t_xmax == tp.t_data->t_xmin);
+
                        /*
-                        * If this tuple is updated version of row and
-                        * it was created by the same transaction then
-                        * no one is interested in this tuple -
-                        * mark it as removed.
+                        * If this tuple is updated version of row and it
+                        * was created by the same transaction then no one
+                        * is interested in this tuple - mark it as
+                        * removed.
                         */
-                       if (Ptp.t_data->t_infomask & HEAP_UPDATED && 
+                       if (Ptp.t_data->t_infomask & HEAP_UPDATED &&
                            Ptp.t_data->t_xmin == Ptp.t_data->t_xmax)
                        {
-                           TransactionIdStore(myXID, 
-                               (TransactionId*) &(Ptp.t_data->t_cmin));
-                           Ptp.t_data->t_infomask &= 
-                               ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN);
+                           TransactionIdStore(myXID,
+                               (TransactionId *) &(Ptp.t_data->t_cmin));
+                           Ptp.t_data->t_infomask &=
+                               ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
                            Ptp.t_data->t_infomask |= HEAP_MOVED_OFF;
                            WriteBuffer(Pbuf);
                            continue;
@@ -1354,7 +1366,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                }
                if (freeCbuf)
                    ReleaseBuffer(Cbuf);
-               if (num_vtmove == 0)            /* chain can't be moved */
+               if (num_vtmove == 0)    /* chain can't be moved */
                {
                    pfree(vtmove);
                    break;
@@ -1364,19 +1376,20 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                {
                    /* Get tuple from chain */
                    tuple.t_self = vtmove[ti].tid;
-                   Cbuf = ReadBuffer(onerel, 
-                           ItemPointerGetBlockNumber(&(tuple.t_self)));
+                   Cbuf = ReadBuffer(onerel,
+                            ItemPointerGetBlockNumber(&(tuple.t_self)));
                    Cpage = BufferGetPage(Cbuf);
-                   Citemid = PageGetItemId(Cpage, 
+                   Citemid = PageGetItemId(Cpage,
                            ItemPointerGetOffsetNumber(&(tuple.t_self)));
                    tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
                    tuple_len = tuple.t_len = ItemIdGetLength(Citemid);
                    /* Get page to move in */
                    cur_buffer = ReadBuffer(onerel, vtmove[ti].vpd->vpd_blkno);
+
                    /*
-                    * We should LockBuffer(cur_buffer) but don't, at the 
-                    * moment. If you'll do LockBuffer then UNLOCK it 
-                    * before index_insert: unique btree-s call heap_fetch 
+                    * We should LockBuffer(cur_buffer) but don't, at the
+                    * moment. If you'll do LockBuffer then UNLOCK it
+                    * before index_insert: unique btree-s call heap_fetch
                     * to get t_infomask of inserted heap tuple !!!
                     */
                    ToPage = BufferGetPage(cur_buffer);
@@ -1385,22 +1398,23 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                        vc_vacpage(ToPage, vtmove[ti].vpd);
                    heap_copytuple_with_tuple(&tuple, &newtup);
                    RelationInvalidateHeapTuple(onerel, &tuple);
-                   TransactionIdStore(myXID, (TransactionId*) &(newtup.t_data->t_cmin));
-                   newtup.t_data->t_infomask &= 
-                       ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_OFF);
+                   TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin));
+                   newtup.t_data->t_infomask &=
+                       ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
                    newtup.t_data->t_infomask |= HEAP_MOVED_IN;
                    newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len,
-                                InvalidOffsetNumber, LP_USED);
+                                        InvalidOffsetNumber, LP_USED);
                    if (newoff == InvalidOffsetNumber)
                    {
                        elog(ERROR, "\
 moving chain: failed to add item with len = %u to page %u",
-                    tuple_len, vtmove[ti].vpd->vpd_blkno);
+                            tuple_len, vtmove[ti].vpd->vpd_blkno);
                    }
                    newitemid = PageGetItemId(ToPage, newoff);
                    pfree(newtup.t_data);
                    newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
                    ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff);
+
                    /*
                     * Set t_ctid pointing to itself for last tuple in
                     * chain and to next tuple in chain otherwise.
@@ -1411,19 +1425,20 @@ moving chain: failed to add item with len = %u to page %u",
                        newtup.t_data->t_ctid = Ctid;
                    Ctid = newtup.t_self;
 
-                   TransactionIdStore(myXID, (TransactionId*) &(tuple.t_data->t_cmin));
-                   tuple.t_data->t_infomask &= 
-                       ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN);
+                   TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin));
+                   tuple.t_data->t_infomask &=
+                       ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
                    tuple.t_data->t_infomask |= HEAP_MOVED_OFF;
 
                    num_moved++;
+
                    /*
                     * Remember that we moved tuple from the current page
                     * (corresponding index tuple will be cleaned).
                     */
                    if (Cbuf == buf)
-                       vpc->vpd_offsets[vpc->vpd_offsets_free++] = 
-                               ItemPointerGetOffsetNumber(&(tuple.t_self));
+                       vpc->vpd_offsets[vpc->vpd_offsets_free++] =
+                           ItemPointerGetOffsetNumber(&(tuple.t_self));
                    else
                        keep_tuples++;
 
@@ -1432,12 +1447,12 @@ moving chain: failed to add item with len = %u to page %u",
                        for (i = 0, idcur = Idesc; i < nindices; i++, idcur++)
                        {
                            FormIndexDatum(idcur->natts,
-                                  (AttrNumber *) &(idcur->tform->indkey[0]),
-                                      &newtup,
-                                      tupdesc,
-                                      idatum,
-                                      inulls,
-                                      idcur->finfoP);
+                              (AttrNumber *) &(idcur->tform->indkey[0]),
+                                          &newtup,
+                                          tupdesc,
+                                          idatum,
+                                          inulls,
+                                          idcur->finfoP);
                            iresult = index_insert(Irel[i],
                                                   idatum,
                                                   inulls,
@@ -1507,13 +1522,13 @@ moving chain: failed to add item with len = %u to page %u",
 
            RelationInvalidateHeapTuple(onerel, &tuple);
 
-           /* 
-            * Mark new tuple as moved_in by vacuum and 
-            * store vacuum XID in t_cmin !!! 
+           /*
+            * Mark new tuple as moved_in by vacuum and store vacuum XID
+            * in t_cmin !!!
             */
-           TransactionIdStore(myXID, (TransactionId*) &(newtup.t_data->t_cmin));
-           newtup.t_data->t_infomask &= 
-               ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_OFF);
+           TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin));
+           newtup.t_data->t_infomask &=
+               ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
            newtup.t_data->t_infomask |= HEAP_MOVED_IN;
 
            /* add tuple to the page */
@@ -1532,13 +1547,13 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
            ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff);
            newtup.t_self = newtup.t_data->t_ctid;
 
-           /* 
-            * Mark old tuple as moved_off by vacuum and 
-            * store vacuum XID in t_cmin !!! 
+           /*
+            * Mark old tuple as moved_off by vacuum and store vacuum XID
+            * in t_cmin !!!
             */
-           TransactionIdStore(myXID, (TransactionId*) &(tuple.t_data->t_cmin));
-           tuple.t_data->t_infomask &= 
-               ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN);
+           TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin));
+           tuple.t_data->t_infomask &=
+               ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN);
            tuple.t_data->t_infomask |= HEAP_MOVED_OFF;
 
            cur_page->vpd_offsets_used++;
@@ -1572,11 +1587,11 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
 
        if (offnum < maxoff && keep_tuples > 0)
        {
-           OffsetNumber    off;
+           OffsetNumber off;
 
            for (off = OffsetNumberNext(offnum);
-                   off <= maxoff;
-                   off = OffsetNumberNext(off))
+                off <= maxoff;
+                off = OffsetNumberNext(off))
            {
                itemid = PageGetItemId(page, off);
                if (!ItemIdIsUsed(itemid))
@@ -1584,21 +1599,22 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
                if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
                    continue;
-               if ((TransactionId)tuple.t_data->t_cmin != myXID)
+               if ((TransactionId) tuple.t_data->t_cmin != myXID)
                    elog(ERROR, "Invalid XID in t_cmin (4)");
                if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
                    elog(ERROR, "HEAP_MOVED_IN was not expected (2)");
                if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
                {
-                   if (chain_tuple_moved)  /* some chains was moved while */
-                   {                       /* cleaning this page */
+                   if (chain_tuple_moved)      /* some chains was moved
+                                                * while */
+                   {           /* cleaning this page */
                        Assert(vpc->vpd_offsets_free > 0);
                        for (i = 0; i < vpc->vpd_offsets_free; i++)
                        {
                            if (vpc->vpd_offsets[i] == off)
                                break;
                        }
-                       if (i >= vpc->vpd_offsets_free) /* not found */
+                       if (i >= vpc->vpd_offsets_free) /* not found */
                        {
                            vpc->vpd_offsets[vpc->vpd_offsets_free++] = off;
                            Assert(keep_tuples > 0);
@@ -1619,8 +1635,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
        {
            if (chain_tuple_moved)      /* else - they are ordered */
            {
-               qsort((char *) (vpc->vpd_offsets), vpc->vpd_offsets_free, 
-                                   sizeof(OffsetNumber), vc_cmp_offno);
+               qsort((char *) (vpc->vpd_offsets), vpc->vpd_offsets_free,
+                     sizeof(OffsetNumber), vc_cmp_offno);
            }
            vc_reappage(&Nvpl, vpc);
            WriteBuffer(buf);
@@ -1645,6 +1661,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
 
    if (num_moved > 0)
    {
+
        /*
         * We have to commit our tuple' movings before we'll truncate
         * relation, but we shouldn't lose our locks. And so - quick hack:
@@ -1657,8 +1674,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
    }
 
    /*
-    * Clean uncleaned reapped pages from vacuum_pages list list and set xmin
-    * committed for inserted tuples
+    * Clean uncleaned reapped pages from vacuum_pages list list and set
+    * xmin committed for inserted tuples
     */
    checked_moved = 0;
    for (i = 0, vpp = vacuum_pages->vpl_pagedesc; i < vacuumed_pages; i++, vpp++)
@@ -1671,7 +1688,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
            if (!PageIsEmpty(page))
                vc_vacpage(page, *vpp);
        }
-       else    /* this page was used */
+       else
+/* this page was used */
        {
            num_tuples = 0;
            max_offset = PageGetMaxOffsetNumber(page);
@@ -1685,7 +1703,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
                if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
                {
-                   if ((TransactionId)tuple.t_data->t_cmin != myXID)
+                   if ((TransactionId) tuple.t_data->t_cmin != myXID)
                        elog(ERROR, "Invalid XID in t_cmin (2)");
                    if (tuple.t_data->t_infomask & HEAP_MOVED_IN)
                    {
@@ -1734,8 +1752,8 @@ Elapsed %u/%u sec.",
            }
            Assert(keep_tuples >= 0);
            for (i = 0; i < nindices; i++)
-               vc_vaconeind(&Nvpl, Irel[i], 
-                           vacrelstats->num_tuples, keep_tuples);
+               vc_vaconeind(&Nvpl, Irel[i],
+                            vacrelstats->num_tuples, keep_tuples);
        }
 
        /*
@@ -1757,7 +1775,7 @@ Elapsed %u/%u sec.",
 
                if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
                {
-                   if ((TransactionId)tuple.t_data->t_cmin != myXID)
+                   if ((TransactionId) tuple.t_data->t_cmin != myXID)
                        elog(ERROR, "Invalid XID in t_cmin (3)");
                    if (tuple.t_data->t_infomask & HEAP_MOVED_OFF)
                    {
@@ -1998,7 +2016,7 @@ vc_vaconeind(VPageList vpl, Relation indrel, int num_tuples, int keep_tuples)
    getrusage(RUSAGE_SELF, &ru1);
 
    elog(MESSAGE_LEVEL, "Index %s: Pages %u; Tuples %u: Deleted %u. Elapsed %u/%u sec.",
-        indrel->rd_rel->relname.data, num_pages, 
+        indrel->rd_rel->relname.data, num_pages,
         num_index_tuples - keep_tuples, tups_vacuumed,
         ru1.ru_stime.tv_sec - ru0.ru_stime.tv_sec,
         ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec);
@@ -2208,25 +2226,25 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l
 static void
 vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
 {
-   Relation            rd,
-                       ad,
-                       sd;
-   HeapScanDesc        scan;
-   HeapTupleData       rtup;
-   HeapTuple           ctup,
-                       atup,
-                       stup;
-   Form_pg_class       pgcform;
-   ScanKeyData         askey;
-   Form_pg_attribute   attp;
-   Buffer              buffer;
+   Relation    rd,
+               ad,
+               sd;
+   HeapScanDesc scan;
+   HeapTupleData rtup;
+   HeapTuple   ctup,
+               atup,
+               stup;
+   Form_pg_class pgcform;
+   ScanKeyData askey;
+   Form_pg_attribute attp;
+   Buffer      buffer;
 
    /*
     * update number of tuples and number of pages in pg_class
     */
    ctup = SearchSysCacheTupleCopy(RELOID,
-                              ObjectIdGetDatum(relid),
-                              0, 0, 0);
+                                  ObjectIdGetDatum(relid),
+                                  0, 0, 0);
    if (!HeapTupleIsValid(ctup))
        elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
             relid);
@@ -2237,7 +2255,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
    rtup.t_self = ctup->t_self;
    heap_fetch(rd, SnapshotNow, &rtup, &buffer);
    pfree(ctup);
-   
+
    /* overwrite the existing statistics in the tuple */
    vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
    pgcform = (Form_pg_class) GETSTRUCT(&rtup);
@@ -2317,8 +2335,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
                attp->attdisbursion = selratio;
 
                /*
-                * Invalidate the cache for the tuple
-                * and write the buffer
+                * Invalidate the cache for the tuple and write the buffer
                 */
                RelationInvalidateHeapTuple(ad, atup);
                WriteNoReleaseBuffer(abuffer);
@@ -2375,8 +2392,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
    }
 
    /*
-    * Invalidate the cached pg_class tuple and
-    * write the buffer
+    * Invalidate the cached pg_class tuple and write the buffer
     */
    RelationInvalidateHeapTuple(rd, &rtup);
 
@@ -2504,8 +2520,8 @@ vc_free(VRelList vrl)
 }
 
 static void *
-vc_find_eq(void *bot, int nelem, int size, void *elm, 
-           int (*compar) (const void *, const void *))
+vc_find_eq(void *bot, int nelem, int size, void *elm,
+          int (*compar) (const void *, const void *))
 {
    int         res;
    int         last = nelem - 1;
@@ -2527,16 +2543,16 @@ vc_find_eq(void *bot, int nelem, int size, void *elm,
        }
        if (last_move == true)
        {
-           res = compar(elm, (void *)((char *)bot + last * size));
+           res = compar(elm, (void *) ((char *) bot + last * size));
            if (res > 0)
                return NULL;
            if (res == 0)
-               return (void *)((char *)bot + last * size);
+               return (void *) ((char *) bot + last * size);
            last_move = false;
        }
-       res = compar(elm, (void *)((char *)bot + celm * size));
+       res = compar(elm, (void *) ((char *) bot + celm * size));
        if (res == 0)
-           return (void *)((char *)bot + celm * size);
+           return (void *) ((char *) bot + celm * size);
        if (res < 0)
        {
            if (celm == 0)
@@ -2551,7 +2567,7 @@ vc_find_eq(void *bot, int nelem, int size, void *elm,
            return NULL;
 
        last = last - celm - 1;
-       bot = (void *)((char *)bot + (celm + 1) * size);
+       bot = (void *) ((char *) bot + (celm + 1) * size);
        celm = (last + 1) / 2;
        first_move = true;
    }
@@ -2591,25 +2607,25 @@ static int
 vc_cmp_vtlinks(const void *left, const void *right)
 {
 
-   if (((VTupleLink)left)->new_tid.ip_blkid.bi_hi < 
-       ((VTupleLink)right)->new_tid.ip_blkid.bi_hi)
+   if (((VTupleLink) left)->new_tid.ip_blkid.bi_hi <
+       ((VTupleLink) right)->new_tid.ip_blkid.bi_hi)
        return -1;
-   if (((VTupleLink)left)->new_tid.ip_blkid.bi_hi > 
-       ((VTupleLink)right)->new_tid.ip_blkid.bi_hi)
+   if (((VTupleLink) left)->new_tid.ip_blkid.bi_hi >
+       ((VTupleLink) right)->new_tid.ip_blkid.bi_hi)
        return 1;
    /* bi_hi-es are equal */
-   if (((VTupleLink)left)->new_tid.ip_blkid.bi_lo < 
-       ((VTupleLink)right)->new_tid.ip_blkid.bi_lo)
+   if (((VTupleLink) left)->new_tid.ip_blkid.bi_lo <
+       ((VTupleLink) right)->new_tid.ip_blkid.bi_lo)
        return -1;
-   if (((VTupleLink)left)->new_tid.ip_blkid.bi_lo > 
-       ((VTupleLink)right)->new_tid.ip_blkid.bi_lo)
+   if (((VTupleLink) left)->new_tid.ip_blkid.bi_lo >
+       ((VTupleLink) right)->new_tid.ip_blkid.bi_lo)
        return 1;
    /* bi_lo-es are equal */
-   if (((VTupleLink)left)->new_tid.ip_posid < 
-       ((VTupleLink)right)->new_tid.ip_posid)
+   if (((VTupleLink) left)->new_tid.ip_posid <
+       ((VTupleLink) right)->new_tid.ip_posid)
        return -1;
-   if (((VTupleLink)left)->new_tid.ip_posid > 
-       ((VTupleLink)right)->new_tid.ip_posid)
+   if (((VTupleLink) left)->new_tid.ip_posid >
+       ((VTupleLink) right)->new_tid.ip_posid)
        return 1;
    return 0;
 
index 66f75c5f06248b9f1ad357c3b1f3a9ac9d7ecf08..f1462423071fdfd7a1999fd5964ee97c31185e28 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for handling of 'SET var TO',
  * 'SHOW var' and 'RESET var' statements.
  *
- * $Id: variable.c,v 1.19 1999/02/18 06:00:44 momjian Exp $
+ * $Id: variable.c,v 1.20 1999/05/25 16:08:28 momjian Exp $
  *
  */
 
@@ -45,10 +45,12 @@ static bool parse_ksqo(const char *);
 static bool show_XactIsoLevel(void);
 static bool reset_XactIsoLevel(void);
 static bool parse_XactIsoLevel(const char *);
+
 #ifdef QUERY_LIMIT
 static bool show_query_limit(void);
 static bool reset_query_limit(void);
 static bool parse_query_limit(const char *);
+
 #endif
 
 extern Cost _cpu_page_wight_;
@@ -545,41 +547,41 @@ reset_timezone()
 static bool
 parse_query_limit(const char *value)
 {
-  int32 limit;
-
-  if (value == NULL) {
-    reset_query_limit();
-    return(TRUE);
-  }
-  /* why is pg_atoi's arg not declared "const char *" ? */
-  limit = pg_atoi((char *) value, sizeof(int32), '\0');
-  if (limit <= -1) {
-    elog(ERROR, "Bad value for # of query limit (%s)", value);
-  }
-  ExecutorLimit(limit);
-  return(TRUE);
+   int32       limit;
+
+   if (value == NULL)
+   {
+       reset_query_limit();
+       return (TRUE);
+   }
+   /* why is pg_atoi's arg not declared "const char *" ? */
+   limit = pg_atoi((char *) value, sizeof(int32), '\0');
+   if (limit <= -1)
+       elog(ERROR, "Bad value for # of query limit (%s)", value);
+   ExecutorLimit(limit);
+   return (TRUE);
 }
 
 static bool
 show_query_limit(void)
 {
-  int limit;
-
-  limit = ExecutorGetLimit();
-  if (limit == ALL_TUPLES) {
-    elog(NOTICE, "No query limit is set");
-  } else {
-    elog(NOTICE, "query limit is %d",limit);
-  }
-  return(TRUE);
+   int         limit;
+
+   limit = ExecutorGetLimit();
+   if (limit == ALL_TUPLES)
+       elog(NOTICE, "No query limit is set");
+   else
+       elog(NOTICE, "query limit is %d", limit);
+   return (TRUE);
 }
 
 static bool
 reset_query_limit(void)
 {
-  ExecutorLimit(ALL_TUPLES);
-  return(TRUE);
+   ExecutorLimit(ALL_TUPLES);
+   return (TRUE);
 }
+
 #endif
 
 /*-----------------------------------------------------------------------*/
@@ -685,10 +687,10 @@ ResetPGVariable(const char *name)
 
 
 /*-----------------------------------------------------------------------
-KSQO code will one day be unnecessary when the optimizer makes use of 
+KSQO code will one day be unnecessary when the optimizer makes use of
 indexes when multiple ORs are specified in the where clause.
 See optimizer/prep/prepkeyset.c for more on this.
-   [email protected]    6/16/98
+   [email protected]    6/16/98
 -----------------------------------------------------------------------*/
 static bool
 parse_ksqo(const char *value)
@@ -732,7 +734,7 @@ reset_ksqo()
 static bool
 parse_XactIsoLevel(const char *value)
 {
-   
+
    if (value == NULL)
    {
        reset_XactIsoLevel();
@@ -770,7 +772,7 @@ show_XactIsoLevel()
 static bool
 reset_XactIsoLevel()
 {
-   
+
    if (SerializableSnapshot != NULL)
    {
        elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query");
index 06de282f1993dc0da1aa6546ce8be2377801b153..1cea214613bddcb86f06b40fd0014f4bf1b33b7f 100644 (file)
@@ -5,11 +5,11 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- *  $Id: view.c,v 1.32 1999/02/13 23:15:12 momjian Exp $
+ * $Id: view.c,v 1.33 1999/05/25 16:08:28 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
-#include <stdio.h>         
+#include <stdio.h>
 #include <string.h>
 
 #include <postgres.h>
@@ -230,9 +230,9 @@ UpdateRangeTableOfViewParse(char *viewName, Query *viewParse)
     * table... CURRENT first, then NEW....
     */
    rt_entry1 = addRangeTableEntry(NULL, (char *) viewName, "*CURRENT*",
-                          FALSE, FALSE);
+                                  FALSE, FALSE);
    rt_entry2 = addRangeTableEntry(NULL, (char *) viewName, "*NEW*",
-                          FALSE, FALSE);
+                                  FALSE, FALSE);
    new_rt = lcons(rt_entry2, old_rt);
    new_rt = lcons(rt_entry1, new_rt);
 
index b06c700c4621bf5aa12cde3be861bdf5f19c3b08..645a11cd11ee1c5015fb1c0f289b08fbcb8bfb42 100644 (file)
@@ -6,15 +6,15 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  *  DESCRIPTION
- *     This code provides support for a tee node, which allows 
- *         multiple parent in a megaplan.
+ *     This code provides support for a tee node, which allows
+ *     multiple parent in a megaplan.
  *
  *  INTERFACE ROUTINES
  *     ExecTee
  *     ExecInitTee
  *     ExecEndTee
  *
- *  $Id: nodeTee.c,v 1.1 1999/03/23 16:50:49 momjian Exp $
+ * $Id: nodeTee.c,v 1.2 1999/05/25 16:08:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 bool
 ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
 {
-   TeeState    *teeState;
-   Plan            *outerPlan;
-   int             len;
+   TeeState   *teeState;
+   Plan       *outerPlan;
+   int         len;
    Relation    bufferRel;
    TupleDesc   tupType;
-   EState      *estate;
+   EState     *estate;
 
    /*
     * it is possible that the Tee has already been initialized since it
@@ -167,7 +167,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
        else
            bufferRel = heap_open(
                    heap_create_with_catalog(teeState->tee_bufferRelname,
-                                        tupType, RELKIND_RELATION, false));
+                                     tupType, RELKIND_RELATION, false));
    }
    else
    {
@@ -176,7 +176,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
                newoid());
        bufferRel = heap_open(
                    heap_create_with_catalog(teeState->tee_bufferRelname,
-                                        tupType, RELKIND_RELATION, false));
+                                     tupType, RELKIND_RELATION, false));
    }
 
    teeState->tee_bufferRel = bufferRel;
@@ -339,6 +339,7 @@ ExecTee(Tee *node, Plan *parent)
        slot = ExecProcNode(childNode, (Plan *) node);
        if (!TupIsNull(slot))
        {
+
            /*
             * heap_insert changes something...
             */
index 7b8bde8e1ba9c70e86e4ba1d8772988c1bef1c73..d4c60687a11915b708584175d92f67894054e82f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- *  $Id: execAmi.c,v 1.34 1999/05/10 00:45:05 momjian Exp $
+ * $Id: execAmi.c,v 1.35 1999/05/25 16:08:34 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,7 +24,7 @@
  *     ExecCreatR      function to create temporary relations
  *
  */
-#include <stdio.h>         
+#include <stdio.h>
 
 #include "postgres.h"
 
index 3565613bba92d771b20ef14be289968e8dc19a51..cab1b06624646a11e2a4724bb8caffe92a454200 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.83 1999/05/10 00:45:06 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.84 1999/05/25 16:08:36 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,26 +61,26 @@ void ExecCheckPerms(CmdType operation, int resultRelation, List *rangeTable,
 
 /* decls for local routines only used within this module */
 static TupleDesc InitPlan(CmdType operation,
-                       Query *parseTree,
-                       Plan *plan,
-                       EState *estate);
+        Query *parseTree,
+        Plan *plan,
+        EState *estate);
 static void EndPlan(Plan *plan,
-                       EState *estate);
+       EState *estate);
 static TupleTableSlot *ExecutePlan(EState *estate, Plan *plan,
-                       CmdType operation, 
-                       int offsetTuples,
-                       int numberTuples,
-                       ScanDirection direction,
-                       DestReceiver *destfunc);
+           CmdType operation,
+           int offsetTuples,
+           int numberTuples,
+           ScanDirection direction,
+           DestReceiver * destfunc);
 static void ExecRetrieve(TupleTableSlot *slot,
-                       DestReceiver *destfunc,
-                       EState *estate);
+            DestReceiver * destfunc,
+            EState *estate);
 static void ExecAppend(TupleTableSlot *slot, ItemPointer tupleid,
-                       EState *estate);
+          EState *estate);
 static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid,
-                       EState *estate);
+          EState *estate);
 static void ExecReplace(TupleTableSlot *slot, ItemPointer tupleid,
-                       EState *estate);
+           EState *estate);
 
 TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
 static TupleTableSlot *EvalPlanQualNext(EState *estate);
@@ -141,14 +141,14 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
        estate->es_snapshot = NULL;
    else
    {
-       estate->es_snapshot = (Snapshot)palloc(sizeof(SnapshotData));
+       estate->es_snapshot = (Snapshot) palloc(sizeof(SnapshotData));
        memcpy(estate->es_snapshot, QuerySnapshot, sizeof(SnapshotData));
        if (estate->es_snapshot->xcnt > 0)
        {
            estate->es_snapshot->xip = (TransactionId *)
-                   palloc(estate->es_snapshot->xcnt * sizeof(TransactionId));
+               palloc(estate->es_snapshot->xcnt * sizeof(TransactionId));
            memcpy(estate->es_snapshot->xip, QuerySnapshot->xip,
-                   estate->es_snapshot->xcnt * sizeof(TransactionId));
+                  estate->es_snapshot->xcnt * sizeof(TransactionId));
        }
    }
 
@@ -193,25 +193,25 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
  * ----------------------------------------------------------------
  */
 TupleTableSlot *
-ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, 
-                   Node *limoffset, Node *limcount)
+ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature,
+           Node *limoffset, Node *limcount)
 {
-   CmdType         operation;
-   Plan           *plan;
+   CmdType     operation;
+   Plan       *plan;
    TupleTableSlot *result;
-   CommandDest     dest;
-   DestReceiver   *destfunc;
-   int             offset = 0;
-   int             count = 0;
+   CommandDest dest;
+   DestReceiver *destfunc;
+   int         offset = 0;
+   int         count = 0;
 
    /*
-    *  sanity checks
+    * sanity checks
     */
    Assert(queryDesc != NULL);
 
    /*
-    *  extract information from the query descriptor
-    *  and the query feature.
+    * extract information from the query descriptor and the query
+    * feature.
     */
    operation = queryDesc->operation;
    plan = queryDesc->plantree;
@@ -221,34 +221,34 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature,
    estate->es_lastoid = InvalidOid;
 
    /*
-    *  FIXME: the dest setup function ought to be handed the tuple desc
-    *  for the tuples to be output, but I'm not quite sure how to get that
-    *  info at this point.  For now, passing NULL is OK because no existing
-    *  dest setup function actually uses the pointer.
+    * FIXME: the dest setup function ought to be handed the tuple desc
+    * for the tuples to be output, but I'm not quite sure how to get that
+    * info at this point.  For now, passing NULL is OK because no
+    * existing dest setup function actually uses the pointer.
     */
    (*destfunc->setup) (destfunc, (TupleDesc) NULL);
 
-    /*
-     *  if given get the offset of the LIMIT clause
-     */
-    if (limoffset != NULL)
-    {
-        Const       *coffset;
-        Param       *poffset;
-        ParamListInfo   paramLI;
-       int  i;
+   /*
+    * if given get the offset of the LIMIT clause
+    */
+   if (limoffset != NULL)
+   {
+       Const      *coffset;
+       Param      *poffset;
+       ParamListInfo paramLI;
+       int         i;
+
        switch (nodeTag(limoffset))
        {
            case T_Const:
-               coffset = (Const *)limoffset;
-               offset = (int)(coffset->constvalue);
+               coffset = (Const *) limoffset;
+               offset = (int) (coffset->constvalue);
                break;
+
            case T_Param:
-               poffset = (Param *)limoffset;
+               poffset = (Param *) limoffset;
                paramLI = estate->es_param_list_info;
+
                if (paramLI == NULL)
                    elog(ERROR, "parameter for limit offset not in executor state");
                for (i = 0; paramLI[i].kind != PARAM_INVALID; i++)
@@ -260,60 +260,60 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature,
                    elog(ERROR, "parameter for limit offset not in executor state");
                if (paramLI[i].isnull)
                    elog(ERROR, "limit offset cannot be NULL value");
-               offset = (int)(paramLI[i].value);
+               offset = (int) (paramLI[i].value);
+
                break;
+
            default:
                elog(ERROR, "unexpected node type %d as limit offset", nodeTag(limoffset));
        }
+
        if (offset < 0)
            elog(ERROR, "limit offset cannot be negative");
    }
+
    /*
-    *  if given get the count of the LIMIT clause
+    * if given get the count of the LIMIT clause
     */
    if (limcount != NULL)
    {
-       Const       *ccount;
-       Param       *pcount;
-       ParamListInfo   paramLI;
-       int     i;
-       switch (nodeTag(limcount))
-       {
-           case T_Const:
-               ccount = (Const *)limcount;
-               count = (int)(ccount->constvalue);
-               break;
-           case T_Param:
-               pcount = (Param *)limcount;
-               paramLI = estate->es_param_list_info;
-               if (paramLI == NULL)
-                   elog(ERROR, "parameter for limit count not in executor state");
-               for (i = 0; paramLI[i].kind != PARAM_INVALID; i++)
-               {
-                   if (paramLI[i].kind == PARAM_NUM && paramLI[i].id == pcount->paramid)
-                       break;
-               }
-               if (paramLI[i].kind == PARAM_INVALID)
-                   elog(ERROR, "parameter for limit count not in executor state");
-               if (paramLI[i].isnull)
-                   elog(ERROR, "limit count cannot be NULL value");
-               count = (int)(paramLI[i].value);
-               break;
-           default:
-               elog(ERROR, "unexpected node type %d as limit count", nodeTag(limcount));
-       }
-       if (count < 0)
-           elog(ERROR, "limit count cannot be negative");
+       Const      *ccount;
+       Param      *pcount;
+       ParamListInfo paramLI;
+       int         i;
+
+       switch (nodeTag(limcount))
+       {
+           case T_Const:
+               ccount = (Const *) limcount;
+               count = (int) (ccount->constvalue);
+               break;
+
+           case T_Param:
+               pcount = (Param *) limcount;
+               paramLI = estate->es_param_list_info;
+
+               if (paramLI == NULL)
+                   elog(ERROR, "parameter for limit count not in executor state");
+               for (i = 0; paramLI[i].kind != PARAM_INVALID; i++)
+               {
+                   if (paramLI[i].kind == PARAM_NUM && paramLI[i].id == pcount->paramid)
+                       break;
+               }
+               if (paramLI[i].kind == PARAM_INVALID)
+                   elog(ERROR, "parameter for limit count not in executor state");
+               if (paramLI[i].isnull)
+                   elog(ERROR, "limit count cannot be NULL value");
+               count = (int) (paramLI[i].value);
+
+               break;
+
+           default:
+               elog(ERROR, "unexpected node type %d as limit count", nodeTag(limcount));
+       }
+
+       if (count < 0)
+           elog(ERROR, "limit count cannot be negative");
    }
 
    switch (feature)
@@ -339,7 +339,7 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature,
            break;
 
            /*
-            *      retrieve next n "backward" tuples
+            * retrieve next n "backward" tuples
             */
        case EXEC_BACK:
            result = ExecutePlan(estate,
@@ -352,8 +352,8 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature,
            break;
 
            /*
-            *      return one tuple but don't "retrieve" it.
-            *      (this is used by the rule manager..) -cim 9/14/89
+            * return one tuple but don't "retrieve" it. (this is used by
+            * the rule manager..) -cim 9/14/89
             */
        case EXEC_RETONE:
            result = ExecutePlan(estate,
@@ -395,20 +395,25 @@ ExecutorEnd(QueryDesc *queryDesc, EState *estate)
    EndPlan(queryDesc->plantree, estate);
 
    /* XXX - clean up some more from ExecutorStart() - er1p */
-   if (NULL == estate->es_snapshot) {
-     /* nothing to free */
-   } else {
-     if (estate->es_snapshot->xcnt > 0) { 
-       pfree(estate->es_snapshot->xip);
-     }
-     pfree(estate->es_snapshot);
+   if (NULL == estate->es_snapshot)
+   {
+       /* nothing to free */
+   }
+   else
+   {
+       if (estate->es_snapshot->xcnt > 0)
+           pfree(estate->es_snapshot->xip);
+       pfree(estate->es_snapshot);
    }
 
-   if (NULL == estate->es_param_exec_vals) {
-     /* nothing to free */
-   } else {
-     pfree(estate->es_param_exec_vals);
-     estate->es_param_exec_vals = NULL;
+   if (NULL == estate->es_param_exec_vals)
+   {
+       /* nothing to free */
+   }
+   else
+   {
+       pfree(estate->es_param_exec_vals);
+       estate->es_param_exec_vals = NULL;
    }
 
    /* restore saved refcounts. */
@@ -509,15 +514,15 @@ ExecCheckPerms(CmdType operation,
    {
        foreach(lp, parseTree->rowMark)
        {
-           RowMark    *rm = lfirst(lp);
+           RowMark    *rm = lfirst(lp);
 
            if (!(rm->info & ROW_ACL_FOR_UPDATE))
                continue;
 
-           relid = ((RangeTblEntry *)nth(rm->rti - 1, rangeTable))->relid;
+           relid = ((RangeTblEntry *) nth(rm->rti - 1, rangeTable))->relid;
            htup = SearchSysCacheTuple(RELOID,
-                                  ObjectIdGetDatum(relid),
-                                  0, 0, 0);
+                                      ObjectIdGetDatum(relid),
+                                      0, 0, 0);
            if (!HeapTupleIsValid(htup))
                elog(ERROR, "ExecCheckPerms: bogus RT relid: %u", relid);
            StrNCpy(rname.data,
@@ -543,15 +548,15 @@ typedef struct execRowMark
    Relation    relation;
    Index       rti;
    char        resname[32];
-} execRowMark;
+}          execRowMark;
 
 typedef struct evalPlanQual
 {
-   Plan                   *plan;
-   Index                   rti;
-   EState                  estate;
-   struct evalPlanQual    *free;
-} evalPlanQual;
+   Plan       *plan;
+   Index       rti;
+   EState      estate;
+   struct evalPlanQual *free;
+}          evalPlanQual;
 
 /* ----------------------------------------------------------------
  *     InitPlan
@@ -563,15 +568,15 @@ typedef struct evalPlanQual
 static TupleDesc
&nbs