Ye-old pgindent run. Same 4-space tabs.
authorBruce Momjian <[email protected]>
Wed, 12 Apr 2000 17:17:23 +0000 (17:17 +0000)
committerBruce Momjian <[email protected]>
Wed, 12 Apr 2000 17:17:23 +0000 (17:17 +0000)
434 files changed:
contrib/array/array_iterator.c
contrib/array/array_iterator.h
contrib/bit/varbit.c
contrib/bit/varbit.h
contrib/bit/varbit_glue.c
contrib/bit/vartest.c
contrib/datetime/datetime_functions.c
contrib/datetime/datetime_functions.h
contrib/miscutil/misc_utils.c
contrib/miscutil/misc_utils.h
contrib/os2client/config.h
contrib/pgbench/pgbench.c
contrib/string/string_io.c
contrib/string/string_io.h
contrib/userlock/user_locks.c
contrib/userlock/user_locks.h
src/backend/access/common/heaptuple.c
src/backend/access/common/indextuple.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/hashscan.c
src/backend/access/hash/hashsearch.c
src/backend/access/heap/heapam.c
src/backend/access/heap/hio.c
src/backend/access/heap/tuptoaster.c
src/backend/access/index/genam.c
src/backend/access/index/indexam.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/nbtree/nbtutils.c
src/backend/access/rtree/rtree.c
src/backend/access/rtree/rtscan.c
src/backend/access/transam/rmgr.c
src/backend/access/transam/transam.c
src/backend/access/transam/varsup.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/bootstrap/bootstrap.c
src/backend/catalog/aclchk.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_aggregate.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_type.c
src/backend/commands/_deadcode/recipe.c
src/backend/commands/async.c
src/backend/commands/cluster.c
src/backend/commands/command.c
src/backend/commands/comment.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/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/nodeIndexscan.c
src/backend/executor/nodeSort.c
src/backend/executor/nodeSubplan.c
src/backend/executor/nodeTidscan.c
src/backend/executor/nodeUnique.c
src/backend/lib/dllist.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/hba.c
src/backend/libpq/portalbuf.c
src/backend/libpq/pqcomm.c
src/backend/libpq/pqformat.c
src/backend/libpq/pqpacket.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/freefuncs.c
src/backend/nodes/list.c
src/backend/nodes/makefuncs.c
src/backend/nodes/nodes.c
src/backend/nodes/outfuncs.c
src/backend/nodes/print.c
src/backend/nodes/read.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/geqo/geqo_eval.c
src/backend/optimizer/path/_deadcode/predmig.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/clausesel.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/orindxpath.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/path/tidpath.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/prepqual.c
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/tlist.c
src/backend/optimizer/util/var.c
src/backend/parser/analyze.c
src/backend/parser/keywords.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_node.c
src/backend/parser/parse_oper.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/parser/parser.c
src/backend/parser/scansup.c
src/backend/port/isinf.c
src/backend/port/qnx4/ipc.h
src/backend/port/qnx4/isnan.c
src/backend/port/qnx4/rint.c
src/backend/port/qnx4/sem.c
src/backend/port/qnx4/sem.h
src/backend/port/qnx4/shm.c
src/backend/port/qnx4/shm.h
src/backend/port/qnx4/tstrint.c
src/backend/port/qnx4/tstsem.c
src/backend/port/qnx4/tstshm.c
src/backend/postmaster/postmaster.c
src/backend/rewrite/locks.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/localbuf.c
src/backend/storage/file/buffile.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/ipc/spin.c
src/backend/storage/large_object/inv_api.c
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/proc.c
src/backend/storage/page/bufpage.c
src/backend/storage/smgr/md.c
src/backend/storage/smgr/smgr.c
src/backend/tcop/fastpath.c
src/backend/tcop/postgres.c
src/backend/tcop/utility.c
src/backend/tioga/tgRecipe.h
src/backend/utils/adt/acl.c
src/backend/utils/adt/cash.c
src/backend/utils/adt/date.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/float.c
src/backend/utils/adt/formatting.c
src/backend/utils/adt/geo_ops.c
src/backend/utils/adt/geo_selfuncs.c
src/backend/utils/adt/int.c
src/backend/utils/adt/int8.c
src/backend/utils/adt/like.c
src/backend/utils/adt/lztext.c
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/name.c
src/backend/utils/adt/network.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numutils.c
src/backend/utils/adt/oid.c
src/backend/utils/adt/oracle_compat.c
src/backend/utils/adt/pg_locale.c
src/backend/utils/adt/pg_lzcompress.c
src/backend/utils/adt/regproc.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/tid.c
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/varbit.c
src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/fcache.c
src/backend/utils/cache/inval.c
src/backend/utils/cache/lsyscache.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/fmgr/dfmgr.c
src/backend/utils/hash/dynahash.c
src/backend/utils/init/globals.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/mb/conv.c
src/backend/utils/mb/wchar.c
src/backend/utils/misc/database.c
src/backend/utils/misc/trace.c
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/oset.c
src/backend/utils/mmgr/portalmem.c
src/backend/utils/sort/logtape.c
src/backend/utils/sort/tuplesort.c
src/bin/pg_dump/common.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_id/pg_id.c
src/bin/pg_passwd/pg_passwd.c
src/bin/psql/command.c
src/bin/psql/command.h
src/bin/psql/common.c
src/bin/psql/common.h
src/bin/psql/copy.c
src/bin/psql/describe.c
src/bin/psql/describe.h
src/bin/psql/help.c
src/bin/psql/input.c
src/bin/psql/input.h
src/bin/psql/large_obj.c
src/bin/psql/mainloop.c
src/bin/psql/mainloop.h
src/bin/psql/print.c
src/bin/psql/print.h
src/bin/psql/prompt.c
src/bin/psql/prompt.h
src/bin/psql/settings.h
src/bin/psql/startup.c
src/bin/psql/stringutils.c
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.h
src/bin/psql/variables.c
src/bin/psql/variables.h
src/include/access/gist.h
src/include/access/heapam.h
src/include/access/htup.h
src/include/access/ibit.h
src/include/access/nbtree.h
src/include/access/rmgr.h
src/include/access/strat.h
src/include/access/tupdesc.h
src/include/access/tuptoaster.h
src/include/access/xlog.h
src/include/c.h
src/include/catalog/catalog.h
src/include/catalog/catversion.h
src/include/catalog/heap.h
src/include/catalog/index.h
src/include/catalog/indexing.h
src/include/catalog/pg_aggregate.h
src/include/catalog/pg_am.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_description.h
src/include/catalog/pg_inheritproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_statistic.h
src/include/catalog/pg_trigger.h
src/include/catalog/pg_type.h
src/include/catalog/pg_version.h
src/include/commands/command.h
src/include/commands/comment.h
src/include/commands/copy.h
src/include/commands/trigger.h
src/include/commands/user.h
src/include/commands/vacuum.h
src/include/executor/nodeGroup.h
src/include/executor/nodeSubplan.h
src/include/executor/nodeTidscan.h
src/include/lib/dllist.h
src/include/lib/stringinfo.h
src/include/libpq/hba.h
src/include/libpq/libpq-be.h
src/include/libpq/libpq.h
src/include/libpq/pqsignal.h
src/include/miscadmin.h
src/include/nodes/execnodes.h
src/include/nodes/makefuncs.h
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/nodes/pg_list.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/pathnode.h
src/include/optimizer/paths.h
src/include/optimizer/plancat.h
src/include/optimizer/planmain.h
src/include/optimizer/subselect.h
src/include/optimizer/tlist.h
src/include/parser/gramparse.h
src/include/parser/parse_agg.h
src/include/parser/parse_clause.h
src/include/parser/parse_coerce.h
src/include/parser/parse_func.h
src/include/parser/parse_node.h
src/include/parser/parse_relation.h
src/include/parser/parse_target.h
src/include/port/alpha.h
src/include/port/bsd.h
src/include/port/linux.h
src/include/port/netbsd.h
src/include/port/qnx4.h
src/include/postgres.h
src/include/rewrite/rewriteManip.h
src/include/storage/buf_internals.h
src/include/storage/buffile.h
src/include/storage/bufmgr.h
src/include/storage/fd.h
src/include/storage/itempos.h
src/include/storage/lock.h
src/include/storage/proc.h
src/include/storage/s_lock.h
src/include/storage/sinvaladt.h
src/include/storage/smgr.h
src/include/tcop/tcopprot.h
src/include/utils/acl.h
src/include/utils/array.h
src/include/utils/builtins.h
src/include/utils/catcache.h
src/include/utils/date.h
src/include/utils/datetime.h
src/include/utils/elog.h
src/include/utils/formatting.h
src/include/utils/geo_decls.h
src/include/utils/hsearch.h
src/include/utils/int8.h
src/include/utils/logtape.h
src/include/utils/lsyscache.h
src/include/utils/lztext.h
src/include/utils/memutils.h
src/include/utils/nabstime.h
src/include/utils/numeric.h
src/include/utils/pg_locale.h
src/include/utils/pg_lzcompress.h
src/include/utils/portal.h
src/include/utils/ps_status.h
src/include/utils/rel.h
src/include/utils/syscache.h
src/include/utils/temprel.h
src/include/utils/timestamp.h
src/include/utils/tqual.h
src/include/utils/trace.h
src/include/utils/tuplesort.h
src/include/utils/varbit.h
src/interfaces/cli/example1.c
src/interfaces/cli/example2.c
src/interfaces/cli/sqlcli.h
src/interfaces/ecpg/include/ecpgerrno.h
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/include/ecpgtype.h
src/interfaces/ecpg/include/sql3types.h
src/interfaces/ecpg/include/sqlca.h
src/interfaces/ecpg/lib/connect.c
src/interfaces/ecpg/lib/data.c
src/interfaces/ecpg/lib/descriptor.c
src/interfaces/ecpg/lib/error.c
src/interfaces/ecpg/lib/execute.c
src/interfaces/ecpg/lib/extern.h
src/interfaces/ecpg/lib/misc.c
src/interfaces/ecpg/lib/prepare.c
src/interfaces/ecpg/lib/typename.c
src/interfaces/ecpg/preproc/descriptor.c
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/ecpg_keywords.c
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/output.c
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/preproc/type.h
src/interfaces/ecpg/preproc/variable.c
src/interfaces/ecpg/test/header_test.h
src/interfaces/libpgeasy/halt.c
src/interfaces/libpgeasy/libpgeasy.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-lobj.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/pqexpbuffer.c
src/interfaces/libpq/pqexpbuffer.h
src/interfaces/libpq/win32.h
src/pl/plperl/eloglvl.c
src/pl/plperl/eloglvl.h
src/pl/plperl/plperl.c
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/tcl/pltcl.c
src/test/regress/regress.c
src/utils/version.c
src/win32/endian.h
src/win32/un.h

index cadda58a8f47973b84c836450a6c2664cbf71ebf..aa8697fb037f1dbbda196e543f710ae2a9c52912 100644 (file)
@@ -144,7 +144,7 @@ array_texteq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 25,     /* text */
                          (Oid) 67,     /* texteq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -153,7 +153,7 @@ array_all_texteq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 25,     /* text */
                          (Oid) 67,     /* texteq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -162,7 +162,7 @@ array_textregexeq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 25,     /* text */
                          (Oid) 1254,   /* textregexeq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -171,7 +171,7 @@ array_all_textregexeq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 25,     /* text */
                          (Oid) 1254,   /* textregexeq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -185,7 +185,7 @@ array_varchareq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1043,   /* varchar */
                          (Oid) 1070,   /* varchareq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -194,7 +194,7 @@ array_all_varchareq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1043,   /* varchar */
                          (Oid) 1070,   /* varchareq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -203,7 +203,7 @@ array_varcharregexeq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1043,   /* varchar */
                          (Oid) 1254,   /* textregexeq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -212,7 +212,7 @@ array_all_varcharregexeq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1043,   /* varchar */
                          (Oid) 1254,   /* textregexeq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -226,7 +226,7 @@ array_bpchareq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1042,   /* bpchar */
                          (Oid) 1048,   /* bpchareq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -235,7 +235,7 @@ array_all_bpchareq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1042,   /* bpchar */
                          (Oid) 1048,   /* bpchareq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -244,7 +244,7 @@ array_bpcharregexeq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1042,   /* bpchar */
                          (Oid) 1254,   /* textregexeq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -253,7 +253,7 @@ array_all_bpcharregexeq(ArrayType *array, char *value)
 {
    return array_iterator((Oid) 1042,   /* bpchar */
                          (Oid) 1254,   /* textregexeq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -266,7 +266,7 @@ array_int4eq(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 65,     /* int4eq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -275,7 +275,7 @@ array_all_int4eq(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 65,     /* int4eq */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -284,7 +284,7 @@ array_int4ne(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 144,    /* int4ne */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -293,7 +293,7 @@ array_all_int4ne(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 144,    /* int4ne */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -302,7 +302,7 @@ array_int4gt(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 147,    /* int4gt */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -311,7 +311,7 @@ array_all_int4gt(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 147,    /* int4gt */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -320,7 +320,7 @@ array_int4ge(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 150,    /* int4ge */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -329,7 +329,7 @@ array_all_int4ge(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 150,    /* int4ge */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -338,7 +338,7 @@ array_int4lt(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 66,     /* int4lt */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -347,7 +347,7 @@ array_all_int4lt(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 66,     /* int4lt */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -356,7 +356,7 @@ array_int4le(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 149,    /* int4le */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -365,7 +365,7 @@ array_all_int4le(ArrayType *array, int4 value)
 {
    return array_iterator((Oid) 23,     /* int4 */
                          (Oid) 149,    /* int4le */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -376,7 +376,7 @@ array_oideq(ArrayType *array, Oid value)
 {
    return array_iterator((Oid) 26,     /* oid */
                          (Oid) 184,    /* oideq */
-                         0,            /* logical or */
+                         0,    /* logical or */
                          array, (Datum) value);
 }
 
@@ -385,7 +385,7 @@ array_all_oidne(ArrayType *array, Oid value)
 {
    return array_iterator((Oid) 26,     /* int4 */
                          (Oid) 185,    /* oidne */
-                         1,            /* logical and */
+                         1,    /* logical and */
                          array, (Datum) value);
 }
 
@@ -393,8 +393,8 @@ array_all_oidne(ArrayType *array, Oid value)
 
 /*
  * 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 9a386abd2c7959dea151a0e2cfcb8408f56cbc5f..68da385c9a4b48895d5875420dbcae9b21cc5bad 100644 (file)
@@ -2,7 +2,7 @@
 #define ARRAY_ITERATOR_H
 
 static int32 array_iterator(Oid elemtype, Oid proc, int and,
-                           ArrayType *array, Datum value);
+              ArrayType *array, Datum value);
 
 int32      array_texteq(ArrayType *array, char *value);
 int32      array_all_texteq(ArrayType *array, char *value);
@@ -32,14 +32,15 @@ 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
 
 /*
  * 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 2a677ec6040121657f1e35a4dc24c51891674e21..20caaf9f7cb170dd84d46bd3a88cfd95bfb91b72 100644 (file)
@@ -4,7 +4,7 @@
  *   Functions for the built-in type bit() and varying bit().
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/contrib/bit/Attic/varbit.c,v 1.2 2000/04/03 20:56:40 momjian Exp $
+ *   $Header: /cvsroot/pgsql/contrib/bit/Attic/varbit.c,v 1.3 2000/04/12 17:14:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 /*#include "utils/builtins.h" */
 
 
-/* 
+/*
    Prefixes:
-     zp    -- zero-padded fixed length bit string
-     var   -- varying bit string
+    zp    -- zero-padded fixed length bit string
+    var   -- varying bit string
 
    attypmod -- contains the length of the bit string in bits, or for
-               varying bits the maximum length. 
+              varying bits the maximum length.
 
    The data structure contains the following elements:
-      header  -- length of the whole data structure (incl header)
-                 in bytes. (as with all varying length datatypes)
-      data section -- private data section for the bits data structures
-         bitlength -- lenght of the bit string in bits
+     header  -- length of the whole data structure (incl header)
+                in bytes. (as with all varying length datatypes)
+     data section -- private data section for the bits data structures
+        bitlength -- lenght of the bit string in bits
     bitdata   -- least significant byte first string
 */
 
  * zpbitin -
 
  *   converts a string to the internal representation of a bitstring.
- *        The length is determined by the number of bits required plus
- *        VARHDRSZ bytes or from atttypmod. 
- *   (XXX dummy is here because we pass typelem as the second argument 
- *        for array_in. copied this, no idea what it means??)
+ *       The length is determined by the number of bits required plus
+ *       VARHDRSZ bytes or from atttypmod.
+ *   (XXX dummy is here because we pass typelem as the second argument
+ *       for array_in. copied this, no idea what it means??)
  */
 bits8 *
-zpbitin(char *s, int dummy,  int32 atttypmod)
+zpbitin(char *s, int dummy, int32 atttypmod)
 {
-  bits8 *result;   /* the bits string that was read in   */ 
-  char  *sp;       /* pointer into the character string  */
-  bits8 *r;
-  int len,     /* Length of the whole data structure */
-    bitlen,        /* Number of bits in the bit string   */
-    slen;      /* Length of the input string         */
-  int bit_not_hex = 0;  /* 0 = hex string  1=bit string       */
-  int bc, ipad;
-  bits8 x = 0;
-
-
-  if (s == NULL)
-    return (bits8 *) NULL;
-
-  /* Check that the first character is a b or an x */
-  if (s[0]=='b' || s[0]=='B') 
-      bit_not_hex = 1;
-  else if (s[0]=='x' || s[0]=='X') 
-      bit_not_hex = 0;
-  else 
-    elog(ERROR, "zpbitin: %s is not a valid bitstring",s);
-
-  slen = strlen(s) - 1;
-  /* Determine bitlength from input string */
-  bitlen = slen;
-  if (!bit_not_hex)
-    bitlen *= 4;
-  
-  /* Sometimes atttypmod is not supplied. If it is supplied we need to make
-     sure that the bitstring fits. Note that the number of infered bits can
-     be larger than the number of actual bits needed, but only if we are 
-     reading a hex string and not by more than 3 bits, as a hex string gives 
-     and accurate length upto 4 bits */
-  if (atttypmod == -1)
-    atttypmod = bitlen;
-  else
-    if ((bitlen>atttypmod && bit_not_hex) || 
-   (bitlen>atttypmod+3 && !bit_not_hex))
-     elog(ERROR, "zpbitin: bit string of size %d cannot be written into bits(%d)",
-          bitlen,atttypmod);
-
-
-  len = VARBITDATALEN(atttypmod);
-
-  if (len > MaxAttrSize)
-    elog(ERROR, "zpbitin: length of bit() must be less than %ld",
-    (MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
-
-  result = (bits8 *) palloc(len);
-  /* set to 0 so that *r is always initialised and strin is zero-padded */
-  memset(result, 0, len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = atttypmod;
-
-  /* We need to read the bitstring from the end, as we store it least 
-     significant byte first. s points to the byte before the beginning
-     of the bitstring */
-  sp = s+1;
-  r = VARBITS(result);
-  if (bit_not_hex) 
-    {
-      /* Parse the bit representation of the string */
-      /* We know it fits, as bitlen was compared to atttypmod */
-      x = BITHIGH;
-      for (bc = 0; sp != s+slen+1; sp++, bc++)
+   bits8      *result;         /* the bits string that was read in   */
+   char       *sp;             /* pointer into the character string  */
+   bits8      *r;
+   int         len,            /* Length of the whole data structure */
+               bitlen,         /* Number of bits in the bit string   */
+               slen;           /* Length of the input string         */
+   int         bit_not_hex = 0;/* 0 = hex string  1=bit string       */
+   int         bc,
+               ipad;
+   bits8       x = 0;
+
+
+   if (s == NULL)
+       return (bits8 *) NULL;
+
+   /* Check that the first character is a b or an x */
+   if (s[0] == 'b' || s[0] == 'B')
+       bit_not_hex = 1;
+   else if (s[0] == 'x' || s[0] == 'X')
+       bit_not_hex = 0;
+   else
+       elog(ERROR, "zpbitin: %s is not a valid bitstring", s);
+
+   slen = strlen(s) - 1;
+   /* Determine bitlength from input string */
+   bitlen = slen;
+   if (!bit_not_hex)
+       bitlen *= 4;
+
+   /*
+    * Sometimes atttypmod is not supplied. If it is supplied we need to
+    * make sure that the bitstring fits. Note that the number of infered
+    * bits can be larger than the number of actual bits needed, but only
+    * if we are reading a hex string and not by more than 3 bits, as a
+    * hex string gives and accurate length upto 4 bits
+    */
+   if (atttypmod == -1)
+       atttypmod = bitlen;
+   else if ((bitlen > atttypmod && bit_not_hex) ||
+            (bitlen > atttypmod + 3 && !bit_not_hex))
+       elog(ERROR, "zpbitin: bit string of size %d cannot be written into bits(%d)",
+            bitlen, atttypmod);
+
+
+   len = VARBITDATALEN(atttypmod);
+
+   if (len > MaxAttrSize)
+       elog(ERROR, "zpbitin: length of bit() must be less than %ld",
+            (MaxAttrSize - VARHDRSZ - VARBITHDRSZ) * BITSPERBYTE);
+
+   result = (bits8 *) palloc(len);
+   /* set to 0 so that *r is always initialised and strin is zero-padded */
+   memset(result, 0, len);
+   VARSIZE(result) = len;
+   VARBITLEN(result) = atttypmod;
+
+   /*
+    * We need to read the bitstring from the end, as we store it least
+    * significant byte first. s points to the byte before the beginning
+    * of the bitstring
+    */
+   sp = s + 1;
+   r = VARBITS(result);
+   if (bit_not_hex)
+   {
+       /* Parse the bit representation of the string */
+       /* We know it fits, as bitlen was compared to atttypmod */
+       x = BITHIGH;
+       for (bc = 0; sp != s + slen + 1; sp++, bc++)
+       {
+           if (*sp == '1')
+               *r |= x;
+           if (bc == 7)
+           {
+               bc = 0;
+               x = BITHIGH;
+               r++;
+           }
+           else
+               x >>= 1;
+       }
+   }
+   else
    {
-     if (*sp=='1')
-       *r |= x;
-     if (bc==7) {
-       bc = 0;
-       x = BITHIGH;
-       r++;
-     } else 
-       x >>= 1;
+       /* Parse the hex representation of the string */
+       for (bc = 0; sp != s + slen + 1; sp++)
+       {
+           if (*sp >= '0' && *sp <= '9')
+               x = (bits8) (*sp - '0');
+           else if (*sp >= 'A' && *sp <= 'F')
+               x = (bits8) (*sp - 'A') + 10;
+           else if (*sp >= 'a' && *sp <= 'f')
+               x = (bits8) (*sp - 'a') + 10;
+           else
+               elog(ERROR, "Cannot parse %c as a hex digit", *sp);
+           if (bc)
+           {
+               bc = 0;
+               *r++ |= x;
+           }
+           else
+           {
+               bc++;
+               *r = x << 4;
+           }
+       }
    }
-     }
-  else 
-    {
-      /* Parse the hex representation of the string */
-      for (bc = 0; sp != s+slen+1; sp++)
+
+   if (bitlen > atttypmod)
    {
-     if (*sp>='0' && *sp<='9') 
-       x = (bits8) (*sp - '0');
-     else if (*sp>='A' && *sp<='F') 
-       x = (bits8) (*sp - 'A') + 10;
-     else if (*sp>='a' && *sp<='f') 
-       x = (bits8) (*sp - 'a') + 10;
-     else 
-       elog(ERROR,"Cannot parse %c as a hex digit",*sp);
-     if (bc) {
-       bc = 0;
-       *r++ |= x;
-     } else {
-       bc++;
-       *r = x<<4;
-     }
+       /* Check that this fitted */
+       r = (bits8 *) (result + len - 1);
+       ipad = VARBITPAD(result);
+
+       /*
+        * The bottom ipad bits of the byte pointed to by r need to be
+        * zero
+        */
+
+       /*
+        * printf("Byte %X  shift %X %d\n",*r,(*r << (8-ipad)) & BITMASK,
+        * (*r << (8-ipad)) & BITMASK > 0);
+        */
+       if (((*r << (BITSPERBYTE - ipad)) & BITMASK) > 0)
+           elog(ERROR, "zpbitin: bit string too large for bit(%d) data type",
+                atttypmod);
    }
-    }
-
-  if (bitlen > atttypmod) {
-    /* Check that this fitted */
-    r = (bits8 *) (result + len - 1);
-    ipad = VARBITPAD(result);
-    /* The bottom ipad bits of the byte pointed to by r need to be zero */
-    /*    printf("Byte %X  shift %X %d\n",*r,(*r << (8-ipad)) & BITMASK,
-      (*r << (8-ipad)) & BITMASK > 0);
-    */
-    if (((*r << (BITSPERBYTE-ipad)) & BITMASK) > 0)
-      elog(ERROR, "zpbitin: bit string too large for bit(%d) data type",
-      atttypmod);
-  }
-
-  return result;
+
+   return result;
 }
 
 /* zpbitout -
- *    for the time being we print everything as hex strings, as this is likely 
- *    to be more compact than bit strings, and consequently much more efficient
- *    for long strings
+ *   for the time being we print everything as hex strings, as this is likely
+ *   to be more compact than bit strings, and consequently much more efficient
+ *   for long strings
  */
 char *
 zpbitout(bits8 *s)
 {
-  char    *result, *r;
-  bits8    *sp;
-  int     i, len, bitlen;
-  
-  if (s == NULL)
-    {
-      result = (char *) palloc(2);
-      result[0] = '-';
-      result[1] = '\0';
-    }
-  else
-    {
-      bitlen = VARBITLEN(s);
-      len = bitlen/4 + (bitlen%4>0 ? 1 : 0);
-      result = (char *) palloc(len + 4);
-      sp = VARBITS(s);
-      r = result;
-      *r++ = 'X';
-      *r++ = '\'';
-      /* we cheat by knowing that we store full bytes zero padded */
-      for (i=0; i<len; i+=2, sp++) {
-   *r++ = HEXDIG((*sp)>>4);
-   *r++ = HEXDIG((*sp) & 0xF);
-      }
-      /* Go back one step if we printed a hex number that was not part
-    of the bitstring anymore */
-      if (i==len+1)
-   r--;
-      *r++ = '\'';
-      *r = '\0';
-    }
-  return result;
+   char       *result,
+              *r;
+   bits8      *sp;
+   int         i,
+               len,
+               bitlen;
+
+   if (s == NULL)
+   {
+       result = (char *) palloc(2);
+       result[0] = '-';
+       result[1] = '\0';
+   }
+   else
+   {
+       bitlen = VARBITLEN(s);
+       len = bitlen / 4 + (bitlen % 4 > 0 ? 1 : 0);
+       result = (char *) palloc(len + 4);
+       sp = VARBITS(s);
+       r = result;
+       *r++ = 'X';
+       *r++ = '\'';
+       /* we cheat by knowing that we store full bytes zero padded */
+       for (i = 0; i < len; i += 2, sp++)
+       {
+           *r++ = HEXDIG((*sp) >> 4);
+           *r++ = HEXDIG((*sp) & 0xF);
+       }
+
+       /*
+        * Go back one step if we printed a hex number that was not part
+        * of the bitstring anymore
+        */
+       if (i == len + 1)
+           r--;
+       *r++ = '\'';
+       *r = '\0';
+   }
+   return result;
 }
 
 /* zpbitsout -
- *    Prints the string a bits
+ *   Prints the string a bits
  */
 char *
 zpbitsout(bits8 *s)
 {
-  char    *result, *r;
-  bits8    *sp;
-  bits8    x;
-  int     i, k, len;
-  
-  if (s == NULL)
-    {
-      result = (char *) palloc(2);
-      result[0] = '-';
-      result[1] = '\0';
-    }
-  else
-    {
-      len = VARBITLEN(s);
-      result = (char *) palloc(len + 4);
-      sp = VARBITS(s);
-      r = result;
-      *r++ = 'B';
-      *r++ = '\'';
-      for (i=0; i<len-BITSPERBYTE; i+=BITSPERBYTE, sp++) {
-   x = *sp;
-   for (k=0; k<BITSPERBYTE; k++) 
-     {
-       *r++ = (x & BITHIGH) ? '1' : '0';
-       x <<= 1;
-     }
-      }
-      x = *sp;
-      for (k=i; k<len; k++)
+   char       *result,
+              *r;
+   bits8      *sp;
+   bits8       x;
+   int         i,
+               k,
+               len;
+
+   if (s == NULL)
    {
-     *r++ = (x & BITHIGH) ? '1' : '0';
-     x <<= 1;
+       result = (char *) palloc(2);
+       result[0] = '-';
+       result[1] = '\0';
    }
-      *r++ = '\'';
-      *r = '\0';
-    }
-  return result;
+   else
+   {
+       len = VARBITLEN(s);
+       result = (char *) palloc(len + 4);
+       sp = VARBITS(s);
+       r = result;
+       *r++ = 'B';
+       *r++ = '\'';
+       for (i = 0; i < len - BITSPERBYTE; i += BITSPERBYTE, sp++)
+       {
+           x = *sp;
+           for (k = 0; k < BITSPERBYTE; k++)
+           {
+               *r++ = (x & BITHIGH) ? '1' : '0';
+               x <<= 1;
+           }
+       }
+       x = *sp;
+       for (k = i; k < len; k++)
+       {
+           *r++ = (x & BITHIGH) ? '1' : '0';
+           x <<= 1;
+       }
+       *r++ = '\'';
+       *r = '\0';
+   }
+   return result;
 }
 
 
@@ -250,118 +277,133 @@ zpbitsout(bits8 *s)
  *   converts a string to the internal representation of a bitstring.
 */
 bits8 *
-varbitin(char *s, int dummy,  int32 atttypmod)
+varbitin(char *s, int dummy, int32 atttypmod)
 {
-  bits8 *result;   /* The resulting bit string           */
-  char *sp;        /* pointer into the character string  */
-  bits8 *r;
-  int len,     /* Length of the whole data structure */
-    bitlen,        /* Number of bits in the bit string   */
-    slen;      /* Length of the input string         */
-  int bit_not_hex = 0;
-  int bc, ipad;
-  bits8 x = 0;
-
-
-  if (s == NULL)
-    return (bits8 *) NULL;
-
-  /* Check that the first character is a b or an x */
-  if (s[0]=='b' || s[0]=='B') 
-      bit_not_hex = 1;
-  else if (s[0]=='x' || s[0]=='X') 
-      bit_not_hex = 0;
-  else 
-    elog(ERROR, "zpbitin: %s is not a valid bitstring",s);
-
-  slen = strlen(s) - 1;
-  /* Determine bitlength from input string */
-  bitlen = slen;
-  if (!bit_not_hex)
-    bitlen *= 4;
-  
-  /* Sometimes atttypmod is not supplied. If it is supplied we need to make
-     sure that the bitstring fits. Note that the number of infered bits can
-     be larger than the number of actual bits needed, but only if we are 
-     reading a hex string and not by more than 3 bits, as a hex string gives 
-     and accurate length upto 4 bits */
-  if (atttypmod > -1)
-    if ((bitlen>atttypmod && bit_not_hex) || 
-   (bitlen>atttypmod+3 && !bit_not_hex))
-     elog(ERROR, "varbitin: bit string of size %d cannot be written into varying bits(%d)",
-          bitlen,atttypmod);
-
-
-  len = VARBITDATALEN(bitlen);
-
-  if (len > MaxAttrSize)
-    elog(ERROR, "varbitin: length of bit() must be less than %ld",
-    (MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
-
-  result = (bits8 *) palloc(len);
-  /* set to 0 so that *r is always initialised and strin is zero-padded */
-  memset(result, 0, len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = bitlen;
-
-  /* We need to read the bitstring from the end, as we store it least 
-     significant byte first. s points to the byte before the beginning
-     of the bitstring */
-  sp = s + 1;
-  r = VARBITS(result);
-  if (bit_not_hex) 
-    {
-      /* Parse the bit representation of the string */
-      x = BITHIGH;
-      for (bc = 0; sp != s+slen+1; sp++, bc++)
+   bits8      *result;         /* The resulting bit string           */
+   char       *sp;             /* pointer into the character string  */
+   bits8      *r;
+   int         len,            /* Length of the whole data structure */
+               bitlen,         /* Number of bits in the bit string   */
+               slen;           /* Length of the input string         */
+   int         bit_not_hex = 0;
+   int         bc,
+               ipad;
+   bits8       x = 0;
+
+
+   if (s == NULL)
+       return (bits8 *) NULL;
+
+   /* Check that the first character is a b or an x */
+   if (s[0] == 'b' || s[0] == 'B')
+       bit_not_hex = 1;
+   else if (s[0] == 'x' || s[0] == 'X')
+       bit_not_hex = 0;
+   else
+       elog(ERROR, "zpbitin: %s is not a valid bitstring", s);
+
+   slen = strlen(s) - 1;
+   /* Determine bitlength from input string */
+   bitlen = slen;
+   if (!bit_not_hex)
+       bitlen *= 4;
+
+   /*
+    * Sometimes atttypmod is not supplied. If it is supplied we need to
+    * make sure that the bitstring fits. Note that the number of infered
+    * bits can be larger than the number of actual bits needed, but only
+    * if we are reading a hex string and not by more than 3 bits, as a
+    * hex string gives and accurate length upto 4 bits
+    */
+   if (atttypmod > -1)
+       if ((bitlen > atttypmod && bit_not_hex) ||
+           (bitlen > atttypmod + 3 && !bit_not_hex))
+           elog(ERROR, "varbitin: bit string of size %d cannot be written into varying bits(%d)",
+                bitlen, atttypmod);
+
+
+   len = VARBITDATALEN(bitlen);
+
+   if (len > MaxAttrSize)
+       elog(ERROR, "varbitin: length of bit() must be less than %ld",
+            (MaxAttrSize - VARHDRSZ - VARBITHDRSZ) * BITSPERBYTE);
+
+   result = (bits8 *) palloc(len);
+   /* set to 0 so that *r is always initialised and strin is zero-padded */
+   memset(result, 0, len);
+   VARSIZE(result) = len;
+   VARBITLEN(result) = bitlen;
+
+   /*
+    * We need to read the bitstring from the end, as we store it least
+    * significant byte first. s points to the byte before the beginning
+    * of the bitstring
+    */
+   sp = s + 1;
+   r = VARBITS(result);
+   if (bit_not_hex)
+   {
+       /* Parse the bit representation of the string */
+       x = BITHIGH;
+       for (bc = 0; sp != s + slen + 1; sp++, bc++)
+       {
+           if (*sp == '1')
+               *r |= x;
+           if (bc == 7)
+           {
+               bc = 0;
+               x = BITHIGH;
+               r++;
+           }
+           else
+               x >>= 1;
+       }
+   }
+   else
    {
-     if (*sp=='1')
-       *r |= x;
-     if (bc==7) {
-       bc = 0;
-       x = BITHIGH;
-       r++;
-     } else 
-       x >>= 1;
+       for (bc = 0; sp != s + slen + 1; sp++)
+       {
+           if (*sp >= '0' && *sp <= '9')
+               x = (bits8) (*sp - '0');
+           else if (*sp >= 'A' && *sp <= 'F')
+               x = (bits8) (*sp - 'A') + 10;
+           else if (*sp >= 'a' && *sp <= 'f')
+               x = (bits8) (*sp - 'a') + 10;
+           else
+               elog(ERROR, "Cannot parse %c as a hex digit", *sp);
+           if (bc)
+           {
+               bc = 0;
+               *r++ |= x;
+           }
+           else
+           {
+               bc++;
+               *r = x << 4;
+           }
+       }
    }
-     }
-  else 
-    {
-      for (bc = 0; sp != s+slen+1; sp++)
+
+   if (bitlen > atttypmod)
    {
-     if (*sp>='0' && *sp<='9') 
-       x = (bits8) (*sp - '0');
-     else if (*sp>='A' && *sp<='F') 
-       x = (bits8) (*sp - 'A') + 10;
-     else if (*sp>='a' && *sp<='f') 
-       x = (bits8) (*sp - 'a') + 10;
-     else 
-       elog(ERROR,"Cannot parse %c as a hex digit",*sp);
-     if (bc) {
-       bc = 0;
-       *r++ |= x;
-     } else {
-       bc++;
-       *r = x<<4;
-     }
+       /* Check that this fitted */
+       r = (bits8 *) (result + len - 1);
+       ipad = VARBITPAD(result);
+
+       /*
+        * The bottom ipad bits of the byte pointed to by r need to be
+        * zero
+        */
+       if (((*r << (BITSPERBYTE - ipad)) & BITMASK) > 0)
+           elog(ERROR, "varbitin: bit string too large for varying bit(%d) data type",
+                atttypmod);
    }
-    }
-
-  if (bitlen > atttypmod) {
-    /* Check that this fitted */
-    r = (bits8 *) (result + len - 1);
-    ipad = VARBITPAD(result);
-    /* The bottom ipad bits of the byte pointed to by r need to be zero */
-    if (((*r << (BITSPERBYTE-ipad)) & BITMASK) > 0)
-      elog(ERROR, "varbitin: bit string too large for varying bit(%d) data type",
-      atttypmod);
-  }
-
-  return result;
+
+   return result;
 }
 
 /*
-  the zpbitout routines are fine for varying bits as well 
+  the zpbitout routines are fine for varying bits as well
 */
 
 
@@ -369,228 +411,244 @@ varbitin(char *s, int dummy,  int32 atttypmod)
  * Comparison operators
  *
  * We only need one set of comparison operators for bitstrings, as the lengths
- * are stored in the same way for zero-padded and varying bit strings. 
+ * are stored in the same way for zero-padded and varying bit strings.
  *
- * Note that the standard is not unambiguous about the comparison between 
+ * Note that the standard is not unambiguous about the comparison between
  * zero-padded bit strings and varying bitstrings. If the same value is written
- * into a zero padded bitstring as into a varying bitstring, but the zero 
- * padded bitstring has greater length, it will be bigger. 
+ * into a zero padded bitstring as into a varying bitstring, but the zero
+ * padded bitstring has greater length, it will be bigger.
  *
  * Zeros from the beginning of a bitstring cannot simply be ignored, as they
  * may be part of a bit string and may be significant.
  */
 
 bool
-biteq (bits8 *arg1, bits8 *arg2)
+biteq(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1,
-    bitlen2;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-  if (bitlen1 != bitlen2)
-    return (bool) 0;
-  
-  /* bit strings are always stored in a full number of bytes */
-  return memcmp((void *)VARBITS(arg1),(void *)VARBITS(arg2),
-       VARBITBYTES(arg1)) == 0;
+   int         bitlen1,
+               bitlen2;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return (bool) 0;
+   bitlen1 = VARBITLEN(arg1);
+   bitlen2 = VARBITLEN(arg2);
+   if (bitlen1 != bitlen2)
+       return (bool) 0;
+
+   /* bit strings are always stored in a full number of bytes */
+   return memcmp((void *) VARBITS(arg1), (void *) VARBITS(arg2),
+                 VARBITBYTES(arg1)) == 0;
 }
 
 bool
-bitne (bits8 *arg1, bits8 *arg2)
+bitne(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1,
-    bitlen2;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-  if (bitlen1 != bitlen2)
-    return (bool) 1;
-  
-  /* bit strings are always stored in a full number of bytes */
-  return memcmp((void *)VARBITS(arg1),(void *)VARBITS(arg2),
-       VARBITBYTES(arg1)) != 0;
+   int         bitlen1,
+               bitlen2;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return (bool) 0;
+   bitlen1 = VARBITLEN(arg1);
+   bitlen2 = VARBITLEN(arg2);
+   if (bitlen1 != bitlen2)
+       return (bool) 1;
+
+   /* bit strings are always stored in a full number of bytes */
+   return memcmp((void *) VARBITS(arg1), (void *) VARBITS(arg2),
+                 VARBITBYTES(arg1)) != 0;
 }
 
 /* bitcmp
- * 
+ *
  * Compares two bitstrings and returns -1, 0, 1 depending on whether the first
  * string is smaller, equal, or bigger than the second. All bits are considered
  * and additional zero bits may make one string smaller/larger than the other,
  * even if their zero-padded values would be the same.
- *   Anything is equal to undefined.
+ *  Anything is equal to undefined.
  */
-int 
-bitcmp (bits8 *arg1, bits8 *arg2)
+int
+bitcmp(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1, bytelen1,
-    bitlen2, bytelen2;
-  int cmp;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-  bytelen1 = VARBITBYTES(arg1);  
-  bytelen2 = VARBITBYTES(arg2);
-  
-  cmp = memcmp(VARBITS(arg1),VARBITS(arg2),Min(bytelen1,bytelen2));
-  if (cmp==0) {
-    bitlen1 = VARBITLEN(arg1);
-    bitlen2 = VARBITLEN(arg2);
-    if (bitlen1 != bitlen2) 
-      return bitlen1 < bitlen2 ? -1 : 1;
-  }
-  return cmp;
+   int         bitlen1,
+               bytelen1,
+               bitlen2,
+               bytelen2;
+   int         cmp;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return (bool) 0;
+   bytelen1 = VARBITBYTES(arg1);
+   bytelen2 = VARBITBYTES(arg2);
+
+   cmp = memcmp(VARBITS(arg1), VARBITS(arg2), Min(bytelen1, bytelen2));
+   if (cmp == 0)
+   {
+       bitlen1 = VARBITLEN(arg1);
+       bitlen2 = VARBITLEN(arg2);
+       if (bitlen1 != bitlen2)
+           return bitlen1 < bitlen2 ? -1 : 1;
+   }
+   return cmp;
 }
 
 bool
-bitlt (bits8 *arg1, bits8 *arg2)
+bitlt(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) == -1);
+   return (bool) (bitcmp(arg1, arg2) == -1);
 }
 
 bool
-bitle (bits8 *arg1, bits8 *arg2)
+bitle(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) <= 0);
+   return (bool) (bitcmp(arg1, arg2) <= 0);
 }
 
 bool
-bitge (bits8 *arg1, bits8 *arg2)
+bitge(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) >= 0);
+   return (bool) (bitcmp(arg1, arg2) >= 0);
 }
 
 bool
-bitgt (bits8 *arg1, bits8 *arg2)
+bitgt(bits8 *arg1, bits8 *arg2)
 {
-  return (bool) (bitcmp(arg1,arg2) == 1);
+   return (bool) (bitcmp(arg1, arg2) == 1);
 }
 
 /* bitcat
  * Concatenation of bit strings
  */
 bits8 *
-bitcat (bits8 *arg1, bits8 *arg2)
+bitcat(bits8 *arg1, bits8 *arg2)
 {
-  int bitlen1, bitlen2, bytelen, bit1pad, bit2shift;
-  bits8 *result;
-  bits8 *pr, *pa;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return NULL;
-
-  bitlen1 = VARBITLEN(arg1);
-  bitlen2 = VARBITLEN(arg2);
-
-  bytelen = VARBITDATALEN(bitlen1+bitlen2);
-  
-  result = (bits8 *) palloc(bytelen*sizeof(bits8));
-  VARSIZE(result) = bytelen;
-  VARBITLEN(result) = bitlen1+bitlen2;
-  printf("%d %d %d \n",VARBITBYTES(arg1),VARBITLEN(arg1),VARBITPAD(arg1));
-  /* Copy the first bitstring in */
-  memcpy(VARBITS(result),VARBITS(arg1),VARBITBYTES(arg1));
-  /* Copy the second bit string */
-  bit1pad = VARBITPAD(arg1);
-  if (bit1pad==0) 
-    {
-      memcpy(VARBITS(result)+VARBITBYTES(arg1),VARBITS(arg2),
-        VARBITBYTES(arg2));
-    }
-  else if (bitlen2>0)
-    {
-      /* We need to shift all the results to fit */
-      bit2shift = BITSPERBYTE - bit1pad;
-      pa = VARBITS(arg2);
-      pr = VARBITS(result)+VARBITBYTES(arg1)-1;
-      for ( ; pa < VARBITEND(arg2); pa++) {
-   *pr |= ((*pa >> bit2shift) & BITMASK);
-   pr++;
-   if (pr < VARBITEND(result))
-     *pr = (*pa << bit1pad) & BITMASK;
-      }
-    }
-
-  return result;
+   int         bitlen1,
+               bitlen2,
+               bytelen,
+               bit1pad,
+               bit2shift;
+   bits8      *result;
+   bits8      *pr,
+              *pa;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return NULL;
+
+   bitlen1 = VARBITLEN(arg1);
+   bitlen2 = VARBITLEN(arg2);
+
+   bytelen = VARBITDATALEN(bitlen1 + bitlen2);
+
+   result = (bits8 *) palloc(bytelen * sizeof(bits8));
+   VARSIZE(result) = bytelen;
+   VARBITLEN(result) = bitlen1 + bitlen2;
+   printf("%d %d %d \n", VARBITBYTES(arg1), VARBITLEN(arg1), VARBITPAD(arg1));
+   /* Copy the first bitstring in */
+   memcpy(VARBITS(result), VARBITS(arg1), VARBITBYTES(arg1));
+   /* Copy the second bit string */
+   bit1pad = VARBITPAD(arg1);
+   if (bit1pad == 0)
+   {
+       memcpy(VARBITS(result) + VARBITBYTES(arg1), VARBITS(arg2),
+              VARBITBYTES(arg2));
+   }
+   else if (bitlen2 > 0)
+   {
+       /* We need to shift all the results to fit */
+       bit2shift = BITSPERBYTE - bit1pad;
+       pa = VARBITS(arg2);
+       pr = VARBITS(result) + VARBITBYTES(arg1) - 1;
+       for (; pa < VARBITEND(arg2); pa++)
+       {
+           *pr |= ((*pa >> bit2shift) & BITMASK);
+           pr++;
+           if (pr < VARBITEND(result))
+               *pr = (*pa << bit1pad) & BITMASK;
+       }
+   }
+
+   return result;
 }
 
 /* bitsubstr
- * retrieve a substring from the bit string. 
+ * retrieve a substring from the bit string.
  * Note, s is 1-based.
  * SQL draft 6.10 9)
  */
-bits8 * 
-bitsubstr (bits8 *arg, int32 s, int32 l)
+bits8 *
+bitsubstr(bits8 *arg, int32 s, int32 l)
 {
-  int bitlen,
-    rbitlen,
-    len,
-    ipad = 0,
-    ishift,
-    i;
-  int e, s1, e1;
-  bits8 * result;
-  bits8 mask, *r, *ps;
-
-  if (!PointerIsValid(arg))
-    return NULL;
-
-  bitlen = VARBITLEN(arg);
-  e = s+l;
-  s1 = Max(s,1);
-  e1 = Min(e,bitlen+1);
-  if (s1>bitlen || e1<1) 
-    {
-      /* Need to return a null string */
-      len = VARBITDATALEN(0);
-      result = (bits8 *) palloc(len);
-      VARBITLEN(result) = 0;
-      VARSIZE(result) = len;
-    } 
-  else 
-    {
-      /* OK, we've got a true substring starting at position s1-1 and 
-    ending at position e1-1 */
-      rbitlen = e1-s1;
-      len = VARBITDATALEN(rbitlen);
-      result = (bits8 *) palloc(len);
-      VARBITLEN(result) = rbitlen;
-      VARSIZE(result) = len;
-      len -= VARHDRSZ + VARBITHDRSZ;
-      /* Are we copying from a byte boundary? */
-      if ((s1-1)%BITSPERBYTE==0) 
+   int         bitlen,
+               rbitlen,
+               len,
+               ipad = 0,
+               ishift,
+               i;
+   int         e,
+               s1,
+               e1;
+   bits8      *result;
+   bits8       mask,
+              *r,
+              *ps;
+
+   if (!PointerIsValid(arg))
+       return NULL;
+
+   bitlen = VARBITLEN(arg);
+   e = s + l;
+   s1 = Max(s, 1);
+   e1 = Min(e, bitlen + 1);
+   if (s1 > bitlen || e1 < 1)
    {
-     /* Yep, we are copying bytes */
-     memcpy(VARBITS(result),VARBITS(arg)+(s1-1)/BITSPERBYTE,len);
-   } 
-      else 
-   {
-     /* Figure out how much we need to shift the sequence by */
-     ishift = (s1-1)%BITSPERBYTE;
-     r = VARBITS(result);
-     ps = VARBITS(arg) + (s1-1)/BITSPERBYTE;
-     for (i=0; i<len; i++) 
-       {
-         *r = (*ps <<ishift) & BITMASK;
-         if ((++ps) < VARBITEND(arg))
-       *r |= *ps >>(BITSPERBYTE-ishift);
-         r++;
-       }
+       /* Need to return a null string */
+       len = VARBITDATALEN(0);
+       result = (bits8 *) palloc(len);
+       VARBITLEN(result) = 0;
+       VARSIZE(result) = len;
    }
-      /* Do we need to pad at the end? */
-      ipad = VARBITPAD(result);
-      if (ipad > 0) 
+   else
    {
-     mask = BITMASK << ipad;
-     *(VARBITS(result) + len - 1) &= mask;
+
+       /*
+        * OK, we've got a true substring starting at position s1-1 and
+        * ending at position e1-1
+        */
+       rbitlen = e1 - s1;
+       len = VARBITDATALEN(rbitlen);
+       result = (bits8 *) palloc(len);
+       VARBITLEN(result) = rbitlen;
+       VARSIZE(result) = len;
+       len -= VARHDRSZ + VARBITHDRSZ;
+       /* Are we copying from a byte boundary? */
+       if ((s1 - 1) % BITSPERBYTE == 0)
+       {
+           /* Yep, we are copying bytes */
+           memcpy(VARBITS(result), VARBITS(arg) + (s1 - 1) / BITSPERBYTE, len);
+       }
+       else
+       {
+           /* Figure out how much we need to shift the sequence by */
+           ishift = (s1 - 1) % BITSPERBYTE;
+           r = VARBITS(result);
+           ps = VARBITS(arg) + (s1 - 1) / BITSPERBYTE;
+           for (i = 0; i < len; i++)
+           {
+               *r = (*ps << ishift) & BITMASK;
+               if ((++ps) < VARBITEND(arg))
+                   *r |= *ps >> (BITSPERBYTE - ishift);
+               r++;
+           }
+       }
+       /* Do we need to pad at the end? */
+       ipad = VARBITPAD(result);
+       if (ipad > 0)
+       {
+           mask = BITMASK << ipad;
+           *(VARBITS(result) + len - 1) &= mask;
+       }
    }
-    }
 
-  return result;
+   return result;
 }
 
 /* bitand
@@ -598,32 +656,32 @@ bitsubstr (bits8 *arg, int32 s, int32 l)
  * truncated to the shorter bit string
  */
 bits8 *
-bitand (bits8 * arg1, bits8 * arg2)
+bitand(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    *r++ = *p1++ & *p2++;
-  
-  /* Padding is not needed as & of 0 pad is 0 */
-  
-  return result;
+   int         len,
+               i;
+   bits8      *result;
+   bits8      *p1,
+              *p2,
+              *r;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return (bool) 0;
+
+   len = Min(VARSIZE(arg1), VARSIZE(arg2));
+   result = (bits8 *) palloc(len);
+   VARSIZE(result) = len;
+   VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+   p1 = (bits8 *) VARBITS(arg1);
+   p2 = (bits8 *) VARBITS(arg2);
+   r = (bits8 *) VARBITS(result);
+   for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+       *r++ = *p1++ & *p2++;
+
+   /* Padding is not needed as & of 0 pad is 0 */
+
+   return result;
 }
 
 /* bitor
@@ -631,35 +689,35 @@ bitand (bits8 * arg1, bits8 * arg2)
  * truncated to the shorter bit string.
  */
 bits8 *
-bitor (bits8 * arg1, bits8 * arg2)
+bitor(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    *r++ = *p1++ | *p2++;
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+   int         len,
+               i;
+   bits8      *result;
+   bits8      *p1,
+              *p2,
+              *r;
+   bits8       mask;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return (bool) 0;
+
+   len = Min(VARSIZE(arg1), VARSIZE(arg2));
+   result = (bits8 *) palloc(len);
+   VARSIZE(result) = len;
+   VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+   p1 = (bits8 *) VARBITS(arg1);
+   p2 = (bits8 *) VARBITS(arg2);
+   r = (bits8 *) VARBITS(result);
+   for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+       *r++ = *p1++ | *p2++;
+
+   /* Pad the result */
+   mask = BITMASK << VARBITPAD(result);
+   *r &= mask;
+
+   return result;
 }
 
 /* bitxor
@@ -667,160 +725,167 @@ bitor (bits8 * arg1, bits8 * arg2)
  * truncated to the shorter bit string.
  */
 bits8 *
-bitxor (bits8 * arg1, bits8 * arg2)
+bitxor(bits8 *arg1, bits8 *arg2)
 {
-  int len,
-    i;
-  bits8 *result;
-  bits8 *p1, 
-    *p2, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
-    return (bool) 0;
-
-  len = Min(VARSIZE(arg1),VARSIZE(arg2));
-  result = (bits8 *) palloc(len);
-  VARSIZE(result) = len;
-  VARBITLEN(result) = Min(VARBITLEN(arg1),VARBITLEN(arg2));
-
-  p1 = (bits8 *) VARBITS(arg1);
-  p2 = (bits8 *) VARBITS(arg2);
-  r = (bits8 *) VARBITS(result);
-  for (i=0; i<Min(VARBITBYTES(arg1),VARBITBYTES(arg2)); i++)
-    {
-      *r++ = *p1++ ^ *p2++;
-    }
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+   int         len,
+               i;
+   bits8      *result;
+   bits8      *p1,
+              *p2,
+              *r;
+   bits8       mask;
+
+   if (!PointerIsValid(arg1) || !PointerIsValid(arg2))
+       return (bool) 0;
+
+   len = Min(VARSIZE(arg1), VARSIZE(arg2));
+   result = (bits8 *) palloc(len);
+   VARSIZE(result) = len;
+   VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2));
+
+   p1 = (bits8 *) VARBITS(arg1);
+   p2 = (bits8 *) VARBITS(arg2);
+   r = (bits8 *) VARBITS(result);
+   for (i = 0; i < Min(VARBITBYTES(arg1), VARBITBYTES(arg2)); i++)
+       *r++ = *p1++ ^ *p2++;
+
+   /* Pad the result */
+   mask = BITMASK << VARBITPAD(result);
+   *r &= mask;
+
+   return result;
 }
 
 /* bitnot
  * perform a logical NOT on a bit strings.
  */
 bits8 *
-bitnot (bits8 * arg)
+bitnot(bits8 *arg)
 {
-  bits8 *result;
-  bits8 *p, 
-    *r;
-  bits8 mask;
-
-  if (!PointerIsValid(arg))
-    return (bool) 0;
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-
-  p = (bits8 *) VARBITS(arg);
-  r = (bits8 *) VARBITS(result);
-  for ( ; p < VARBITEND(arg); p++, r++)
-    *r = ~*p;
-
-  /* Pad the result */
-  mask = BITMASK << VARBITPAD(result);
-  *r &= mask;
-  
-  return result;
+   bits8      *result;
+   bits8      *p,
+              *r;
+   bits8       mask;
+
+   if (!PointerIsValid(arg))
+       return (bool) 0;
+
+   result = (bits8 *) palloc(VARSIZE(arg));
+   VARSIZE(result) = VARSIZE(arg);
+   VARBITLEN(result) = VARBITLEN(arg);
+
+   p = (bits8 *) VARBITS(arg);
+   r = (bits8 *) VARBITS(result);
+   for (; p < VARBITEND(arg); p++, r++)
+       *r = ~*p;
+
+   /* Pad the result */
+   mask = BITMASK << VARBITPAD(result);
+   *r &= mask;
+
+   return result;
 }
 
 /* bitshiftleft
  * do a left shift (i.e. to the beginning of the string) of the bit string
  */
 bits8 *
-bitshiftleft (bits8 * arg, int shft)
+bitshiftleft(bits8 *arg, int shft)
 {
-  int byte_shift, ishift, len;
-  bits8 *result;
-  bits8 *p, 
-    *r;
-
-  if (!PointerIsValid(arg))
-    return (bool) 0;
-
-  /* Negative shift is a shift to the right */
-  if (shft < 0) 
-    return bitshiftright(arg, -shft);
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-  r = (bits8 *) VARBITS(result);
-
-  byte_shift = shft/BITSPERBYTE;
-  ishift = shft % BITSPERBYTE;
-  p = ((bits8 *) VARBITS(arg)) + byte_shift;
-  
-  if (ishift == 0) {
-    /* Special case: we can do a memcpy */
-    len = VARBITBYTES(arg) - byte_shift;
-    memcpy(r, p, len);
-    memset(r+len, 0, byte_shift);
-  } else {
-    for ( ; p < VARBITEND(arg); r++) {
-      *r = *p <<ishift;
-      if ((++p) < VARBITEND(arg))
-   *r |= *p >>(BITSPERBYTE-ishift);
-    }
-    for ( ; r < VARBITEND(result) ; r++ ) 
-      *r = (bits8) 0;
-  }
-
-  return result;
+   int         byte_shift,
+               ishift,
+               len;
+   bits8      *result;
+   bits8      *p,
+              *r;
+
+   if (!PointerIsValid(arg))
+       return (bool) 0;
+
+   /* Negative shift is a shift to the right */
+   if (shft < 0)
+       return bitshiftright(arg, -shft);
+
+   result = (bits8 *) palloc(VARSIZE(arg));
+   VARSIZE(result) = VARSIZE(arg);
+   VARBITLEN(result) = VARBITLEN(arg);
+   r = (bits8 *) VARBITS(result);
+
+   byte_shift = shft / BITSPERBYTE;
+   ishift = shft % BITSPERBYTE;
+   p = ((bits8 *) VARBITS(arg)) + byte_shift;
+
+   if (ishift == 0)
+   {
+       /* Special case: we can do a memcpy */
+       len = VARBITBYTES(arg) - byte_shift;
+       memcpy(r, p, len);
+       memset(r + len, 0, byte_shift);
+   }
+   else
+   {
+       for (; p < VARBITEND(arg); r++)
+       {
+           *r = *p << ishift;
+           if ((++p) < VARBITEND(arg))
+               *r |= *p >> (BITSPERBYTE - ishift);
+       }
+       for (; r < VARBITEND(result); r++)
+           *r = (bits8) 0;
+   }
+
+   return result;
 }
 
 /* bitshiftright
  * do a right shift (i.e. to the beginning of the string) of the bit string
  */
 bits8 *
-bitshiftright (bits8 * arg, int shft)
+bitshiftright(bits8 *arg, int shft)
 {
-  int byte_shift, ishift, len;
-  bits8 *result;
-  bits8 *p, 
-    *r;
-
-  if (!PointerIsValid(arg))
-    return (bits8 *) 0;
-
-  /* Negative shift is a shift to the left */
-  if (shft < 0) 
-    return bitshiftleft(arg, -shft);
-
-  result = (bits8 *) palloc(VARSIZE(arg));
-  VARSIZE(result) = VARSIZE(arg);
-  VARBITLEN(result) = VARBITLEN(arg);
-  r = (bits8 *) VARBITS(result);
-
-  byte_shift = shft/BITSPERBYTE;
-  ishift = shft % BITSPERBYTE;
-  p = (bits8 *) VARBITS(arg);
-
-  /* Set the first part of the result to 0 */
-  memset(r, 0, byte_shift);
-  
-  if (ishift == 0) 
-    {
-      /* Special case: we can do a memcpy */
-      len = VARBITBYTES(arg) - byte_shift;
-      memcpy(r+byte_shift, p, len);
-    } 
-  else 
-    {
-      r += byte_shift;
-      *r = 0;    /* Initialise first byte */
-      for ( ; r < VARBITEND(result); p++) {
-   *r |= *p >> ishift;
-   if ((++r) < VARBITEND(result))
-     *r = (*p <<(BITSPERBYTE-ishift)) & BITMASK;
-      }
-    }
-
-  return result;
+   int         byte_shift,
+               ishift,
+               len;
+   bits8      *result;
+   bits8      *p,
+              *r;
+
+   if (!PointerIsValid(arg))
+       return (bits8 *) 0;
+
+   /* Negative shift is a shift to the left */
+   if (shft < 0)
+       return bitshiftleft(arg, -shft);
+
+   result = (bits8 *) palloc(VARSIZE(arg));
+   VARSIZE(result) = VARSIZE(arg);
+   VARBITLEN(result) = VARBITLEN(arg);
+   r = (bits8 *) VARBITS(result);
+
+   byte_shift = shft / BITSPERBYTE;
+   ishift = shft % BITSPERBYTE;
+   p = (bits8 *) VARBITS(arg);
+
+   /* Set the first part of the result to 0 */
+   memset(r, 0, byte_shift);
+
+   if (ishift == 0)
+   {
+       /* Special case: we can do a memcpy */
+       len = VARBITBYTES(arg) - byte_shift;
+       memcpy(r + byte_shift, p, len);
+   }
+   else
+   {
+       r += byte_shift;
+       *r = 0;                 /* Initialise first byte */
+       for (; r < VARBITEND(result); p++)
+       {
+           *r |= *p >> ishift;
+           if ((++r) < VARBITEND(result))
+               *r = (*p << (BITSPERBYTE - ishift)) & BITMASK;
+       }
+   }
+
+   return result;
 }
index 0b7e3308c482c20608d84cd17fbf170d7ab2a86c..ca7202b4c802dc64b414b54e142b9e79c2348b9a 100644 (file)
@@ -2,7 +2,7 @@
 #include <ctype.h>
 #include <errno.h>
 
-#include <float.h>                              /* faked on sunos4 */
+#include <float.h>             /* faked on sunos4 */
 
 #include <math.h>
 
@@ -10,7 +10,7 @@
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #ifndef MAXINT
-#define MAXINT            INT_MAX
+#define MAXINT           INT_MAX
 #endif
 #else
 #ifdef HAVE_VALUES_H
@@ -22,7 +22,7 @@
 #include "utils/builtins.h"
 
 
-#define HEXDIG(z)    (z)<10 ? ((z)+'0') : ((z)-10+'A')
+#define HEXDIG(z)   (z)<10 ? ((z)+'0') : ((z)-10+'A')
 
 /* Modeled on struct varlena from postgres.h, bu data type is bits8 */
 struct varbita
@@ -49,25 +49,25 @@ struct varbita
 #define VARBITEND(PTR)     ((bits8 *) (PTR + VARSIZE(PTR)))
 /* Mask that will cover exactly one byte, i.e. BITSPERBYTE bits */
 #define BITMASK            0xFF
-#define BITHIGH                 0x80
+#define BITHIGH                    0x80
 
 
-bits8 * zpbitin(char *s, int dummy,  int32 atttypmod);
-char zpbitout(bits8 *s);
-char zpbitsout(bits8 *s);
-bits8 * varbitin(char *s, int dummy,  int32 atttypmod);
-bool biteq (bits8 *arg1, bits8 *arg2);
-bool bitne (bits8 *arg1, bits8 *arg2);
-bool bitge (bits8 *arg1, bits8 *arg2);
-bool bitgt (bits8 *arg1, bits8 *arg2);
-bool bitle (bits8 *arg1, bits8 *arg2);
-bool bitlt (bits8 *arg1, bits8 *arg2);
-int bitcmp (bits8 *arg1, bits8 *arg2);
-bits8 * bitand (bits8 * arg1, bits8 * arg2);
-bits8 * bitor (bits8 * arg1, bits8 * arg2);
-bits8 * bitxor (bits8 * arg1, bits8 * arg2);
-bits8 * bitnot (bits8 * arg);
-bits8 * bitshiftright (bits8 * arg, int shft);
-bits8 * bitshiftleft (bits8 * arg, int shft);
-bits8 * bitcat (bits8 *arg1, bits8 *arg2);
-bits8 * bitsubstr (bits8 *arg, int32 s, int32 l);
+bits8     *zpbitin(char *s, int dummy, int32 atttypmod);
+char      *zpbitout(bits8 *s);
+char      *zpbitsout(bits8 *s);
+bits8     *varbitin(char *s, int dummy, int32 atttypmod);
+bool       biteq(bits8 *arg1, bits8 *arg2);
+bool       bitne(bits8 *arg1, bits8 *arg2);
+bool       bitge(bits8 *arg1, bits8 *arg2);
+bool       bitgt(bits8 *arg1, bits8 *arg2);
+bool       bitle(bits8 *arg1, bits8 *arg2);
+bool       bitlt(bits8 *arg1, bits8 *arg2);
+int            bitcmp(bits8 *arg1, bits8 *arg2);
+bits8     *bitand(bits8 *arg1, bits8 *arg2);
+bits8     *bitor(bits8 *arg1, bits8 *arg2);
+bits8     *bitxor(bits8 *arg1, bits8 *arg2);
+bits8     *bitnot(bits8 *arg);
+bits8     *bitshiftright(bits8 *arg, int shft);
+bits8     *bitshiftleft(bits8 *arg, int shft);
+bits8     *bitcat(bits8 *arg1, bits8 *arg2);
+bits8     *bitsubstr(bits8 *arg, int32 s, int32 l);
index 29b7debd03cd45c9a813b92bb7dee1588174aef0..bd79a849a5095d4ba8a638a0a06893810b9e7d77 100644 (file)
@@ -2,21 +2,23 @@
 
 #include "varbit.h"
 
-bits8 * varbit_in (char * s);
-char * varbit_out (bits8 *s);
+bits8     *varbit_in(char *s);
+char      *varbit_out(bits8 *s);
 
 bits8 *
-varbit_in (char * s) {
-  return varbitin (s, 0, -1);
+varbit_in(char *s)
+{
+   return varbitin(s, 0, -1);
 }
 
-/*char * 
+/*char *
 varbit_out (bits8 *s) {
   return zpbitout(s);
 }
 */
 
-char * 
-varbit_out (bits8 *s) {
-  return zpbitsout(s);
+char *
+varbit_out(bits8 *s)
+{
+   return zpbitsout(s);
 }
index f07f5c5b8333654b89099b7fe961137efe53905d..7725f6bbd306f027ad8cfd1e8ac35dd00e13a6a1 100644 (file)
 #include "varbit.h"
 #include <stdio.h>
 
-void print_details (unsigned char *s);
+void       print_details(unsigned char *s);
+
+const int  numb = 8;
 
-const int numb = 8;
 /*
 const char *b[] = { "B0010", "B11011011", "B0001", "X3F12", "X27", "B",
-                    "X11", "B100111"};
+                   "X11", "B100111"};
 int atttypmod[] = {-1, -1, -1,-1,-1,-1,-1,-1 };
 */
-const char *b[] = { "B0010", "B11011011", "B10001", "X3D12", "X27", "B",
-                    "X11", "B100111"};
-int atttypmod[] = { 7, 9, 6, 18, 11, 6, -1, -1 };
+const char *b[] = {"B0010", "B11011011", "B10001", "X3D12", "X27", "B",
+"X11", "B100111"};
+int            atttypmod[] = {7, 9, 6, 18, 11, 6, -1, -1};
 
 
-void print_details (unsigned char *s) 
+void
+print_details(unsigned char *s)
 {
-  int i;
-  printf ("Length in bytes    : %d\n",VARSIZE(s));
-  printf ("Length of bitstring: %d\n",VARBITLEN(s));
-  for (i=8; i<VARSIZE(s); i++) 
-    printf ("%X%X ",s[i]>>4,s[i]&0xF);
-  printf("\n");
+   int         i;
+
+   printf("Length in bytes    : %d\n", VARSIZE(s));
+   printf("Length of bitstring: %d\n", VARBITLEN(s));
+   for (i = 8; i < VARSIZE(s); i++)
+       printf("%X%X ", s[i] >> 4, s[i] & 0xF);
+   printf("\n");
 }
 
 int
-main () 
+main()
 {
-  int i, j;
-  char *s[numb];
-
-  for (i=0; i<numb; i++) {
-    printf ("Input: %s\n",b[i]);
-    s[i] = zpbitin(b[i], 0, atttypmod[i]);
-    //print_details(s[i]);
-    printf ("%s = %s\n",zpbitout(s[i]),zpbitsout(s[i]));
-  }
-
-  printf ("\nCOMPARISONS:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s <=> %s = %d\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        bitcmp(s[i],s[j]));
-
-  printf ("\nCONCATENATION:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s || %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitcat(s[i],s[j])));
-
-  printf("\nSUBSTR:\n");
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,8,
-    zpbitsout(bitsubstr(s[3],1,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),9,8,
-    zpbitsout(bitsubstr(s[3],9,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,9,
-    zpbitsout(bitsubstr(s[3],1,9)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,5,
-    zpbitsout(bitsubstr(s[3],3,5)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,9,
-    zpbitsout(bitsubstr(s[3],3,9)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,17,
-    zpbitsout(bitsubstr(s[3],3,17)));
-  printf ("\nLOGICAL AND:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s & %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitand(s[i],s[j])));
-
-  printf ("\nLOGICAL OR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s | %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitor(s[i],s[j])));
-
-  printf ("\nLOGICAL XOR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s ^ %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitxor(s[i],s[j])));
-  
-  printf ("\nLOGICAL NOT:\n");
-  for (i=0; i<numb; i++)
-    printf("~%s = %s\n",zpbitsout(s[i]),zpbitsout(bitnot(s[i])));
-
-
-  printf ("\nSHIFT LEFT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftleft(s[i],j)));
-  }
-
-  printf ("\nSHIFT RIGHT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftright(s[i],j)));
-  }
-
-  printf ("\n\n ********** VARYING **********\n");
-  for (i=0; i<numb; i++) {
-    printf ("Input: %s\n",b[i]);
-    s[i] = varbitin(b[i], 0, atttypmod[i]);
-    /*print_details(s);*/
-    printf ("%s\n",zpbitout(s[i]));
-    printf ("%s\n",zpbitsout(s[i]));
-  }
-
-  printf ("\nCOMPARISONS:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s <=> %s = %d\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        bitcmp(s[i],s[j]));
-
-  printf ("\nCONCATENATION:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s || %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitcat(s[i],s[j])));
-
-  printf("\nSUBSTR:\n");
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,8,
-    zpbitsout(bitsubstr(s[3],1,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),9,8,
-    zpbitsout(bitsubstr(s[3],9,8)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),1,9,
-    zpbitsout(bitsubstr(s[3],1,9)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,5,
-    zpbitsout(bitsubstr(s[3],3,5)));
-  printf("%s (%d,%d) => %s\n",zpbitsout(s[3]),3,9,
-    zpbitsout(bitsubstr(s[3],3,9)));
-  printf("%s (%d,%d) => %s (%s)\n",zpbitsout(s[3]),3,17,
-    zpbitsout(bitsubstr(s[3],3,17)),zpbitsout(bitsubstr(s[3],3,17)));
-  printf ("\nLOGICAL AND:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s & %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitand(s[i],s[j])));
-
-  printf ("\nLOGICAL OR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s | %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitor(s[i],s[j])));
-
-  printf ("\nLOGICAL XOR:\n");
-  for (i=0; i<numb; i++)
-    for (j=i+1; j<numb; j++)
-      printf("%s ^ %s = %s\n",zpbitsout(s[i]),zpbitsout(s[j]),
-        zpbitsout(bitxor(s[i],s[j])));
-  
-  printf ("\nLOGICAL NOT:\n");
-  for (i=0; i<numb; i++)
-    printf("~%s = %s\n",zpbitsout(s[i]),zpbitsout(bitnot(s[i])));
-
-
-  printf ("\nSHIFT LEFT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftleft(s[i],j)));
-  }
-
-  printf ("\nSHIFT RIGHT:\n");
-  for (i=0; i<numb; i++) {
-    printf("%s\n",zpbitsout(s[i]));
-    for (j=0; j<=VARBITLEN(s[i]); j++)
-      printf("\t%3d\t%s\n",j,zpbitsout(bitshiftright(s[i],j)));
-  }
+   int         i,
+               j;
+   char       *s[numb];
+
+   for (i = 0; i < numb; i++)
+   {
+       printf("Input: %s\n", b[i]);
+       s[i] = zpbitin(b[i], 0, atttypmod[i]);
+       //print_details(s[i]);
+       printf("%s = %s\n", zpbitout(s[i]), zpbitsout(s[i]));
+   }
+
+   printf("\nCOMPARISONS:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s <=> %s = %d\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  bitcmp(s[i], s[j]));
+
+   printf("\nCONCATENATION:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s || %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitcat(s[i], s[j])));
+
+   printf("\nSUBSTR:\n");
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 8,
+          zpbitsout(bitsubstr(s[3], 1, 8)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 9, 8,
+          zpbitsout(bitsubstr(s[3], 9, 8)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 9,
+          zpbitsout(bitsubstr(s[3], 1, 9)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 5,
+          zpbitsout(bitsubstr(s[3], 3, 5)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 9,
+          zpbitsout(bitsubstr(s[3], 3, 9)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 17,
+          zpbitsout(bitsubstr(s[3], 3, 17)));
+   printf("\nLOGICAL AND:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s & %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitand(s[i], s[j])));
+
+   printf("\nLOGICAL OR:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s | %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitor(s[i], s[j])));
+
+   printf("\nLOGICAL XOR:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s ^ %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitxor(s[i], s[j])));
+
+   printf("\nLOGICAL NOT:\n");
+   for (i = 0; i < numb; i++)
+       printf("~%s = %s\n", zpbitsout(s[i]), zpbitsout(bitnot(s[i])));
+
+
+   printf("\nSHIFT LEFT:\n");
+   for (i = 0; i < numb; i++)
+   {
+       printf("%s\n", zpbitsout(s[i]));
+       for (j = 0; j <= VARBITLEN(s[i]); j++)
+           printf("\t%3d\t%s\n", j, zpbitsout(bitshiftleft(s[i], j)));
+   }
+
+   printf("\nSHIFT RIGHT:\n");
+   for (i = 0; i < numb; i++)
+   {
+       printf("%s\n", zpbitsout(s[i]));
+       for (j = 0; j <= VARBITLEN(s[i]); j++)
+           printf("\t%3d\t%s\n", j, zpbitsout(bitshiftright(s[i], j)));
+   }
+
+   printf("\n\n ********** VARYING **********\n");
+   for (i = 0; i < numb; i++)
+   {
+       printf("Input: %s\n", b[i]);
+       s[i] = varbitin(b[i], 0, atttypmod[i]);
+       /* print_details(s); */
+       printf("%s\n", zpbitout(s[i]));
+       printf("%s\n", zpbitsout(s[i]));
+   }
+
+   printf("\nCOMPARISONS:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s <=> %s = %d\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  bitcmp(s[i], s[j]));
+
+   printf("\nCONCATENATION:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s || %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitcat(s[i], s[j])));
+
+   printf("\nSUBSTR:\n");
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 8,
+          zpbitsout(bitsubstr(s[3], 1, 8)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 9, 8,
+          zpbitsout(bitsubstr(s[3], 9, 8)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 1, 9,
+          zpbitsout(bitsubstr(s[3], 1, 9)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 5,
+          zpbitsout(bitsubstr(s[3], 3, 5)));
+   printf("%s (%d,%d) => %s\n", zpbitsout(s[3]), 3, 9,
+          zpbitsout(bitsubstr(s[3], 3, 9)));
+   printf("%s (%d,%d) => %s (%s)\n", zpbitsout(s[3]), 3, 17,
+   zpbitsout(bitsubstr(s[3], 3, 17)), zpbitsout(bitsubstr(s[3], 3, 17)));
+   printf("\nLOGICAL AND:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s & %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitand(s[i], s[j])));
+
+   printf("\nLOGICAL OR:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s | %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitor(s[i], s[j])));
+
+   printf("\nLOGICAL XOR:\n");
+   for (i = 0; i < numb; i++)
+       for (j = i + 1; j < numb; j++)
+           printf("%s ^ %s = %s\n", zpbitsout(s[i]), zpbitsout(s[j]),
+                  zpbitsout(bitxor(s[i], s[j])));
+
+   printf("\nLOGICAL NOT:\n");
+   for (i = 0; i < numb; i++)
+       printf("~%s = %s\n", zpbitsout(s[i]), zpbitsout(bitnot(s[i])));
+
+
+   printf("\nSHIFT LEFT:\n");
+   for (i = 0; i < numb; i++)
+   {
+       printf("%s\n", zpbitsout(s[i]));
+       for (j = 0; j <= VARBITLEN(s[i]); j++)
+           printf("\t%3d\t%s\n", j, zpbitsout(bitshiftleft(s[i], j)));
+   }
+
+   printf("\nSHIFT RIGHT:\n");
+   for (i = 0; i < numb; i++)
+   {
+       printf("%s\n", zpbitsout(s[i]));
+       for (j = 0; j <= VARBITLEN(s[i]); j++)
+           printf("\t%3d\t%s\n", j, zpbitsout(bitshiftright(s[i], j)));
+   }
 
 }
index c5b8bc25e9d2789611846cb849850b2e1b81270b..47991a8646d9a5c94e642585482ba9871f00bf6c 100644 (file)
@@ -36,7 +36,7 @@
  * Decode time string 00:00:00 through 24:00:00.
  */
 static int
-decode_24h_time(char *str, struct tm *tm, double *fsec)
+decode_24h_time(char *str, struct tm * tm, double *fsec)
 {
    char       *cp;
 
@@ -51,9 +51,7 @@ decode_24h_time(char *str, struct tm *tm, double *fsec)
        *fsec = 0;
    }
    else if (*cp != ':')
-   {
        return -1;
-   }
    else
    {
        str = cp + 1;
@@ -72,10 +70,10 @@ decode_24h_time(char *str, struct tm *tm, double *fsec)
    }
 
    /* do a sanity check */
-   if (   (tm->tm_hour < 0) || (tm->tm_hour > 24)
-       || (tm->tm_min  < 0) || (tm->tm_min  > 59)
-       || (tm->tm_sec  < 0) || (tm->tm_sec  > 59)
-       || (*fsec       < 0) )
+   if ((tm->tm_hour < 0) || (tm->tm_hour > 24)
+       || (tm->tm_min < 0) || (tm->tm_min > 59)
+       || (tm->tm_sec < 0) || (tm->tm_sec > 59)
+       || (*fsec < 0))
        return -1;
 
    return 0;
@@ -265,7 +263,7 @@ currentdate()
 int4
 date2mjd(DateADT val)
 {
-   int result;
+   int         result;
 
    result = val + JDATE_2000 - 2400000.5;
 
@@ -276,8 +274,8 @@ date2mjd(DateADT val)
 
 /*
  * 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 ff2309d16f0543f4e080c282547ce427b492d8e1..c345f2852b8a16d1ac5d4bfb846e750d138e254b 100644 (file)
@@ -20,8 +20,8 @@ DateADT       currentdate(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 6745b5b8bb9a9e049c19e181b875f64e45fae7ab..302118689dc1b9a713c2192eb64823261ff9850f 100644 (file)
@@ -38,6 +38,7 @@ extern int    assertTest(int val);
 
 #ifdef ASSERT_CHECKING_TEST
 extern int assertEnable(int val);
+
 #endif
 
 int
@@ -84,7 +85,8 @@ active_listeners(text *relname)
    ScanKeyData key;
    Datum       d;
    bool        isnull;
-   int         len, pid;
+   int         len,
+               pid;
    int         count = 0;
    int         ourpid = getpid();
    char        listen_name[NAMEDATALEN];
@@ -92,8 +94,9 @@ active_listeners(text *relname)
    lRel = heap_openr(ListenerRelationName, AccessShareLock);
    tdesc = RelationGetDescr(lRel);
 
-   if (relname && (VARSIZE(relname) > VARHDRSZ)) {
-       len = MIN(VARSIZE(relname)-VARHDRSZ, NAMEDATALEN-1);
+   if (relname && (VARSIZE(relname) > VARHDRSZ))
+   {
+       len = MIN(VARSIZE(relname) - VARHDRSZ, NAMEDATALEN - 1);
        strncpy(listen_name, VARDATA(relname), len);
        listen_name[len] = '\0';
        ScanKeyEntryInitialize(&key, 0,
@@ -101,15 +104,16 @@ active_listeners(text *relname)
                               F_NAMEEQ,
                               PointerGetDatum(listen_name));
        sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, &key);
-   } else {
-       sRel = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey)NULL);
    }
+   else
+       sRel = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey) NULL);
 
    while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
    {
        d = heap_getattr(lTuple, Anum_pg_listener_pid, tdesc, &isnull);
        pid = DatumGetInt32(d);
-       if ((pid == ourpid) || (kill(pid, SIGTSTP) == 0)) {
+       if ((pid == ourpid) || (kill(pid, SIGTSTP) == 0))
+       {
            /* elog(NOTICE, "%d ok", pid); */
            count++;
        }
@@ -134,6 +138,7 @@ assert_test(int val)
 {
    return assertTest(val);
 }
+
 #endif
 #endif
 
@@ -141,8 +146,8 @@ assert_test(int val)
 
 /*
  * 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 139df3bc775cadc75e3a75cac7e2a812c601cd58..080f1147a887753f5fb2ab51667b213b086ccf53 100644 (file)
@@ -10,8 +10,10 @@ int          active_listeners(text *relname);
 
 #ifdef USE_ASSERT_CHECKING
 int            assert_enable(int val);
+
 #ifdef ASSERT_CHECKING_TEST
 int            assert_test(int val);
+
 #endif
 #endif
 
@@ -19,8 +21,8 @@ int           assert_test(int val);
 
 /*
  * 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 afdcb4484c8d557359556ef1e9dfdbf64e4edfb4..7a98eb60a9c399472aad6ef52124144ef76899a1 100644 (file)
@@ -11,7 +11,7 @@
  * 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
 \r
 #define DEF_PGPORT "5432"\r
 \r
index ab5f0907167f727e87a6637dfe0120c12c56bad1..c2b027c9eccbd7f0b788ec173aaa7a85b8a7cc5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.2 2000/04/08 18:32:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.3 2000/04/12 17:14:27 momjian Exp $
  *
  * pgbench: a simple TPC-B like benchmark program for PostgreSQL
  * written by Tatsuo Ishii
 /********************************************************************
  * some configurable parameters */
 
-#define MAXCLIENTS 1024    /* max number of clients allowed */
+#define MAXCLIENTS 1024            /* max number of clients allowed */
 
-int nclients = 1;  /* default number of simulated clients */
-int nxacts = 10;   /* default number of transactions per clients */
+int            nclients = 1;       /* default number of simulated clients */
+int            nxacts = 10;        /* default number of transactions per
+                                * clients */
 
 /*
  * scaling factor. for example, tps = 10 will make 1000000 tuples of
  * accounts table.
  */
-int tps = 1;
+int            tps = 1;
 
 /*
  * end of configurable parameters
@@ -67,671 +68,753 @@ int tps = 1;
 
 #define nbranches  1
 #define ntellers   10
-#define    naccounts   100000
-
-int remains;       /* number of remained clients */
-
-typedef struct {
-  PGconn   *con;   /* connection handle to DB */
-  int  state;  /* state No. */
-  int  cnt;    /* xacts count */
-  int  ecnt;   /* error count */
-  int  listen; /* none 0 indicates that an async query has been sent */
-  int  aid;    /* account id for this transaction */
-  int  bid;    /* branch id for this transaction */
-  int  tid;    /* teller id for this transaction */
-  int  delta;
-  int  abalance;
-} CState;
-
-static void usage() {
-  fprintf(stderr,"usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-v][-S][-d][dbname]\n");
-  fprintf(stderr,"(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-d][dbname]\n");
+#define naccounts  100000
+
+int            remains;            /* number of remained clients */
+
+typedef struct
+{
+   PGconn     *con;            /* connection handle to DB */
+   int         state;          /* state No. */
+   int         cnt;            /* xacts count */
+   int         ecnt;           /* error count */
+   int         listen;         /* none 0 indicates that an async query
+                                * has been sent */
+   int         aid;            /* account id for this transaction */
+   int         bid;            /* branch id for this transaction */
+   int         tid;            /* teller id for this transaction */
+   int         delta;
+   int         abalance;
+}          CState;
+
+static void
+usage()
+{
+   fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-v][-S][-d][dbname]\n");
+   fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-d][dbname]\n");
 }
 
 /* random number generator */
-static int getrand(int min, int max) {
-  return(min+(int)(max*1.0*rand()/(RAND_MAX+1.0)));
+static int
+getrand(int min, int max)
+{
+   return (min + (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)));
 }
 
 /* throw away response from backend */
-static void discard_response(CState *state) {
-  PGresult *res;
-  do {
-    res = PQgetResult(state->con);
-    if (res)
-      PQclear(res);
-  } while(res);
+static void
+discard_response(CState * state)
+{
+   PGresult   *res;
+
+   do
+   {
+       res = PQgetResult(state->con);
+       if (res)
+           PQclear(res);
+   } while (res);
 }
 
-static int check(CState *state, PGresult *res, int n, int good)
+static int
+check(CState * state, PGresult *res, int n, int good)
 {
-  CState *st = &state[n];
-
-  if (res && PQresultStatus(res) != good) {
-    fprintf(stderr,"Client %d aborted in state %d: %s",n,st->state,PQerrorMessage(st->con));
-    remains--; /* I've aborted */
-    PQfinish(st->con);
-    st->con = NULL;
-    return(-1);
-  }
-  return(0);
+   CState     *st = &state[n];
+
+   if (res && PQresultStatus(res) != good)
+   {
+       fprintf(stderr, "Client %d aborted in state %d: %s", n, st->state, PQerrorMessage(st->con));
+       remains--;              /* I've aborted */
+       PQfinish(st->con);
+       st->con = NULL;
+       return (-1);
+   }
+   return (0);
 }
 
 /* process a transaction */
-static void doOne(CState *state, int n, int debug) {
-  char sql[256];
-  PGresult   *res;
-  CState *st = &state[n];
-
-  if (st->listen) {    /* are we receiver? */
-    if (debug) {
-      fprintf(stderr,"client %d receiving\n",n);
-    }
-    while (PQisBusy(st->con) == TRUE) {
-      if (!PQconsumeInput(st->con)) {  /* there's something wrong */
-   fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n",n, st->state);
-   remains--;  /* I've aborted */
-   PQfinish(st->con);
-   st->con = NULL;
-   return;
-      }
-    }
-
-    switch (st->state) {
-    case 0:    /* response to "begin" */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 1:    /* response to "update accounts..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 2:    /* response to "select abalance ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_TUPLES_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 3:    /* response to "update tellers ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 4:    /* response to "update branches ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 5:    /* response to "insert into history ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-      break;
-    case 6:    /* response to "end" */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_COMMAND_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-
-      if (++st->cnt >= nxacts) {
-   remains--;  /* I've done */
-   PQfinish(st->con);
-   st->con = NULL;
-   return;
-      }
-      break;
-    }
-
-    /* increment state counter */
-    st->state++;
-    if (st->state > 6) {
-      st->state = 0;
-    }
-  }
-
-  switch (st->state) {
-  case 0:  /* about to start */
-    strcpy(sql,"begin");
-    st->aid = getrand(1,naccounts*tps);
-    st->bid = getrand(1,nbranches*tps);
-    st->tid = getrand(1,ntellers*tps);
-    st->delta = getrand(1,1000);
-    break;
-  case 1:
-    sprintf(sql,"update accounts set abalance = abalance + %d where aid = %d\n",st->delta,st->aid);
-      break;
-  case 2:
-    sprintf(sql,"select abalance from accounts where aid = %d",st->aid);
-    break;
-  case 3:
-    sprintf(sql,"update tellers set tbalance = tbalance + %d where tid = %d\n",
-       st->delta,st->tid);
-    break;
-  case 4:
-    sprintf(sql,"update branches set bbalance = bbalance + %d where bid = %d",st->delta,st->bid);
-    break;
-  case 5:
-    sprintf(sql,"insert into history(tid,bid,aid,delta,time) values(%d,%d,%d,%d,'now')",
-       st->tid,st->bid,st->aid,st->delta);
-    break;
-  case 6:
-    strcpy(sql,"end");
-    break;
-  }
-
-  if (debug) {
-    fprintf(stderr,"client %d sending %s\n",n,sql);
-  }
-  if (PQsendQuery(st->con, sql) == 0) {
-    if (debug) {
-      fprintf(stderr, "PQsendQuery(%s)failed\n",sql);
-    }
-    st->ecnt++;
-  } else {
-    st->listen++;  /* flags that should be listned */
-  }
+static void
+doOne(CState * state, int n, int debug)
+{
+   char        sql[256];
+   PGresult   *res;
+   CState     *st = &state[n];
+
+   if (st->listen)
+   {                           /* are we receiver? */
+       if (debug)
+           fprintf(stderr, "client %d receiving\n", n);
+       while (PQisBusy(st->con) == TRUE)
+       {
+           if (!PQconsumeInput(st->con))
+           {                   /* there's something wrong */
+               fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
+               remains--;      /* I've aborted */
+               PQfinish(st->con);
+               st->con = NULL;
+               return;
+           }
+       }
+
+       switch (st->state)
+       {
+           case 0:             /* response to "begin" */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_COMMAND_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+               break;
+           case 1:             /* response to "update accounts..." */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_COMMAND_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+               break;
+           case 2:             /* response to "select abalance ..." */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_TUPLES_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+               break;
+           case 3:             /* response to "update tellers ..." */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_COMMAND_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+               break;
+           case 4:             /* response to "update branches ..." */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_COMMAND_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+               break;
+           case 5:             /* response to "insert into history ..." */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_COMMAND_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+               break;
+           case 6:             /* response to "end" */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_COMMAND_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+
+               if (++st->cnt >= nxacts)
+               {
+                   remains--;  /* I've done */
+                   PQfinish(st->con);
+                   st->con = NULL;
+                   return;
+               }
+               break;
+       }
+
+       /* increment state counter */
+       st->state++;
+       if (st->state > 6)
+           st->state = 0;
+   }
+
+   switch (st->state)
+   {
+       case 0:         /* about to start */
+           strcpy(sql, "begin");
+           st->aid = getrand(1, naccounts * tps);
+           st->bid = getrand(1, nbranches * tps);
+           st->tid = getrand(1, ntellers * tps);
+           st->delta = getrand(1, 1000);
+           break;
+       case 1:
+           sprintf(sql, "update accounts set abalance = abalance + %d where aid = %d\n", st->delta, st->aid);
+           break;
+       case 2:
+           sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
+           break;
+       case 3:
+           sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n",
+                   st->delta, st->tid);
+           break;
+       case 4:
+           sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
+           break;
+       case 5:
+           sprintf(sql, "insert into history(tid,bid,aid,delta,time) values(%d,%d,%d,%d,'now')",
+                   st->tid, st->bid, st->aid, st->delta);
+           break;
+       case 6:
+           strcpy(sql, "end");
+           break;
+   }
+
+   if (debug)
+       fprintf(stderr, "client %d sending %s\n", n, sql);
+   if (PQsendQuery(st->con, sql) == 0)
+   {
+       if (debug)
+           fprintf(stderr, "PQsendQuery(%s)failed\n", sql);
+       st->ecnt++;
+   }
+   else
+   {
+       st->listen++;           /* flags that should be listned */
+   }
 }
 
 /* process a select only transaction */
-static void doSelectOnly(CState *state, int n, int debug) {
-  char sql[256];
-  PGresult   *res;
-  CState *st = &state[n];
-
-  if (st->listen) {    /* are we receiver? */
-    if (debug) {
-      fprintf(stderr,"client %d receiving\n",n);
-    }
-    while (PQisBusy(st->con) == TRUE) {
-      if (!PQconsumeInput(st->con)) {  /* there's something wrong */
-   fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n",n, st->state);
-   remains--;  /* I've aborted */
-   PQfinish(st->con);
-   st->con = NULL;
-   return;
-      }
-    }
-
-    switch (st->state) {
-    case 0:    /* response to "select abalance ..." */
-      res = PQgetResult(st->con);
-      if (check(state, res, n, PGRES_TUPLES_OK)) {
-   return;
-      }
-      PQclear(res);
-      discard_response(st);
-
-      if (++st->cnt >= nxacts) {
-   remains--;  /* I've done */
-   PQfinish(st->con);
-   st->con = NULL;
-   return;
-      }
-      break;
-    }
-
-    /* increment state counter */
-    st->state++;
-    if (st->state > 0) {
-      st->state = 0;
-    }
-  }
-
-  switch (st->state) {
-  case 0:
-    st->aid = getrand(1,naccounts*tps);
-    sprintf(sql,"select abalance from accounts where aid = %d",st->aid);
-    break;
-  }
-
-  if (debug) {
-    fprintf(stderr,"client %d sending %s\n",n,sql);
-  }
-
-  if (PQsendQuery(st->con, sql) == 0) {
-    if (debug) {
-      fprintf(stderr, "PQsendQuery(%s)failed\n",sql);
-    }
-    st->ecnt++;
-  } else {
-    st->listen++;  /* flags that should be listned */
-  }
+static void
+doSelectOnly(CState * state, int n, int debug)
+{
+   char        sql[256];
+   PGresult   *res;
+   CState     *st = &state[n];
+
+   if (st->listen)
+   {                           /* are we receiver? */
+       if (debug)
+           fprintf(stderr, "client %d receiving\n", n);
+       while (PQisBusy(st->con) == TRUE)
+       {
+           if (!PQconsumeInput(st->con))
+           {                   /* there's something wrong */
+               fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
+               remains--;      /* I've aborted */
+               PQfinish(st->con);
+               st->con = NULL;
+               return;
+           }
+       }
+
+       switch (st->state)
+       {
+           case 0:             /* response to "select abalance ..." */
+               res = PQgetResult(st->con);
+               if (check(state, res, n, PGRES_TUPLES_OK))
+                   return;
+               PQclear(res);
+               discard_response(st);
+
+               if (++st->cnt >= nxacts)
+               {
+                   remains--;  /* I've done */
+                   PQfinish(st->con);
+                   st->con = NULL;
+                   return;
+               }
+               break;
+       }
+
+       /* increment state counter */
+       st->state++;
+       if (st->state > 0)
+           st->state = 0;
+   }
+
+   switch (st->state)
+   {
+       case 0:
+           st->aid = getrand(1, naccounts * tps);
+           sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
+           break;
+   }
+
+   if (debug)
+       fprintf(stderr, "client %d sending %s\n", n, sql);
+
+   if (PQsendQuery(st->con, sql) == 0)
+   {
+       if (debug)
+           fprintf(stderr, "PQsendQuery(%s)failed\n", sql);
+       st->ecnt++;
+   }
+   else
+   {
+       st->listen++;           /* flags that should be listned */
+   }
 }
 
 /* discard connections */
-static void disconnect_all(CState *state) {
-  int i;
-  for (i=0;i<nclients;i++) {
-    if (state[i].con) {
-      PQfinish(state[i].con);
-    }
-  }
+static void
+disconnect_all(CState * state)
+{
+   int         i;
+
+   for (i = 0; i < nclients; i++)
+   {
+       if (state[i].con)
+           PQfinish(state[i].con);
+   }
 }
 
 /* create tables and setup data */
-static void init(char *pghost, char *pgport,char *dbName) {
-  PGconn *con;
-  PGresult *res;
-  static char *DDLs[] = {
-    "drop table branches",
-    "create table branches(bid int, primary key(bid),bbalance int,filler char(88))",
-    "drop table tellers",
-    "create table tellers(tid int, primary key(tid),bid int,tbalance int,filler char(84))",
-    "drop table accounts",
-    "create table accounts(aid int,primary key(aid),bid int,abalance int,filler char(84))",
-    "drop table history",
-    "create table history(tid int,bid int,aid int,delta int,time timestamp,filler char(22))"};
-  char sql[256];
-
-  int i;
-
-  con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-  if (PQstatus(con) == CONNECTION_BAD) {
-    fprintf(stderr, "Connection to database '%s' on %s failed.\n", dbName,pghost);
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  for (i=0;i<(sizeof(DDLs)/sizeof(char *));i++) {
-    res = PQexec(con,DDLs[i]);
-    if (strncmp(DDLs[i],"drop",4) && PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-  }
-
-  res = PQexec(con,"begin");
-  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  for(i = 0; i < nbranches * tps; i++) {
-    sprintf(sql,"insert into branches(bid,bbalance) values(%d,0)",i+1);
-    res = PQexec(con,sql);
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-  }
-
-  for(i = 0; i < ntellers * tps; i++) {
-    sprintf(sql,"insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
-       ,i+1,i/ntellers+1);
-    res = PQexec(con,sql);
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-  }
-
-  res = PQexec(con,"copy accounts from stdin");
-  if (PQresultStatus(res) != PGRES_COPY_IN) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-  PQclear(res);
-
-  fprintf(stderr,"creating tables...\n");
-  for(i = 0; i < naccounts*tps; i++) {
-    int j = i + 1;
-    sprintf(sql,"%d\t%d\t%d\t\n",i+1,(i+1)/naccounts,0);
-    if (PQputline(con,sql)) {
-      fprintf(stderr,"PQputline failed\n");
-      exit(1);
-    }
-    if (j % 10000 == 0) {
-      fprintf(stderr,"%d tuples done.\n",j);
-    }
-  }
-  if (PQputline(con,"\\.\n")) {
-    fprintf(stderr,"very last PQputline failed\n");
-    exit(1);
-  }
-
-  if (PQendcopy(con)) {
-    fprintf(stderr,"PQendcopy failed\n");
-    exit(1);
-  }
-
-  res = PQexec(con,"end");
-  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  /* vacuum */
-  fprintf(stderr,"vacuum...");
-  res = PQexec(con,"vacuum analyze");
-  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-  fprintf(stderr,"done.\n");
-
-  PQfinish(con);
-}
+static void
+init(char *pghost, char *pgport, char *dbName)
+{
+   PGconn     *con;
+   PGresult   *res;
+   static char *DDLs[] = {
+       "drop table branches",
+       "create table branches(bid int, primary key(bid),bbalance int,filler char(88))",
+       "drop table tellers",
+       "create table tellers(tid int, primary key(tid),bid int,tbalance int,filler char(84))",
+       "drop table accounts",
+       "create table accounts(aid int,primary key(aid),bid int,abalance int,filler char(84))",
+       "drop table history",
+   "create table history(tid int,bid int,aid int,delta int,time timestamp,filler char(22))"};
+   char        sql[256];
+
+   int         i;
+
+   con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+   if (PQstatus(con) == CONNECTION_BAD)
+   {
+       fprintf(stderr, "Connection to database '%s' on %s failed.\n", dbName, pghost);
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
 
-/* print out results */
-static void printResults(
-            int ttype, CState *state, 
-            struct timeval *tv1,struct timeval *tv2,
-            struct timeval *tv3) {
-  double t1,t2;
-  int i;
-  int normal_xacts = 0;
-
-  for (i=0;i<nclients;i++) {
-    normal_xacts += state[i].cnt;
-  }
-
-  t1 = (tv3->tv_sec - tv1->tv_sec)*1000000.0+(tv3->tv_usec - tv1->tv_usec);
-  t1 = normal_xacts*1000000.0/t1;
-
-  t2 = (tv3->tv_sec - tv2->tv_sec)*1000000.0+(tv3->tv_usec - tv2->tv_usec);
-  t2 = normal_xacts*1000000.0/t2;
-
-  printf("transaction type: %s\n",ttype==0?"TPC-B (sort of)":"SELECT only");
-  printf("scaling factor: %d\n",tps);
-  printf("number of clients: %d\n",nclients);
-  printf("number of transactions per client: %d\n",nxacts);
-  printf("number of transactions actually processed: %d/%d\n",normal_xacts,nxacts*nclients);
-  printf("tps = %f(including connections establishing)\n",t1);
-  printf("tps = %f(excluding connections establishing)\n",t2);
-}
+   for (i = 0; i < (sizeof(DDLs) / sizeof(char *)); i++)
+   {
+       res = PQexec(con, DDLs[i]);
+       if (strncmp(DDLs[i], "drop", 4) && PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+   }
 
-int main(int argc, char **argv) {
-  extern char *optarg;
-  extern int optind, opterr, optopt;
-  int c;
-  char *pghost = "";
-  char *pgport = "";
-  char *dbName;
-  int is_init_mode = 0;    /* initialize mode? */
-  int is_no_vacuum = 0;    /* no vacuum at all before testing? */
-  int is_full_vacuum = 0;  /* do full vacuum before testing? */
-  int debug = 0;   /* debug flag */
-  int ttype = 0;   /* transaction type. 0: TPC-B, 1: SELECT only */
+   res = PQexec(con, "begin");
+   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   {
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
 
-  static CState       state[MAXCLIENTS];   /* clients status */
+   for (i = 0; i < nbranches * tps; i++)
+   {
+       sprintf(sql, "insert into branches(bid,bbalance) values(%d,0)", i + 1);
+       res = PQexec(con, sql);
+       if (PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+   }
 
-  struct timeval tv1;  /* start up time */
-  struct timeval tv2;  /* after establishing all connections to the backend */
-  struct timeval tv3;  /* end time */
+   for (i = 0; i < ntellers * tps; i++)
+   {
+       sprintf(sql, "insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
+               ,i + 1, i / ntellers + 1);
+       res = PQexec(con, sql);
+       if (PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+   }
 
-  int  i;
+   res = PQexec(con, "copy accounts from stdin");
+   if (PQresultStatus(res) != PGRES_COPY_IN)
+   {
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
+   PQclear(res);
+
+   fprintf(stderr, "creating tables...\n");
+   for (i = 0; i < naccounts * tps; i++)
+   {
+       int         j = i + 1;
+
+       sprintf(sql, "%d\t%d\t%d\t\n", i + 1, (i + 1) / naccounts, 0);
+       if (PQputline(con, sql))
+       {
+           fprintf(stderr, "PQputline failed\n");
+           exit(1);
+       }
+       if (j % 10000 == 0)
+           fprintf(stderr, "%d tuples done.\n", j);
+   }
+   if (PQputline(con, "\\.\n"))
+   {
+       fprintf(stderr, "very last PQputline failed\n");
+       exit(1);
+   }
+
+   if (PQendcopy(con))
+   {
+       fprintf(stderr, "PQendcopy failed\n");
+       exit(1);
+   }
+
+   res = PQexec(con, "end");
+   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   {
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
+
+   /* vacuum */
+   fprintf(stderr, "vacuum...");
+   res = PQexec(con, "vacuum analyze");
+   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   {
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
+   fprintf(stderr, "done.\n");
+
+   PQfinish(con);
+}
 
-  fd_set   input_mask;
-  int nsocks;  /* return from select(2) */
-  int maxsock; /* max socket number to be waited */
+/* print out results */
+static void
+printResults(
+            int ttype, CState * state,
+            struct timeval * tv1, struct timeval * tv2,
+            struct timeval * tv3)
+{
+   double      t1,
+               t2;
+   int         i;
+   int         normal_xacts = 0;
+
+   for (i = 0; i < nclients; i++)
+       normal_xacts += state[i].cnt;
+
+   t1 = (tv3->tv_sec - tv1->tv_sec) * 1000000.0 + (tv3->tv_usec - tv1->tv_usec);
+   t1 = normal_xacts * 1000000.0 / t1;
+
+   t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec);
+   t2 = normal_xacts * 1000000.0 / t2;
+
+   printf("transaction type: %s\n", ttype == 0 ? "TPC-B (sort of)" : "SELECT only");
+   printf("scaling factor: %d\n", tps);
+   printf("number of clients: %d\n", nclients);
+   printf("number of transactions per client: %d\n", nxacts);
+   printf("number of transactions actually processed: %d/%d\n", normal_xacts, nxacts * nclients);
+   printf("tps = %f(including connections establishing)\n", t1);
+   printf("tps = %f(excluding connections establishing)\n", t2);
+}
+
+int
+main(int argc, char **argv)
+{
+   extern char *optarg;
+   extern int  optind,
+               opterr,
+               optopt;
+   int         c;
+   char       *pghost = "";
+   char       *pgport = "";
+   char       *dbName;
+   int         is_init_mode = 0;       /* initialize mode? */
+   int         is_no_vacuum = 0;       /* no vacuum at all before
+                                        * testing? */
+   int         is_full_vacuum = 0;     /* do full vacuum before testing? */
+   int         debug = 0;      /* debug flag */
+   int         ttype = 0;      /* transaction type. 0: TPC-B, 1: SELECT
+                                * only */
+
+   static CState state[MAXCLIENTS];    /* clients status */
+
+   struct timeval tv1;         /* start up time */
+   struct timeval tv2;         /* after establishing all connections to
+                                * the backend */
+   struct timeval tv3;         /* end time */
+
+   int         i;
+
+   fd_set      input_mask;
+   int         nsocks;         /* return from select(2) */
+   int         maxsock;        /* max socket number to be waited */
 
 #ifndef __CYGWIN32__
-  struct rlimit rlim;
+   struct rlimit rlim;
+
 #endif
 
-  PGconn *con;
-  PGresult *res;
-
-  while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:S")) != EOF) {
-    switch (c) {
-    case 'i':
-      is_init_mode++;
-      break;
-    case 'h':
-      pghost = optarg;
-      break;
-    case 'n':
-      is_no_vacuum++;
-      break;
-    case 'v':
-      is_full_vacuum++;
-      break;
-    case 'p':
-      pgport = optarg;
-      break;
-    case 'd':
-      debug++;
-      break;
-    case 'S':
-      ttype = 1;
-      break;
-    case 'c':
-      nclients = atoi(optarg);
-      if (nclients <= 0 || nclients > MAXCLIENTS) {
-   fprintf(stderr,"wrong number of clients: %d\n",nclients);
-   exit(1);
-      }
+   PGconn     *con;
+   PGresult   *res;
+
+   while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:S")) != EOF)
+   {
+       switch (c)
+       {
+           case 'i':
+               is_init_mode++;
+               break;
+           case 'h':
+               pghost = optarg;
+               break;
+           case 'n':
+               is_no_vacuum++;
+               break;
+           case 'v':
+               is_full_vacuum++;
+               break;
+           case 'p':
+               pgport = optarg;
+               break;
+           case 'd':
+               debug++;
+               break;
+           case 'S':
+               ttype = 1;
+               break;
+           case 'c':
+               nclients = atoi(optarg);
+               if (nclients <= 0 || nclients > MAXCLIENTS)
+               {
+                   fprintf(stderr, "wrong number of clients: %d\n", nclients);
+                   exit(1);
+               }
 #ifndef __CYGWIN32__
-#ifdef RLIMIT_NOFILE       /* most platform uses RLIMIT_NOFILE */
-      if (getrlimit(RLIMIT_NOFILE,&rlim) == -1) {
-#else  /* but BSD doesn't ... */
-      if (getrlimit(RLIMIT_OFILE,&rlim) == -1) {
-#endif /* HAVE_RLIMIT_NOFILE */
-   fprintf(stderr,"getrlimit failed. reason: %s\n",strerror(errno));
-   exit(1);
-      }
-      if (rlim.rlim_cur <= (nclients+2)) {
-   fprintf(stderr,"You need at least %d open files resource but you are only allowed to use %ld.\n",nclients+2,rlim.rlim_cur);
-   fprintf(stderr,"Use limit/ulimt to increase the limit before using pgbench.\n");
-   exit(1);
-      }
-#endif /* #ifndef __CYGWIN32__ */
-      break;
-    case 's':
-      tps = atoi(optarg);
-      if (tps <= 0) {
-   fprintf(stderr,"wrong scaling factor: %d\n",tps);
-   exit(1);
-      }
-      break;
-    case 't':
-      nxacts = atoi(optarg);
-      if (nxacts <= 0) {
-   fprintf(stderr,"wrong number of transactions: %d\n",nxacts);
-   exit(1);
-      }
-      break;
-    default:
-      usage();
-      exit(1);
-      break;
-    }
-  }
-
-  if (argc > optind) {
-    dbName = argv[optind];
-  } else {
-    dbName = getenv("USER");
-    if (dbName == NULL) {
-      dbName = "";
-    }
-  }
-
-  if (is_init_mode) {
-    init(pghost, pgport, dbName);
-    exit(0);
-  }
-
-  remains = nclients;
-
-  if (debug) {
-    printf("pghost: %s pgport: %s nclients: %d nxacts: %d dbName: %s\n",
-      pghost, pgport, nclients, nxacts, dbName);
-  }
-
-  /* opening connection... */
-  con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-  if (PQstatus(con) == CONNECTION_BAD) {
-    fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-
-  /* get the scaling factor that should be same as count(*) from branches... */
-  res = PQexec(con,"select count(*) from branches");
-  if (PQresultStatus(res) != PGRES_TUPLES_OK) {
-    fprintf(stderr, "%s", PQerrorMessage(con));
-    exit(1);
-  }
-  tps = atoi(PQgetvalue(res, 0, 0));
-  if (tps < 0) {
-    fprintf(stderr,"count(*) from branches invalid (%d)\n",tps);
-    exit(1);
-  }
-  PQclear(res);
-
-  if (!is_no_vacuum) {
-    fprintf(stderr,"starting vacuum...");
-    res = PQexec(con,"vacuum branches");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-
-    res = PQexec(con,"vacuum tellers");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-
-    res = PQexec(con,"delete from history");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-    res = PQexec(con,"vacuum history");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-      fprintf(stderr, "%s", PQerrorMessage(con));
-      exit(1);
-    }
-    PQclear(res);
-
-    fprintf(stderr,"end.\n");
-
-    if (is_full_vacuum) {
-      fprintf(stderr,"starting full vacuum...");
-      res = PQexec(con,"vacuum analyze accounts");
-      if (PQresultStatus(res) != PGRES_COMMAND_OK) {
-   fprintf(stderr, "%s", PQerrorMessage(con));
-   exit(1);
-      }
-      PQclear(res);
-      fprintf(stderr,"end.\n");
-    }
-  }
-  PQfinish(con);
-
-  /* set random seed */
-  gettimeofday(&tv1, 0);
-  srand((uint)tv1.tv_usec);
-
-  /* get start up time */
-  gettimeofday(&tv1, 0);
-
-  /* make connections to the database */
-  for (i=0;i<nclients;i++) {
-    state[i].con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-    if (PQstatus(state[i].con) == CONNECTION_BAD) {
-      fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
-      fprintf(stderr, "%s", PQerrorMessage(state[i].con));
-      exit(1);
-    }
-  }
-
-  /* time after connections set up */
-  gettimeofday(&tv2, 0);
-
-  /* send start up quries in async manner */
-  for (i=0;i<nclients;i++) {
-    if (ttype == 0) {
-      doOne(state, i, debug);
-    } else if (ttype == 1) {
-      doSelectOnly(state, i, debug);
-    }
-  }
-
-  for (;;) {
-    if (remains <= 0) {    /* all done ? */
-      disconnect_all(state);
-      /* get end time */
-      gettimeofday(&tv3, 0);
-      printResults(ttype, state, &tv1,&tv2,&tv3);
-      exit(0);
-    }
-
-    FD_ZERO(&input_mask);
-
-    maxsock = 0;
-    for (i=0;i<nclients;i++) {
-      if (state[i].con) {
-   int sock = PQsocket(state[i].con);
-   if (sock < 0) {
-     fprintf(stderr,"Client %d: PQsock failed\n",i);
-     disconnect_all(state);
-     exit(1);
-   }
-   FD_SET(sock, &input_mask);
-   if (maxsock < sock) {
-     maxsock = sock;
-   }
-      }
-    }
-
-    if ((nsocks = select(maxsock +1, &input_mask, (fd_set *)NULL,
-            (fd_set *)NULL, (struct timeval *)NULL)) < 0) {
-      if (errno == EINTR) {
-   continue;
-      }
-      /* must be something wrong */
-      disconnect_all(state);
-      fprintf(stderr,"select failed: %s\n",strerror(errno));
-      exit(1);
-    } else if (nsocks == 0) { /* timeout */
-      fprintf(stderr,"select timeout\n");
-      for (i=0;i<nclients;i++) {
-   fprintf(stderr,"client %d:state %d cnt %d ecnt %d listen %d\n",
-       i,state[i].state,state[i].cnt,state[i].ecnt,state[i].listen);
-      }
-      exit(0);
-    }
-
-    /* ok, backend returns reply */
-    for (i=0;i<nclients;i++) {
-      if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask)) {
-   if (ttype == 0) {
-     doOne(state, i, debug);
-   } else if (ttype == 1) {
-     doSelectOnly(state, i, debug);
-   }
-      }
-    }
-  }
+#ifdef RLIMIT_NOFILE           /* most platform uses RLIMIT_NOFILE */
+               if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
+               {
+#else                          /* but BSD doesn't ... */
+               if (getrlimit(RLIMIT_OFILE, &rlim) == -1)
+               {
+#endif  /* HAVE_RLIMIT_NOFILE */
+                   fprintf(stderr, "getrlimit failed. reason: %s\n", strerror(errno));
+                   exit(1);
+               }
+               if (rlim.rlim_cur <= (nclients + 2))
+               {
+                   fprintf(stderr, "You need at least %d open files resource but you are only allowed to use %ld.\n", nclients + 2, rlim.rlim_cur);
+                   fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
+                   exit(1);
+               }
+#endif  /* #ifndef __CYGWIN32__ */
+               break;
+           case 's':
+               tps = atoi(optarg);
+               if (tps <= 0)
+               {
+                   fprintf(stderr, "wrong scaling factor: %d\n", tps);
+                   exit(1);
+               }
+               break;
+           case 't':
+               nxacts = atoi(optarg);
+               if (nxacts <= 0)
+               {
+                   fprintf(stderr, "wrong number of transactions: %d\n", nxacts);
+                   exit(1);
+               }
+               break;
+           default:
+               usage();
+               exit(1);
+               break;
+       }
+   }
+
+   if (argc > optind)
+       dbName = argv[optind];
+   else
+   {
+       dbName = getenv("USER");
+       if (dbName == NULL)
+           dbName = "";
+   }
+
+   if (is_init_mode)
+   {
+       init(pghost, pgport, dbName);
+       exit(0);
+   }
+
+   remains = nclients;
+
+   if (debug)
+   {
+       printf("pghost: %s pgport: %s nclients: %d nxacts: %d dbName: %s\n",
+              pghost, pgport, nclients, nxacts, dbName);
+   }
+
+   /* opening connection... */
+   con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+   if (PQstatus(con) == CONNECTION_BAD)
+   {
+       fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
+
+   /*
+    * get the scaling factor that should be same as count(*) from
+    * branches...
+    */
+   res = PQexec(con, "select count(*) from branches");
+   if (PQresultStatus(res) != PGRES_TUPLES_OK)
+   {
+       fprintf(stderr, "%s", PQerrorMessage(con));
+       exit(1);
+   }
+   tps = atoi(PQgetvalue(res, 0, 0));
+   if (tps < 0)
+   {
+       fprintf(stderr, "count(*) from branches invalid (%d)\n", tps);
+       exit(1);
+   }
+   PQclear(res);
+
+   if (!is_no_vacuum)
+   {
+       fprintf(stderr, "starting vacuum...");
+       res = PQexec(con, "vacuum branches");
+       if (PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+
+       res = PQexec(con, "vacuum tellers");
+       if (PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+
+       res = PQexec(con, "delete from history");
+       if (PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+       res = PQexec(con, "vacuum history");
+       if (PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+
+       fprintf(stderr, "end.\n");
+
+       if (is_full_vacuum)
+       {
+           fprintf(stderr, "starting full vacuum...");
+           res = PQexec(con, "vacuum analyze accounts");
+           if (PQresultStatus(res) != PGRES_COMMAND_OK)
+           {
+               fprintf(stderr, "%s", PQerrorMessage(con));
+               exit(1);
+           }
+           PQclear(res);
+           fprintf(stderr, "end.\n");
+       }
+   }
+   PQfinish(con);
+
+   /* set random seed */
+   gettimeofday(&tv1, 0);
+   srand((uint) tv1.tv_usec);
+
+   /* get start up time */
+   gettimeofday(&tv1, 0);
+
+   /* make connections to the database */
+   for (i = 0; i < nclients; i++)
+   {
+       state[i].con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+       if (PQstatus(state[i].con) == CONNECTION_BAD)
+       {
+           fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
+           fprintf(stderr, "%s", PQerrorMessage(state[i].con));
+           exit(1);
+       }
+   }
+
+   /* time after connections set up */
+   gettimeofday(&tv2, 0);
+
+   /* send start up quries in async manner */
+   for (i = 0; i < nclients; i++)
+   {
+       if (ttype == 0)
+           doOne(state, i, debug);
+       else if (ttype == 1)
+           doSelectOnly(state, i, debug);
+   }
+
+   for (;;)
+   {
+       if (remains <= 0)
+       {                       /* all done ? */
+           disconnect_all(state);
+           /* get end time */
+           gettimeofday(&tv3, 0);
+           printResults(ttype, state, &tv1, &tv2, &tv3);
+           exit(0);
+       }
+
+       FD_ZERO(&input_mask);
+
+       maxsock = 0;
+       for (i = 0; i < nclients; i++)
+       {
+           if (state[i].con)
+           {
+               int         sock = PQsocket(state[i].con);
+
+               if (sock < 0)
+               {
+                   fprintf(stderr, "Client %d: PQsock failed\n", i);
+                   disconnect_all(state);
+                   exit(1);
+               }
+               FD_SET(sock, &input_mask);
+               if (maxsock < sock)
+                   maxsock = sock;
+           }
+       }
+
+       if ((nsocks = select(maxsock + 1, &input_mask, (fd_set *) NULL,
+                         (fd_set *) NULL, (struct timeval *) NULL)) < 0)
+       {
+           if (errno == EINTR)
+               continue;
+           /* must be something wrong */
+           disconnect_all(state);
+           fprintf(stderr, "select failed: %s\n", strerror(errno));
+           exit(1);
+       }
+       else if (nsocks == 0)
+       {                       /* timeout */
+           fprintf(stderr, "select timeout\n");
+           for (i = 0; i < nclients; i++)
+           {
+               fprintf(stderr, "client %d:state %d cnt %d ecnt %d listen %d\n",
+                       i, state[i].state, state[i].cnt, state[i].ecnt, state[i].listen);
+           }
+           exit(0);
+       }
+
+       /* ok, backend returns reply */
+       for (i = 0; i < nclients; i++)
+       {
+           if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask))
+           {
+               if (ttype == 0)
+                   doOne(state, i, debug);
+               else if (ttype == 1)
+                   doSelectOnly(state, i, debug);
+           }
+       }
+   }
 }
index 9407e6a21b3d37425140ad96b43f1e08affedca8..cb8323d9c9b75650429cc753536fcf65682419bf 100644 (file)
@@ -23,7 +23,7 @@
 #define ISO8859
 
 #define MIN(x, y)  ((x) < (y) ? (x) : (y))
-#define VALUE(char)    ((char) - '0')
+#define VALUE(char) ((char) - '0')
 #define DIGIT(val) ((val) + '0')
 #define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
 #ifndef ISO8859
@@ -89,9 +89,8 @@ string_output(unsigned char *data, int size)
                break;
            case '{':
                /* Escape beginning of string, to distinguish from arrays */
-               if (p == data) {
+               if (p == data)
                    len++;
-               }
                break;
            default:
                if (NOTPRINTABLE(*p))
@@ -137,9 +136,8 @@ string_output(unsigned char *data, int size)
                break;
            case '{':
                /* Escape beginning of string, to distinguish from arrays */
-               if (p == data) {
+               if (p == data)
                    *r++ = '\\';
-               }
                *r++ = c;
                break;
            default:
@@ -361,14 +359,15 @@ c_charin(unsigned 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 e79d7fd28febc7392d56c8102c166561c2182883..556c33660ce7b18c1c5d9585bce44cfff4531d9f 100644 (file)
@@ -1,24 +1,25 @@
 #ifndef STRING_IO_H
 #define STRING_IO_H
 
-unsigned charstring_output(unsigned char *data, int size);
-unsigned charstring_input(unsigned char *str, int size, int hdrsize,
-                             int *rtn_size);
-unsigned charc_charout(int32 c);
-unsigned charc_textout(struct varlena * vlena);
-unsigned charc_varcharout(unsigned char *s);
+unsigned char *string_output(unsigned char *data, int size);
+unsigned char *string_input(unsigned char *str, int size, int hdrsize,
+            int *rtn_size);
+unsigned char *c_charout(int32 c);
+unsigned char *c_textout(struct varlena * vlena);
+unsigned char *c_varcharout(unsigned char *s);
 
 #if 0
-struct varlena*    c_textin(unsigned char *str);
-int32*         c_charin(unsigned char *str)
+struct varlena *c_textin(unsigned char *str);
+int32 *
+c_charin(unsigned 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 1a596d515401696034e38dff0fedd0256500b059..1e37a54cf01ec2470e75e78fdde185ee6c2d1418 100644 (file)
@@ -96,8 +96,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 3f0449e7e4507a1ffae70bec4d28adcbb69329fb..82ecb3b9ea00c22b98b9c9bbe244ae2e7ed84230 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 4eec6ed6d077438bd3d637a17536b2f948d7620a..d30e4c7fe64e350bbee4ffed062a74e7d679e1ab 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.61 2000/01/26 05:55:53 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.62 2000/04/12 17:14:36 momjian Exp $
  *
  * NOTES
  *   The old interface functions have been converted to macros
@@ -137,9 +137,9 @@ DataFill(char *data,
                                   *((int32 *) value[i]));
                break;
            default:
-                Assert(att[i]->attlen >= 0);
-                memmove(data, DatumGetPointer(value[i]),
-                        (size_t)(att[i]->attlen));
+               Assert(att[i]->attlen >= 0);
+               memmove(data, DatumGetPointer(value[i]),
+                       (size_t) (att[i]->attlen));
                break;
        }
        data = (char *) att_addlength((long) data, att[i]->attlen, value[i]);
@@ -326,7 +326,7 @@ nocachegetattr(HeapTuple tuple,
    Form_pg_attribute *att = tupleDesc->attrs;
    int         slow = 0;       /* do we have to walk nulls? */
 
-    (void)isnull; /*not used*/
+   (void) isnull;              /* not used */
 #ifdef IN_MACRO
 /* This is handled in the macro */
    Assert(attnum > 0);
@@ -681,7 +681,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
        len += bitmaplen;
    }
 
-   hoff = len = MAXALIGN(len);     /* be conservative here */
+   hoff = len = MAXALIGN(len); /* be conservative here */
 
    len += ComputeDataSize(tupleDescriptor, value, nulls);
 
@@ -806,11 +806,9 @@ void
 heap_freetuple(HeapTuple htup)
 {
    if (htup->t_data != NULL)
-       if (htup->t_datamcxt != NULL && (char *)(htup->t_data) != 
-                                   ((char *) htup + HEAPTUPLESIZE))
-       {
+       if (htup->t_datamcxt != NULL && (char *) (htup->t_data) !=
+           ((char *) htup + HEAPTUPLESIZE))
            elog(NOTICE, "TELL Jan Wieck: heap_freetuple() found separate t_data");
-       }
 
    pfree(htup);
 }
@@ -835,7 +833,7 @@ heap_addheader(uint32 natts,    /* max domain index */
 
    len = offsetof(HeapTupleHeaderData, t_bits);
 
-   hoff = len = MAXALIGN(len);     /* be conservative */
+   hoff = len = MAXALIGN(len); /* be conservative */
    len += structlen;
    tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
    tuple->t_datamcxt = CurrentMemoryContext;
@@ -850,8 +848,8 @@ heap_addheader(uint32 natts,    /* max domain index */
    td->t_infomask = 0;
    td->t_infomask |= HEAP_XMAX_INVALID;
 
-    if (structlen > 0)
-        memmove((char *) td + hoff, structure, (size_t)structlen);
+   if (structlen > 0)
+       memmove((char *) td + hoff, structure, (size_t) structlen);
 
    return tuple;
 }
index 438318747d24cd75b895fde89728fac6b9180019..e11ddbc1dc9b495cd5a81438268d48f2692088aa 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.42 2000/01/26 05:55:53 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.43 2000/04/12 17:14:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,7 +60,7 @@ index_formtuple(TupleDesc tupleDescriptor,
 
    hoff = IndexInfoFindDataOffset(infomask);
    size = hoff + ComputeDataSize(tupleDescriptor, value, null);
-   size = MAXALIGN(size);  /* be conservative */
+   size = MAXALIGN(size);      /* be conservative */
 
    tp = (char *) palloc(size);
    tuple = (IndexTuple) tp;
@@ -134,7 +134,7 @@ nocache_index_getattr(IndexTuple tup,
    int         data_off;       /* tuple data offset */
    Form_pg_attribute *att = tupleDesc->attrs;
 
-    (void)isnull;
+   (void) isnull;
    /* ----------------
     *  sanity checks
     * ----------------
index b2af4ff932ecac4ba53f1dd9e78e9b8b04e5bd1e..1e8d2ae00343a5964c4a5d01b164413c0dc3c4f8 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.61 2000/01/31 04:35:48 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.62 2000/04/12 17:14:37 momjian Exp $
  *
  * NOTES
  *   some of the executor utility code such as "ExecTypeFromTL" should be
@@ -229,17 +229,19 @@ FreeTupleDesc(TupleDesc tupdesc)
 bool
 equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 {
-   int     i;
+   int         i;
 
    if (tupdesc1->natts != tupdesc2->natts)
        return false;
    for (i = 0; i < tupdesc1->natts; i++)
    {
-       Form_pg_attribute   attr1 = tupdesc1->attrs[i];
-       Form_pg_attribute   attr2 = tupdesc2->attrs[i];
+       Form_pg_attribute attr1 = tupdesc1->attrs[i];
+       Form_pg_attribute attr2 = tupdesc2->attrs[i];
 
-       /* We do not need to check every single field here, and in fact
-        * some fields such as attdisbursion probably shouldn't be compared.
+       /*
+        * We do not need to check every single field here, and in fact
+        * some fields such as attdisbursion probably shouldn't be
+        * compared.
         */
        if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
            return false;
@@ -254,8 +256,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
    }
    if (tupdesc1->constr != NULL)
    {
-       TupleConstr    *constr1 = tupdesc1->constr;
-       TupleConstr    *constr2 = tupdesc2->constr;
+       TupleConstr *constr1 = tupdesc1->constr;
+       TupleConstr *constr2 = tupdesc2->constr;
 
        if (constr2 == NULL)
            return false;
@@ -263,8 +265,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
            return false;
        for (i = 0; i < (int) constr1->num_defval; i++)
        {
-           AttrDefault    *defval1 = constr1->defval + i;
-           AttrDefault    *defval2 = constr2->defval + i;
+           AttrDefault *defval1 = constr1->defval + i;
+           AttrDefault *defval2 = constr2->defval + i;
 
            if (defval1->adnum != defval2->adnum)
                return false;
@@ -275,8 +277,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
            return false;
        for (i = 0; i < (int) constr1->num_check; i++)
        {
-           ConstrCheck    *check1 = constr1->check + i;
-           ConstrCheck    *check2 = constr2->check + i;
+           ConstrCheck *check1 = constr1->check + i;
+           ConstrCheck *check2 = constr2->check + i;
 
            if (strcmp(check1->ccname, check2->ccname) != 0)
                return false;
@@ -585,8 +587,9 @@ BuildDescForRelation(List *schema, char *relname)
            constr->has_not_null = true;
        desc->attrs[attnum - 1]->attnotnull = entry->is_not_null;
 
-       /* Note we copy only pre-cooked default expressions.
-        * Digestion of raw ones is someone else's problem.
+       /*
+        * Note we copy only pre-cooked default expressions. Digestion of
+        * raw ones is someone else's problem.
         */
        if (entry->cooked_default != NULL)
        {
index 9e93f1d652da5d13340c6b53e717734a05468832..66a3702e438d3630486ffb97722a5fcac7583bb3 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.52 2000/03/17 02:36:00 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.53 2000/04/12 17:14:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,8 +52,10 @@ void     gistdelete(Relation r, ItemPointer tid);
 static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t);
 static void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
               Relation r, Page pg, OffsetNumber o, int b, bool l);
+
 #ifdef GISTDEBUG
 static char *int_range_out(INTRANGE *r);
+
 #endif
 
 /*
@@ -98,7 +100,7 @@ gistbuild(Relation heap,
 
    /* no locking is needed */
 
-   CommandCounterIncrement();      /* so we can see the new pg_index tuple */
+   CommandCounterIncrement();  /* so we can see the new pg_index tuple */
 
    initGISTstate(&giststate, index);
 
@@ -186,7 +188,7 @@ gistbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
            /* SetSlotContents(slot, htup); */
            slot->val = htup;
-           if (! ExecQual((List *) pred, econtext, false))
+           if (!ExecQual((List *) pred, econtext, false))
                continue;
 #endif  /* OMIT_PARTIAL_INDEX */
        }
@@ -272,18 +274,18 @@ gistbuild(Relation heap,
    /*
     * Since we just counted the tuples in the heap, we update its stats
     * in pg_class to guarantee that the planner takes advantage of the
-    * index we just created.  But, only update statistics during
-    * normal index definitions, not for indices on system catalogs
-    * created during bootstrap processing.  We must close the relations
-    * before updating statistics to guarantee that the relcache entries
-    * are flushed when we increment the command counter in UpdateStats().
-    * But we do not release any locks on the relations; those will be
-    * held until end of transaction.
+    * index we just created.  But, only update statistics during normal
+    * index definitions, not for indices on system catalogs created
+    * during bootstrap processing.  We must close the relations before
+    * updating statistics to guarantee that the relcache entries are
+    * flushed when we increment the command counter in UpdateStats(). But
+    * we do not release any locks on the relations; those will be held
+    * until end of transaction.
     */
    if (IsNormalProcessingMode())
    {
-       Oid     hrelid = RelationGetRelid(heap);
-       Oid     irelid = RelationGetRelid(index);
+       Oid         hrelid = RelationGetRelid(heap);
+       Oid         irelid = RelationGetRelid(index);
        bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
index a7d1faf43db1b9ffcf45fda183f9e0415aa54a62..2196e897e4a12ecccfc52edd3170af13a22c93f4 100644 (file)
@@ -266,7 +266,7 @@ gistdropscan(IndexScanDesc s)
        prev = l;
 
    if (l == (GISTScanList) NULL)
-       elog(ERROR, "GiST scan list corrupted -- cannot find 0x%p", (void*)s);
+       elog(ERROR, "GiST scan list corrupted -- cannot find 0x%p", (void *) s);
 
    if (prev == (GISTScanList) NULL)
        GISTScans = l->gsl_next;
index d116aa1a4997131f44738527c1d180c45cfb6c50..1e5bc15bf2fadbe3339da23beb059622168bcf08 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.36 2000/03/01 05:39:22 inoue Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.37 2000/04/12 17:14:43 momjian Exp $
  *
  * NOTES
  *   This file contains only the public interface routines.
@@ -149,7 +149,7 @@ hashbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
            /* SetSlotContents(slot, htup); */
            slot->val = htup;
-           if (! ExecQual((List *) pred, econtext, false))
+           if (!ExecQual((List *) pred, econtext, false))
                continue;
 #endif  /* OMIT_PARTIAL_INDEX */
        }
@@ -230,18 +230,18 @@ hashbuild(Relation heap,
    /*
     * Since we just counted the tuples in the heap, we update its stats
     * in pg_class to guarantee that the planner takes advantage of the
-    * index we just created.  But, only update statistics during
-    * normal index definitions, not for indices on system catalogs
-    * created during bootstrap processing.  We must close the relations
-    * before updating statistics to guarantee that the relcache entries
-    * are flushed when we increment the command counter in UpdateStats().
-    * But we do not release any locks on the relations; those will be
-    * held until end of transaction.
+    * index we just created.  But, only update statistics during normal
+    * index definitions, not for indices on system catalogs created
+    * during bootstrap processing.  We must close the relations before
+    * updating statistics to guarantee that the relcache entries are
+    * flushed when we increment the command counter in UpdateStats(). But
+    * we do not release any locks on the relations; those will be held
+    * until end of transaction.
     */
    if (IsNormalProcessingMode())
    {
-       Oid     hrelid = RelationGetRelid(heap);
-       Oid     irelid = RelationGetRelid(index);
+       Oid         hrelid = RelationGetRelid(heap);
+       Oid         irelid = RelationGetRelid(index);
        bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
index 78af6353f0ba15c417057a9004851fa8d8ee1083..80d9ac3741c01566689620526f10ce428ea9ded1 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.24 2000/02/21 03:36:46 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.25 2000/04/12 17:14:44 momjian Exp $
  *
  * NOTES
  *   These functions are stored in pg_amproc.  For each operator class
@@ -146,14 +146,14 @@ hashoidvector(Oid *key)
    int         i;
    uint32      result = 0;
 
-   for (i = INDEX_MAX_KEYS; --i >= 0; )
+   for (i = INDEX_MAX_KEYS; --i >= 0;)
        result = (result << 1) ^ (~(uint32) key[i]);
    return result;
 }
 
 /*
  * Note: hashint2vector currently can't be used as a user hash table
- * hash function, because it has no pg_proc entry.  We only need it
+ * hash function, because it has no pg_proc entry. We only need it
  * for catcache indexing.
  */
 uint32
@@ -162,7 +162,7 @@ hashint2vector(int16 *key)
    int         i;
    uint32      result = 0;
 
-   for (i = INDEX_MAX_KEYS; --i >= 0; )
+   for (i = INDEX_MAX_KEYS; --i >= 0;)
        result = (result << 1) ^ (~(uint32) key[i]);
    return result;
 }
index d44ba69b9bd97d9ad39919d77c0224d67e08ad17..979baf8d70c72ebfab42479ee9a54ee4dbd1198e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.22 2000/01/26 05:55:55 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.23 2000/04/12 17:14:44 momjian Exp $
  *
  * NOTES
  *   Because we can be doing an index scan on a relation while we
@@ -75,7 +75,7 @@ _hash_dropscan(IndexScanDesc scan)
        last = chk;
 
    if (chk == (HashScanList) NULL)
-       elog(ERROR, "hash scan list trashed; can't find 0x%p", (void*)scan);
+       elog(ERROR, "hash scan list trashed; can't find 0x%p", (void *) scan);
 
    if (last == (HashScanList) NULL)
        HashScans = chk->hashsl_next;
index d6ae498d19d285745c4780e46d7959eae7279804..21f45f471370e38d8dc5ca54a554d87d0674022b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.23 2000/03/17 02:36:02 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.24 2000/04/12 17:14:44 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -351,7 +351,7 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir, Buffer metabuf)
                            opaque = (HashPageOpaque) PageGetSpecialPointer(page);
                            Assert(opaque->hasho_bucket == bucket);
                            while (PageIsEmpty(page) &&
-                                  BlockNumberIsValid(opaque->hasho_nextblkno))
+                            BlockNumberIsValid(opaque->hasho_nextblkno))
                                _hash_readnext(rel, &buf, &page, &opaque);
                            maxoff = PageGetMaxOffsetNumber(page);
                            offnum = FirstOffsetNumber;
index d51705fa4726ff60cde33d7fd8f423aa8bffa8c2..29d6c9e0f9ec0208fb191a52eed1f75252f5edc9 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.66 2000/02/09 03:49:47 inoue Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.67 2000/04/12 17:14:45 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -23,7 +23,7 @@
  *     heap_fetch      - retrive tuple with tid
  *     heap_insert     - insert tuple into a relation
  *     heap_delete     - delete a tuple from a relation
- *     heap_update - replace a tuple in a relation with another tuple
+ *     heap_update - replace a tuple in a relation with another tuple
  *     heap_markpos    - mark scan position
  *     heap_restrpos   - restore position to marked location
  *
@@ -120,9 +120,9 @@ initscan(HeapScanDesc scan,
         * ----------------
         */
        scan->rs_ntup.t_datamcxt = scan->rs_ctup.t_datamcxt =
-       scan->rs_ptup.t_datamcxt = NULL;
+           scan->rs_ptup.t_datamcxt = NULL;
        scan->rs_ntup.t_data = scan->rs_ctup.t_data =
-       scan->rs_ptup.t_data = NULL;
+           scan->rs_ptup.t_data = NULL;
        scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
    }
    else if (atend)
@@ -188,8 +188,9 @@ unpinscan(HeapScanDesc scan)
    if (BufferIsValid(scan->rs_nbuf))
        ReleaseBuffer(scan->rs_nbuf);
 
-   /* we don't bother to clear rs_pbuf etc --- caller must
-    * reinitialize them if scan descriptor is not being deleted.
+   /*
+    * we don't bother to clear rs_pbuf etc --- caller must reinitialize
+    * them if scan descriptor is not being deleted.
     */
 }
 
@@ -544,7 +545,7 @@ heap_open(Oid relationId, LOCKMODE lockmode)
    if (lockmode == NoLock)
        return r;               /* caller must check RelationIsValid! */
 
-   if (! RelationIsValid(r))
+   if (!RelationIsValid(r))
        elog(ERROR, "Relation %u does not exist", relationId);
 
    LockRelation(r, lockmode);
@@ -586,7 +587,7 @@ heap_openr(const char *relationName, LOCKMODE lockmode)
    if (lockmode == NoLock)
        return r;               /* caller must check RelationIsValid! */
 
-   if (! RelationIsValid(r))
+   if (!RelationIsValid(r))
        elog(ERROR, "Relation '%s' does not exist", relationName);
 
    LockRelation(r, lockmode);
@@ -646,7 +647,7 @@ heap_beginscan(Relation relation,
     *  sanity checks
     * ----------------
     */
-   if (! RelationIsValid(relation))
+   if (!RelationIsValid(relation))
        elog(ERROR, "heap_beginscan: !RelationIsValid(relation)");
 
    /* ----------------
@@ -659,7 +660,7 @@ heap_beginscan(Relation relation,
     *  Acquire AccessShareLock for the duration of the scan
     *
     *  Note: we could get an SI inval message here and consequently have
-    *  to rebuild the relcache entry.  The refcount increment above
+    *  to rebuild the relcache entry.  The refcount increment above
     *  ensures that we will rebuild it and not just flush it...
     * ----------------
     */
@@ -681,6 +682,7 @@ heap_beginscan(Relation relation,
    scan->rs_nkeys = (short) nkeys;
 
    if (nkeys)
+
        /*
         * we do this here instead of in initscan() because heap_rescan
         * also calls initscan() and we don't want to allocate memory
@@ -847,9 +849,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 
        if (scan->rs_ptup.t_data == scan->rs_ctup.t_data &&
            BufferIsInvalid(scan->rs_pbuf))
-       {
            return NULL;
-       }
 
        /*
         * Copy the "current" tuple/buffer to "next". Pin/unpin the
@@ -1095,8 +1095,10 @@ heap_fetch(Relation relation,
    }
    else
    {
-       /* All checks passed, so return the tuple as valid.
-        * Caller is now responsible for releasing the buffer.
+
+       /*
+        * All checks passed, so return the tuple as valid. Caller is now
+        * responsible for releasing the buffer.
         */
        *userbuf = buffer;
    }
@@ -1109,17 +1111,18 @@ heap_fetch(Relation relation,
  */
 ItemPointer
 heap_get_latest_tid(Relation relation,
-          Snapshot snapshot,
-          ItemPointer tid)
+                   Snapshot snapshot,
+                   ItemPointer tid)
 {
    ItemId      lp = NULL;
    Buffer      buffer;
    PageHeader  dp;
-   OffsetNumber    offnum;
-   HeapTupleData   tp;
-   HeapTupleHeader t_data;
-   ItemPointerData ctid;
-   bool        invalidBlock,linkend;
+   OffsetNumber offnum;
+   HeapTupleData tp;
+   HeapTupleHeader t_data;
+   ItemPointerData ctid;
+   bool        invalidBlock,
+               linkend;
 
    /* ----------------
     *  get the buffer from the relation descriptor
@@ -1149,11 +1152,11 @@ heap_get_latest_tid(Relation relation,
            invalidBlock = false;
    }
    if (invalidBlock)
-   {   
+   {
        LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
        ReleaseBuffer(buffer);
        return NULL;
-   } 
+   }
 
    /* ----------------
     *  more sanity checks
@@ -1175,7 +1178,7 @@ heap_get_latest_tid(Relation relation,
                       snapshot, 0, (ScanKey) NULL);
 
    linkend = true;
-   if ((t_data->t_infomask & HEAP_XMAX_COMMITTED) && 
+   if ((t_data->t_infomask & HEAP_XMAX_COMMITTED) &&
        !ItemPointerEquals(tid, &ctid))
        linkend = false;
 
@@ -1186,7 +1189,7 @@ heap_get_latest_tid(Relation relation,
    {
        if (linkend)
            return NULL;
-       return heap_get_latest_tid(relation, snapshot, &ctid); 
+       return heap_get_latest_tid(relation, snapshot, &ctid);
    }
 
    return tid;
@@ -1300,10 +1303,11 @@ l1:
        LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
        if (TransactionIdDidAbort(xwait))
            goto l1;
-       /* 
-        * xwait is committed but if xwait had just marked
-        * the tuple for update then some other xaction could 
-        * update this tuple before we got to this point.
+
+       /*
+        * xwait is committed but if xwait had just marked the tuple for
+        * update then some other xaction could update this tuple before
+        * we got to this point.
         */
        if (tp.t_data->t_xmax != xwait)
            goto l1;
@@ -1345,11 +1349,11 @@ l1:
 }
 
 /*
- * heap_update - replace a tuple
+ * heap_update - replace a tuple
  */
 int
 heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
-            ItemPointer ctid)
+           ItemPointer ctid)
 {
    ItemId      lp;
    HeapTupleData oldtup;
@@ -1396,10 +1400,11 @@ l2:
        LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
        if (TransactionIdDidAbort(xwait))
            goto l2;
-       /* 
-        * xwait is committed but if xwait had just marked
-        * the tuple for update then some other xaction could 
-        * update this tuple before we got to this point.
+
+       /*
+        * xwait is committed but if xwait had just marked the tuple for
+        * update then some other xaction could update this tuple before
+        * we got to this point.
         */
        if (oldtup.t_data->t_xmax != xwait)
            goto l2;
@@ -1521,10 +1526,11 @@ l3:
        LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
        if (TransactionIdDidAbort(xwait))
            goto l3;
-       /* 
-        * xwait is committed but if xwait had just marked
-        * the tuple for update then some other xaction could 
-        * update this tuple before we got to this point.
+
+       /*
+        * xwait is committed but if xwait had just marked the tuple for
+        * update then some other xaction could update this tuple before
+        * we got to this point.
         */
        if (tuple->t_data->t_xmax != xwait)
            goto l3;
index b269ca90170c0eb3f1610df05533cc8452e4666f..3fc2a69df1a3fe914c9ee30418bda41cbad593b0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Id: hio.c,v 1.30 2000/03/17 02:36:02 tgl Exp $
+ *   $Id: hio.c,v 1.31 2000/04/12 17:14:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,7 +51,7 @@ RelationPutHeapTuple(Relation relation,
    IncrHeapAccessStat(global_RelationPutHeapTuple);
 
    pageHeader = (Page) BufferGetPage(buffer);
-   len = MAXALIGN(tuple->t_len); /* be conservative */
+   len = MAXALIGN(tuple->t_len);       /* be conservative */
    Assert(len <= PageGetFreeSpace(pageHeader));
 
    offnum = PageAddItem((Page) pageHeader, (Item) tuple->t_data,
@@ -108,11 +108,11 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
    ItemId      itemId;
    Item        item;
 
-   len = MAXALIGN(tuple->t_len); /* be conservative */
+   len = MAXALIGN(tuple->t_len);       /* be conservative */
 
    /*
-    * If we're gonna fail for oversize tuple, do it right away...
-    * this code should go away eventually.
+    * If we're gonna fail for oversize tuple, do it right away... this
+    * code should go away eventually.
     */
    if (len > MaxTupleSize)
        elog(ERROR, "Tuple is too big: size %u, max size %ld",
@@ -136,8 +136,8 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
    lastblock = RelationGetNumberOfBlocks(relation);
 
    /*
-    * Get the last existing page --- may need to create the first one
-    * if this is a virgin relation.
+    * Get the last existing page --- may need to create the first one if
+    * this is a virgin relation.
     */
    if (lastblock == 0)
    {
@@ -168,12 +168,14 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
 
        if (len > PageGetFreeSpace(pageHeader))
        {
+
            /*
-            * BUG: by elog'ing here, we leave the new buffer locked and not
-            * marked dirty, which may result in an invalid page header
-            * being left on disk.  But we should not get here given the
-            * test at the top of the routine, and the whole deal should
-            * go away when we implement tuple splitting anyway...
+            * BUG: by elog'ing here, we leave the new buffer locked and
+            * not marked dirty, which may result in an invalid page
+            * header being left on disk.  But we should not get here
+            * given the test at the top of the routine, and the whole
+            * deal should go away when we implement tuple splitting
+            * anyway...
             */
            elog(ERROR, "Tuple is too big: size %u", len);
        }
index 9176521a5fce192811badda304a4fb70dd787e76..3aadfb2cde08c44b2665333c844616c6d82af574 100644 (file)
@@ -2,13 +2,13 @@
  *
  * tuptoaster.c
  *   Support routines for external and compressed storage of
- *    variable size attributes.
+ *   variable size attributes.
  *
  * Copyright (c) 2000, PostgreSQL Global Development Group
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.2 2000/01/20 21:50:59 petere Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.3 2000/04/12 17:14:45 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
 #ifdef TUPLE_TOASTER_ACTIVE
 
 void
-heap_tuple_toast_attrs (Relation rel, HeapTuple newtup, HeapTuple oldtup)
+heap_tuple_toast_attrs(Relation rel, HeapTuple newtup, HeapTuple oldtup)
 {
    return;
 }
 
 
-varattrib *
-heap_tuple_untoast_attr (varattrib *attr)
+varattrib  *
+heap_tuple_untoast_attr(varattrib * attr)
 {
    elog(ERROR, "heap_tuple_untoast_attr() called");
 }
 
 
-#endif /* TUPLE_TOASTER_ACTIVE */
+#endif  /* TUPLE_TOASTER_ACTIVE */
index 1bd02f839ad42236df3bdd5e1966495c7cc470f8..3530320637b016172d5817857e5cd6dfe2f575d3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.24 2000/03/14 23:52:01 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.25 2000/04/12 17:14:47 momjian Exp $
  *
  * NOTES
  *   many of the old access method routines have been turned into
@@ -62,7 +62,7 @@
  *
  *     At the end of a scan, the AM's endscan routine undoes the locking,
  *     but does *not* call IndexScanEnd --- the higher-level index_endscan
- *     routine does that.  (We can't do it in the AM because index_endscan
+ *     routine does that.  (We can't do it in the AM because index_endscan
  *     still needs to touch the IndexScanDesc after calling the AM.)
  *
  *     Because of this, the AM does not have a choice whether to call
@@ -114,7 +114,10 @@ RelationGetIndexScan(Relation relation,
    ItemPointerSetInvalid(&scan->currentMarkData);
    ItemPointerSetInvalid(&scan->nextMarkData);
 
-   /* mark cached function lookup data invalid; it will be set on first use */
+   /*
+    * mark cached function lookup data invalid; it will be set on first
+    * use
+    */
    scan->fn_getnext.fn_oid = InvalidOid;
 
    if (numberOfKeys > 0)
index 2335693119829d6fc289c165b1b57b41361f6f72..e0672667c7fbba99d2a58950f13719351e5810f9 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.41 2000/03/14 23:52:01 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.42 2000/04/12 17:14:47 momjian Exp $
  *
  * INTERFACE ROUTINES
  *     index_open      - open an index relation by relationId
  *     index_open - open an index relation by relationId
  *
  *     presently the relcache routines do all the work we need
- *     to open/close index relations.  However, callers of index_open
+ *     to open/close index relations.  However, callers of index_open
  *     expect it to succeed, so we need to check for a failure return.
  *
- *     Note: we acquire no lock on the index.  An AccessShareLock is
+ *     Note: we acquire no lock on the index.  An AccessShareLock is
  *     acquired by index_beginscan (and released by index_endscan).
  * ----------------
  */
@@ -129,7 +129,7 @@ index_open(Oid relationId)
 
    r = RelationIdGetRelation(relationId);
 
-   if (! RelationIsValid(r))
+   if (!RelationIsValid(r))
        elog(ERROR, "Index %u does not exist", relationId);
 
    if (r->rd_rel->relkind != RELKIND_INDEX)
@@ -151,7 +151,7 @@ index_openr(char *relationName)
 
    r = RelationNameGetRelation(relationName);
 
-   if (! RelationIsValid(r))
+   if (!RelationIsValid(r))
        elog(ERROR, "Index '%s' does not exist", relationName);
 
    if (r->rd_rel->relkind != RELKIND_INDEX)
@@ -238,7 +238,7 @@ index_beginscan(Relation relation,
     *  Acquire AccessShareLock for the duration of the scan
     *
     *  Note: we could get an SI inval message here and consequently have
-    *  to rebuild the relcache entry.  The refcount increment above
+    *  to rebuild the relcache entry.  The refcount increment above
     *  ensures that we will rebuild it and not just flush it...
     * ----------------
     */
index fe956ead378aa133c6bc8650239103283b4712ce..b0864e505fac99084e40a3fd33304d7b97044854 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.41 2000/02/18 09:29:16 inoue Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.42 2000/04/12 17:14:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -477,7 +477,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
 {
    HeapTuple   tuple;
    HeapScanDesc scan = NULL;
-   bool    cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
+   bool        cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
 
    if (cachesearch)
    {
@@ -547,7 +547,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
    AttrNumber  attributeNumber;
    int         attributeIndex;
    Oid         operatorClassObjectId[INDEX_MAX_KEYS];
-   bool    cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
+   bool        cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
 
    if (cachesearch)
    {
@@ -674,7 +674,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
            aform = (Form_pg_amop) GETSTRUCT(tuple);
            OperatorRelationFillScanKeyEntry(operatorRelation,
                                             aform->amopopr,
-                   StrategyMapGetScanKeyEntry(map, aform->amopstrategy));
+                  StrategyMapGetScanKeyEntry(map, aform->amopstrategy));
        }
 
        heap_endscan(scan);
index f66b9a0e8e24c79b97446d74d5f80b258374cea9..3e58c677a0082b7ab5c8567065c5ea8ade420f8f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.33 2000/02/10 19:51:38 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.34 2000/04/12 17:14:49 momjian Exp $
  *
  * NOTES
  *     These functions are stored in pg_amproc.  For each operator class
@@ -35,12 +35,12 @@ btint2cmp(int16 a, int16 b)
 int32
 btint4cmp(int32 a, int32 b)
 {
-      if (a > b)
-              return 1;
-      else if (a == b)
-              return 0;
-      else
-              return -1;
+   if (a > b)
+       return 1;
+   else if (a == b)
+       return 0;
+   else
+       return -1;
 }
 
 int32
index b891716a895bec4d02c71a01acec233f274d7ce1..975b53d658ac0a803bbe713722b8afa283be7fdc 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.56 2000/03/17 02:36:03 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.57 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem);
 static Buffer _bt_split(Relation rel, Size keysz, ScanKey scankey,
-                       Buffer buf, OffsetNumber firstright);
+         Buffer buf, OffsetNumber firstright);
 static OffsetNumber _bt_findsplitloc(Relation rel, Size keysz, ScanKey scankey,
-                                    Page page, OffsetNumber start,
-                                    OffsetNumber maxoff, Size llimit);
+                Page page, OffsetNumber start,
+                OffsetNumber maxoff, Size llimit);
 static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
 static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem);
 static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
@@ -267,21 +267,20 @@ _bt_insertonpg(Relation rel,
    itemsz = IndexTupleDSize(btitem->bti_itup)
        + (sizeof(BTItemData) - sizeof(IndexTupleData));
 
-   itemsz = MAXALIGN(itemsz);      /* be safe, PageAddItem will do
-                                        * this but we need to be
-                                        * consistent */
+   itemsz = MAXALIGN(itemsz);  /* be safe, PageAddItem will do this but
+                                * we need to be consistent */
 
    /*
-    * Check whether the item can fit on a btree page at all.
-    * (Eventually, we ought to try to apply TOAST methods if not.)
-    * We actually need to be able to fit three items on every page,
-    * so restrict any one item to 1/3 the per-page available space.
-    * Note that at this point, itemsz doesn't include the ItemId.
+    * Check whether the item can fit on a btree page at all. (Eventually,
+    * we ought to try to apply TOAST methods if not.) We actually need to
+    * be able to fit three items on every page, so restrict any one item
+    * to 1/3 the per-page available space. Note that at this point,
+    * itemsz doesn't include the ItemId.
     */
-   if (itemsz > (PageGetPageSize(page)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData))
+   if (itemsz > (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
        elog(ERROR, "btree: index item size %u exceeds maximum %lu",
             itemsz,
-            (PageGetPageSize(page)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData));
+            (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
 
    /*
     * If we have to insert item on the leftmost page which is the first
@@ -415,8 +414,8 @@ _bt_insertonpg(Relation rel,
        bool        is_root = lpageop->btpo_flags & BTP_ROOT;
 
        /*
-        * Instead of splitting leaf page in the chain of duplicates 
-        * by new duplicate, insert it into some right page.
+        * Instead of splitting leaf page in the chain of duplicates by
+        * new duplicate, insert it into some right page.
         */
        if ((lpageop->btpo_flags & BTP_CHAIN) &&
            (lpageop->btpo_flags & BTP_LEAF) && keys_equal)
@@ -424,8 +423,9 @@ _bt_insertonpg(Relation rel,
            rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
            rpage = BufferGetPage(rbuf);
            rpageop = (BTPageOpaque) PageGetSpecialPointer(rpage);
-           /* 
-            * some checks 
+
+           /*
+            * some checks
             */
            if (!P_RIGHTMOST(rpageop))  /* non-rightmost page */
            {                   /* If we have the same hikey here then
@@ -442,6 +442,7 @@ _bt_insertonpg(Relation rel,
                                     BTGreaterStrategyNumber))
                    elog(FATAL, "btree: hikey is out of order");
                else if (rpageop->btpo_flags & BTP_CHAIN)
+
                    /*
                     * If hikey > scankey then it's last page in chain and
                     * BTP_CHAIN must be OFF
@@ -450,9 +451,7 @@ _bt_insertonpg(Relation rel,
            }
            else
 /* rightmost page */
-           {
                Assert(!(rpageop->btpo_flags & BTP_CHAIN));
-           }
            _bt_relbuf(rel, buf, BT_WRITE);
            return (_bt_insertonpg(rel, rbuf, stack, keysz,
                                   scankey, btitem, afteritem));
@@ -708,7 +707,7 @@ l_spl:  ;
                 */
                if (!parent_chained &&
                    MAXALIGN(IndexTupleDSize(lowLeftItem->bti_itup)) ==
-                   MAXALIGN(IndexTupleDSize(stack->bts_btitem->bti_itup)))
+                 MAXALIGN(IndexTupleDSize(stack->bts_btitem->bti_itup)))
                {
                    _bt_updateitem(rel, keysz, pbuf,
                                   stack->bts_btitem, lowLeftItem);
index 60eaf3a9d23f84277f2a2ca2b14b86061dfd42fe..1a623698f57c34711c62225384e7c73feb510281 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.35 2000/01/26 05:55:58 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.36 2000/04/12 17:14:49 momjian Exp $
  *
  * NOTES
  *    Postgres btree pages look like ordinary relation pages.  The opaque
@@ -257,7 +257,7 @@ _bt_getroot(Relation rel, int access)
    else
    {
        rootblkno = metad->btm_root;
-       _bt_relbuf(rel, metabuf, BT_READ);  /* done with the meta page */
+       _bt_relbuf(rel, metabuf, BT_READ);      /* done with the meta page */
 
        rootbuf = _bt_getbuf(rel, rootblkno, access);
    }
index da5dd70332e5b07a5552b309a98d52828298f684..72969d4d1b79b4729d3bd41aa508ebf6c5476ddd 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.53 2000/02/18 09:29:54 inoue Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.54 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -77,7 +77,7 @@ btbuild(Relation heap,
 #endif
    Node       *pred,
               *oldPred;
-   BTSpool    *spool = NULL;
+   BTSpool    *spool = NULL;
    bool        isunique;
    bool        usefast;
 
@@ -185,7 +185,7 @@ btbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
            /* SetSlotContents(slot, htup); */
            slot->val = htup;
-           if (! ExecQual((List *) pred, econtext, false))
+           if (!ExecQual((List *) pred, econtext, false))
                continue;
 #endif  /* OMIT_PARTIAL_INDEX */
        }
@@ -276,9 +276,9 @@ btbuild(Relation heap,
    }
 
    /*
-    * if we are doing bottom-up btree build, finish the build by
-    * (1) completing the sort of the spool file, (2) inserting the
-    * sorted tuples into btree pages and (3) building the upper levels.
+    * if we are doing bottom-up btree build, finish the build by (1)
+    * completing the sort of the spool file, (2) inserting the sorted
+    * tuples into btree pages and (3) building the upper levels.
     */
    if (usefast)
    {
@@ -298,26 +298,27 @@ btbuild(Relation heap,
    /*
     * Since we just counted the tuples in the heap, we update its stats
     * in pg_class to guarantee that the planner takes advantage of the
-    * index we just created.  But, only update statistics during
-    * normal index definitions, not for indices on system catalogs
-    * created during bootstrap processing.  We must close the relations
-    * before updating statistics to guarantee that the relcache entries
-    * are flushed when we increment the command counter in UpdateStats().
-    * But we do not release any locks on the relations; those will be
-    * held until end of transaction.
+    * index we just created.  But, only update statistics during normal
+    * index definitions, not for indices on system catalogs created
+    * during bootstrap processing.  We must close the relations before
+    * updating statistics to guarantee that the relcache entries are
+    * flushed when we increment the command counter in UpdateStats(). But
+    * we do not release any locks on the relations; those will be held
+    * until end of transaction.
     */
    if (IsNormalProcessingMode())
    {
-       Oid     hrelid = RelationGetRelid(heap);
-       Oid     irelid = RelationGetRelid(index);
+       Oid         hrelid = RelationGetRelid(heap);
+       Oid         irelid = RelationGetRelid(index);
        bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
        index_close(index);
+
        /*
-       UpdateStats(hrelid, nhtups, true);
-       UpdateStats(irelid, nitups, false);
-       */
+        * UpdateStats(hrelid, nhtups, true); UpdateStats(irelid, nitups,
+        * false);
+        */
        UpdateStats(hrelid, nhtups, inplace);
        UpdateStats(irelid, nitups, inplace);
        if (oldPred != NULL)
@@ -623,7 +624,7 @@ _bt_restscan(IndexScanDesc scan)
    BTItem      item;
    BlockNumber blkno;
 
-   LockBuffer(buf, BT_READ);       /* lock buffer first! */
+   LockBuffer(buf, BT_READ);   /* lock buffer first! */
    page = BufferGetPage(buf);
    maxoff = PageGetMaxOffsetNumber(page);
    opaque = (BTPageOpaque) PageGetSpecialPointer(page);
index 95b1bf53ecbf8d332345927fdf7fd1592122c8fe..37469365bcd42e2b37c06346341d6a9bdf9e95ab 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.30 2000/01/26 05:55:58 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.31 2000/04/12 17:14:49 momjian Exp $
  *
  *
  * NOTES
@@ -52,13 +52,16 @@ static void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offn
 void
 AtEOXact_nbtree(void)
 {
-   /* Note: these actions should only be necessary during xact abort;
-    * but they can't hurt during a commit.
+
+   /*
+    * Note: these actions should only be necessary during xact abort; but
+    * they can't hurt during a commit.
     */
 
-   /* Reset the active-scans list to empty.
-    * We do not need to free the list elements, because they're all
-    * palloc()'d, so they'll go away at end of transaction anyway.
+   /*
+    * Reset the active-scans list to empty. We do not need to free the
+    * list elements, because they're all palloc()'d, so they'll go away
+    * at end of transaction anyway.
     */
    BTScans = NULL;
 
@@ -96,7 +99,7 @@ _bt_dropscan(IndexScanDesc scan)
        last = chk;
 
    if (chk == (BTScanList) NULL)
-       elog(ERROR, "btree scan list trashed; can't find 0x%p", (void*)scan);
+       elog(ERROR, "btree scan list trashed; can't find 0x%p", (void *) scan);
 
    if (last == (BTScanList) NULL)
        BTScans = chk->btsl_next;
index f36da9743f852f577e5b0b672dee82ec7c16e745..cad117e5e6174f239764079d3679ef90c2b61157 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.58 2000/03/17 02:36:04 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.59 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -299,9 +299,7 @@ _bt_skeycmp(Relation rel,
            compare = -1;       /* not-NULL key "<" NULL datum */
        }
        else
-       {
            compare = (int32) FMGR_PTR2(&entry->sk_func, keyDatum, attrDatum);
-       }
 
        if (compare != 0)
            break;              /* done when we find unequal attributes */
@@ -368,26 +366,26 @@ _bt_binsrch(Relation rel,
 
    /*
     * If there are no keys on the page, return the first available slot.
-    * Note this covers two cases: the page is really empty (no keys),
-    * or it contains only a high key.  The latter case is possible after
+    * Note this covers two cases: the page is really empty (no keys), or
+    * it contains only a high key.  The latter case is possible after
     * vacuuming.
     */
    if (high < low)
        return low;
 
    /*
-    * Binary search to find the first key on the page >= scan key.
-    * Loop invariant: all slots before 'low' are < scan key, all slots
-    * at or after 'high' are >= scan key.  Also, haveEq is true if the
-    * tuple at 'high' is == scan key.
-    * We can fall out when high == low.
+    * Binary search to find the first key on the page >= scan key. Loop
+    * invariant: all slots before 'low' are < scan key, all slots at or
+    * after 'high' are >= scan key.  Also, haveEq is true if the tuple at
+    * 'high' is == scan key. We can fall out when high == low.
     */
    high++;                     /* establish the loop invariant for high */
    haveEq = false;
 
    while (high > low)
    {
-       OffsetNumber    mid = low + ((high - low) / 2);
+       OffsetNumber mid = low + ((high - low) / 2);
+
        /* We have low <= mid < high, so mid points at a real slot */
 
        result = _bt_compare(rel, itupdesc, page, keysz, scankey, mid);
@@ -403,7 +401,7 @@ _bt_binsrch(Relation rel,
 
    /*--------------------
     * At this point we have high == low, but be careful: they could point
-    * past the last slot on the page.  We also know that haveEq is true
+    * past the last slot on the page.  We also know that haveEq is true
     * if and only if there is an equal key (in which case high&low point
     * at the first equal key).
     *
@@ -443,18 +441,20 @@ _bt_binsrch(Relation rel,
 
    if (haveEq)
    {
+
        /*
         * There is an equal key.  We return either the first equal key
         * (which we just found), or the last lesser key.
         *
-        * We need not check srchtype != BT_DESCENT here, since if that
-        * is true then natts == keysz by assumption.
+        * We need not check srchtype != BT_DESCENT here, since if that is
+        * true then natts == keysz by assumption.
         */
        if (natts == keysz)
            return low;         /* return first equal key */
    }
    else
    {
+
        /*
         * There is no equal key.  We return either the first greater key
         * (which we just found), or the last lesser key.
@@ -524,6 +524,7 @@ _bt_compare(Relation rel,
        && P_LEFTMOST(opaque)
        && offnum == P_HIKEY)
    {
+
        /*
         * we just have to believe that this will only be called with
         * offnum == P_HIKEY when P_HIKEY is the OffsetNumber of the first
@@ -702,11 +703,12 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
 
    bool        strategyCheck;
    ScanKey     scankeys = 0;
-   int     keysCount = 0;
-   int     *nKeyIs = 0;
-   int     i, j;
-   StrategyNumber  strat_total;
-       
+   int         keysCount = 0;
+   int        *nKeyIs = 0;
+   int         i,
+               j;
+   StrategyNumber strat_total;
+
    rel = scan->relation;
    so = (BTScanOpaque) scan->opaque;
 
@@ -723,15 +725,15 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
        _bt_orderkeys(rel, so);
 
        if (so->qual_ok)
-            strategyCheck = true;
-   }
+           strategyCheck = true;
+   }
    strat_total = BTEqualStrategyNumber;
    if (strategyCheck)
    {
        AttrNumber  attno;
 
-       nKeyIs = (int *)palloc(so->numberOfKeys*sizeof(int));
-       for (i=0; i < so->numberOfKeys; i++)
+       nKeyIs = (int *) palloc(so->numberOfKeys * sizeof(int));
+       for (i = 0; i < so->numberOfKeys; i++)
        {
            attno = so->keyData[i].sk_attno;
            if (attno == keysCount)
@@ -739,16 +741,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
            if (attno > keysCount + 1)
                break;
            strat = _bt_getstrat(rel, attno,
-                   so->keyData[i].sk_procedure);
+                                so->keyData[i].sk_procedure);
            if (strat == strat_total ||
-               strat == BTEqualStrategyNumber)
+               strat == BTEqualStrategyNumber)
            {
                nKeyIs[keysCount++] = i;
                continue;
            }
            if (ScanDirectionIsBackward(dir) &&
-               (strat == BTLessStrategyNumber ||
-                strat == BTLessEqualStrategyNumber) )
+               (strat == BTLessStrategyNumber ||
+                strat == BTLessEqualStrategyNumber))
            {
                nKeyIs[keysCount++] = i;
                strat_total = strat;
@@ -757,8 +759,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
                continue;
            }
            if (ScanDirectionIsForward(dir) &&
-               (strat == BTGreaterStrategyNumber ||
-                strat == BTGreaterEqualStrategyNumber) )
+               (strat == BTGreaterStrategyNumber ||
+                strat == BTGreaterEqualStrategyNumber))
            {
                nKeyIs[keysCount++] = i;
                strat_total = strat;
@@ -794,8 +796,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
     * at the right place in the scan.
     */
    /* _bt_orderkeys disallows it, but it's place to add some code latter */
-   scankeys = (ScanKey)palloc(keysCount*sizeof(ScanKeyData));
-   for (i=0; i < keysCount; i++)
+   scankeys = (ScanKey) palloc(keysCount * sizeof(ScanKeyData));
+   for (i = 0; i < keysCount; i++)
    {
        j = nKeyIs[i];
        if (so->keyData[j].sk_flags & SK_ISNULL)
@@ -804,12 +806,13 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
            pfree(scankeys);
            elog(ERROR, "_bt_first: btree doesn't support is(not)null, yet");
            return ((RetrieveIndexResult) NULL);
-       } 
-       proc = index_getprocid(rel, i+1, BTORDER_PROC);
-       ScanKeyEntryInitialize(scankeys+i, so->keyData[j].sk_flags,
-               i+1, proc, so->keyData[j].sk_argument);
+       }
+       proc = index_getprocid(rel, i + 1, BTORDER_PROC);
+       ScanKeyEntryInitialize(scankeys + i, so->keyData[j].sk_flags,
+                              i + 1, proc, so->keyData[j].sk_argument);
    }
-   if   (nKeyIs)   pfree(nKeyIs);
+   if (nKeyIs)
+       pfree(nKeyIs);
 
    stack = _bt_search(rel, keysCount, scankeys, &buf);
    _bt_freestack(stack);
index f9cbf7121ff4fb078723e226e6e81255dbbc3d48..65e757e42b3b176ab7560768ed980e0d500d0d44 100644 (file)
@@ -6,7 +6,7 @@
  *
  * We use tuplesort.c to sort the given index tuples into order.
  * Then we scan the index tuples in order and build the btree pages
- * for each level.  When we have only one page on a level, it must be the
+ * for each level. When we have only one page on a level, it must be the
  * root -- it can be attached to the btree metapage and we are done.
  *
  * this code is moderately slow (~10% slower) compared to the regular
@@ -28,7 +28,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.51 2000/02/18 06:32:39 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52 2000/04/12 17:14:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,12 +70,12 @@ struct BTSpool
 
 static void _bt_load(Relation index, BTSpool *btspool);
 static BTItem _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
-                          BTPageState *state, BTItem bti, int flags);
+            BTPageState *state, BTItem bti, int flags);
 static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
 static BTPageState *_bt_pagestate(Relation index, int flags,
-                                 int level, bool doupper);
+             int level, bool doupper);
 static void _bt_uppershutdown(Relation index, Size keysz, ScanKey scankey,
-                             BTPageState *state);
+                 BTPageState *state);
 
 
 /*
@@ -86,7 +86,7 @@ static void _bt_uppershutdown(Relation index, Size keysz, ScanKey scankey,
 /*
  * create and initialize a spool structure
  */
-BTSpool *
+BTSpool    *
 _bt_spoolinit(Relation index, bool isunique)
 {
    BTSpool    *btspool = (BTSpool *) palloc(sizeof(BTSpool));
@@ -99,9 +99,9 @@ _bt_spoolinit(Relation index, bool isunique)
    btspool->sortstate = tuplesort_begin_index(index, isunique, false);
 
    /*
-    * Currently, tuplesort provides sort functions on IndexTuples.
-    * If we kept anything in a BTItem other than a regular IndexTuple,
-    * we'd need to modify tuplesort to understand BTItems as such.
+    * Currently, tuplesort provides sort functions on IndexTuples. If we
+    * kept anything in a BTItem other than a regular IndexTuple, we'd
+    * need to modify tuplesort to understand BTItems as such.
     */
    Assert(sizeof(BTItemData) == sizeof(IndexTupleData));
 
@@ -306,20 +306,20 @@ _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
    btisz = MAXALIGN(btisz);
 
    /*
-    * Check whether the item can fit on a btree page at all.
-    * (Eventually, we ought to try to apply TOAST methods if not.)
-    * We actually need to be able to fit three items on every page,
-    * so restrict any one item to 1/3 the per-page available space.
-    * Note that at this point, btisz doesn't include the ItemId.
+    * Check whether the item can fit on a btree page at all. (Eventually,
+    * we ought to try to apply TOAST methods if not.) We actually need to
+    * be able to fit three items on every page, so restrict any one item
+    * to 1/3 the per-page available space. Note that at this point, btisz
+    * doesn't include the ItemId.
     *
     * NOTE: similar code appears in _bt_insertonpg() to defend against
-    * oversize items being inserted into an already-existing index.
-    * But during creation of an index, we don't go through there.
+    * oversize items being inserted into an already-existing index. But
+    * during creation of an index, we don't go through there.
     */
-   if (btisz > (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData))
+   if (btisz > (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
        elog(ERROR, "btree: index item size %d exceeds maximum %ld",
             btisz,
-            (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData));
+            (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
 
    if (pgspc < btisz)
    {
index 9d1cc7b10d0531f07d566b8847f56bc2f28e4a7d..38b152e61b28b214fa6c3a2afd848bf94fdfc7a7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.35 2000/02/18 06:32:39 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.36 2000/04/12 17:14:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -141,7 +141,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
    uint16      numberOfKeys = so->numberOfKeys;
    uint16      new_numberOfKeys = 0;
    AttrNumber  attno = 1;
-   bool        equalStrategyEnd, underEqualStrategy;
+   bool        equalStrategyEnd,
+               underEqualStrategy;
 
    if (numberOfKeys < 1)
        return;
@@ -194,6 +195,7 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
                elog(ERROR, "_bt_orderkeys: key(s) for attribute %d missed", attno + 1);
 
            underEqualStrategy = (!equalStrategyEnd);
+
            /*
             * If = has been specified, no other key will be used. In case
             * of key < 2 && key == 1 and so on we have to set qual_ok to
index 34cf0b6c9370e1d038d232b744871a2fdfda717e..53e5345a55d75f38219b800ee45ed82ff8e546c8 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.44 2000/03/01 05:39:23 inoue Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.45 2000/04/12 17:14:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -181,7 +181,7 @@ rtbuild(Relation heap,
 #ifndef OMIT_PARTIAL_INDEX
            /* SetSlotContents(slot, htup); */
            slot->val = htup;
-           if (! ExecQual((List *) pred, econtext, false))
+           if (!ExecQual((List *) pred, econtext, false))
                continue;
 #endif  /* OMIT_PARTIAL_INDEX */
        }
@@ -249,18 +249,18 @@ rtbuild(Relation heap,
    /*
     * Since we just counted the tuples in the heap, we update its stats
     * in pg_class to guarantee that the planner takes advantage of the
-    * index we just created.  But, only update statistics during
-    * normal index definitions, not for indices on system catalogs
-    * created during bootstrap processing.  We must close the relations
-    * before updating statistics to guarantee that the relcache entries
-    * are flushed when we increment the command counter in UpdateStats().
-    * But we do not release any locks on the relations; those will be
-    * held until end of transaction.
+    * index we just created.  But, only update statistics during normal
+    * index definitions, not for indices on system catalogs created
+    * during bootstrap processing.  We must close the relations before
+    * updating statistics to guarantee that the relcache entries are
+    * flushed when we increment the command counter in UpdateStats(). But
+    * we do not release any locks on the relations; those will be held
+    * until end of transaction.
     */
    if (IsNormalProcessingMode())
    {
-       Oid     hrelid = RelationGetRelid(heap);
-       Oid     irelid = RelationGetRelid(index);
+       Oid         hrelid = RelationGetRelid(heap);
+       Oid         irelid = RelationGetRelid(index);
        bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
index ada386127788ed34e07403737d34b440c93f5f20..71e2acf5f88d0be5cf97e28763afa50a57a0ecbf 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.31 2000/01/26 05:56:00 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.32 2000/04/12 17:14:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -268,7 +268,7 @@ rtdropscan(IndexScanDesc s)
        prev = l;
 
    if (l == (RTScanList) NULL)
-       elog(ERROR, "rtree scan list corrupted -- cannot find 0x%p", (void*)s);
+       elog(ERROR, "rtree scan list corrupted -- cannot find 0x%p", (void *) s);
 
    if (prev == (RTScanList) NULL)
        RTScans = l->rtsl_next;
index 36d50f08c0c32937d908c6a6ee2957a7d1da03a9..4efb53ea08c1ac14729c484f51f6dc9701e5b430 100644 (file)
@@ -1,4 +1,4 @@
 #include "postgres.h"
 #include "access/rmgr.h"
 
-RmgrData      *RmgrTable = NULL;
+RmgrData   *RmgrTable = NULL;
index a5af2bdc533a43810bd4c5f081c4f59ed805c859..acca4a901a2f16083d1eff601ec4647046d1b527 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.33 2000/01/26 05:56:03 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.34 2000/04/12 17:14:52 momjian Exp $
  *
  * NOTES
  *   This file contains the high level access-method interface to the
@@ -162,6 +162,7 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */
 
    if (!fail)
    {
+
        /*
         * DO NOT cache status for transactions in unknown state !!!
         */
index 6a31bfe429ecc50feea01380d44646a721069707..5ce334aa299682048c966bc19bc859fa8df0e24e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.27 2000/03/31 02:43:31 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.28 2000/04/12 17:14:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -331,8 +331,8 @@ ReadNewTransactionId(TransactionId *xid)
    SpinAcquire(OidGenLockId);  /* not good for concurrency... */
 
    /*
-    * Note that we don't check is ShmemVariableCache->xid_count equal
-    * to 0 or not. This will work as long as we don't call 
+    * Note that we don't check is ShmemVariableCache->xid_count equal to
+    * 0 or not. This will work as long as we don't call
     * ReadNewTransactionId() before GetNewTransactionId().
     */
    if (ShmemVariableCache->nextXid == 0)
index 2522cca46c12296a4abfe76bc6391c120fede8ae..688741511fbaa8b280972b41cf95eac3da3c4f88 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.63 2000/04/09 04:43:16 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.64 2000/04/12 17:14:53 momjian Exp $
  *
  * NOTES
  *     Transaction aborts can now occur two ways:
 #include "utils/portal.h"
 #include "utils/relcache.h"
 
-extern bool    SharedBufferChanged;
+extern bool SharedBufferChanged;
 
 static void AbortTransaction(void);
 static void AtAbort_Cache(void);
@@ -517,8 +517,8 @@ CommandCounterIncrement()
    CurrentTransactionStateData.scanCommandId = CurrentTransactionStateData.commandId;
 
    /*
-    * make cache changes visible to me.  AtCommit_LocalCache()
-    * instead of AtCommit_Cache() is called here.
+    * make cache changes visible to me.  AtCommit_LocalCache() instead of
+    * AtCommit_Cache() is called here.
     */
    AtCommit_LocalCache();
    AtStart_Cache();
@@ -627,16 +627,15 @@ RecordTransactionCommit()
     */
    xid = GetCurrentTransactionId();
 
-   /* 
-    *  flush the buffer manager pages.  Note: if we have stable
-    *  main memory, dirty shared buffers are not flushed
-    *  plai 8/7/90
+   /*
+    * flush the buffer manager pages.  Note: if we have stable main
+    * memory, dirty shared buffers are not flushed plai 8/7/90
     */
    leak = BufferPoolCheckLeak();
 
    /*
-    * If no one shared buffer was changed by this transaction then
-    * we don't flush shared buffers and don't record commit status.
+    * If no one shared buffer was changed by this transaction then we
+    * don't flush shared buffers and don't record commit status.
     */
    if (SharedBufferChanged)
    {
@@ -645,13 +644,13 @@ RecordTransactionCommit()
            ResetBufferPool(true);
 
        /*
-        *  have the transaction access methods record the status
-        *  of this transaction id in the pg_log relation.
+        * have the transaction access methods record the status of this
+        * transaction id in the pg_log relation.
         */
        TransactionIdCommit(xid);
 
        /*
-        *  Now write the log info to the disk too.
+        * Now write the log info to the disk too.
         */
        leak = BufferPoolCheckLeak();
        FlushBufferPool();
@@ -751,10 +750,10 @@ RecordTransactionAbort()
     */
    xid = GetCurrentTransactionId();
 
-   /* 
-    * Have the transaction access methods record the status of
-    * this transaction id in the pg_log relation. We skip it
-    * if no one shared buffer was changed by this transaction.
+   /*
+    * Have the transaction access methods record the status of this
+    * transaction id in the pg_log relation. We skip it if no one shared
+    * buffer was changed by this transaction.
     */
    if (SharedBufferChanged && !TransactionIdDidCommit(xid))
        TransactionIdAbort(xid);
@@ -936,7 +935,7 @@ CommitTransaction()
    /* ----------------
     *  Tell the trigger manager that this transaction is about to be
     *  committed. He'll invoke all trigger deferred until XACT before
-    *  we really start on committing the transaction. 
+    *  we really start on committing the transaction.
     * ----------------
     */
    DeferredTriggerEndXact();
@@ -965,13 +964,13 @@ CommitTransaction()
    RecordTransactionCommit();
 
    /*
-    * Let others know about no transaction in progress by me.
-    * Note that this must be done _before_ releasing locks we hold 
-    * and SpinAcquire(SInvalLock) is required: UPDATE with xid 0 is 
-    * blocked by xid 1' UPDATE, xid 1 is doing commit while xid 2 
-    * gets snapshot - if xid 2' GetSnapshotData sees xid 1 as running
-    * then it must see xid 0 as running as well or it will see two
-    * tuple versions - one deleted by xid 1 and one inserted by xid 0.
+    * Let others know about no transaction in progress by me. Note that
+    * this must be done _before_ releasing locks we hold and
+    * SpinAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked
+    * by xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot -
+    * if xid 2' GetSnapshotData sees xid 1 as running then it must see
+    * xid 0 as running as well or it will see two tuple versions - one
+    * deleted by xid 1 and one inserted by xid 0.
     */
    if (MyProc != (PROC *) NULL)
    {
@@ -995,7 +994,7 @@ CommitTransaction()
     * ----------------
     */
    s->state = TRANS_DEFAULT;
-   SharedBufferChanged = false;    /* safest place to do it */
+   SharedBufferChanged = false;/* safest place to do it */
 
 }
 
@@ -1031,7 +1030,7 @@ AbortTransaction()
 
    /* ----------------
     *  Tell the trigger manager that this transaction is about to be
-    *  aborted. 
+    *  aborted.
     * ----------------
     */
    DeferredTriggerAbortXact();
@@ -1070,7 +1069,7 @@ AbortTransaction()
     * ----------------
     */
    s->state = TRANS_DEFAULT;
-   SharedBufferChanged = false;    /* safest place to do it */
+   SharedBufferChanged = false;/* safest place to do it */
 }
 
 /* --------------------------------
index 7d197cb5a3a36b89e0dfa6fe35c308facc887a55..b672cf2c7a9621fbab60fa58ae37870be2e06718 100644 (file)
@@ -1,4 +1,4 @@
-/*------------------------------------------------------------------------- 
+/*-------------------------------------------------------------------------
  *
  * xlog.c
  *
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.12 2000/03/20 07:25:39 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.13 2000/04/12 17:14:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,64 +44,64 @@ bool        StopIfError = false;
 SPINLOCK   ControlFileLockId;
 SPINLOCK   XidGenLockId;
 
-extern bool                ReleaseDataFile(void);
+extern bool ReleaseDataFile(void);
 
-extern VariableCache   ShmemVariableCache;
+extern VariableCache ShmemVariableCache;
 
-#define    MinXLOGbuffers  4
+#define MinXLOGbuffers 4
 
 typedef struct XLgwrRqst
 {
-   XLogRecPtr      Write;      /* byte (1-based) to write out */
-   XLogRecPtr      Flush;      /* byte (1-based) to flush */
+   XLogRecPtr  Write;          /* byte (1-based) to write out */
+   XLogRecPtr  Flush;          /* byte (1-based) to flush */
 } XLgwrRqst;
 
 typedef struct XLgwrResult
 {
-   XLogRecPtr      Write;      /* bytes written out */
-   XLogRecPtr      Flush;      /* bytes flushed */
+   XLogRecPtr  Write;          /* bytes written out */
+   XLogRecPtr  Flush;          /* bytes flushed */
 } XLgwrResult;
 
 typedef struct XLogCtlInsert
 {
-   XLgwrResult     LgwrResult;
-   XLogRecPtr      PrevRecord;
-   uint16          curridx;    /* current block index in cache */
-   XLogPageHeader  currpage;
-   char           *currpos;
+   XLgwrResult LgwrResult;
+   XLogRecPtr  PrevRecord;
+   uint16      curridx;        /* current block index in cache */
+   XLogPageHeader currpage;
+   char       *currpos;
 } XLogCtlInsert;
 
 typedef struct XLogCtlWrite
 {
-   XLgwrResult     LgwrResult;
-   uint16          curridx;    /* index of next block to write */
+   XLgwrResult LgwrResult;
+   uint16      curridx;        /* index of next block to write */
 } XLogCtlWrite;
 
 
 #ifndef HAS_TEST_AND_SET
-#define    TAS(lck)        0
-#define    S_UNLOCK(lck)
-#define    S_INIT_LOCK(lck)
+#define TAS(lck)       0
+#define S_UNLOCK(lck)
+#define S_INIT_LOCK(lck)
 #endif
 
 typedef struct XLogCtlData
 {
-   XLogCtlInsert   Insert;
-   XLgwrRqst       LgwrRqst;
-   XLgwrResult     LgwrResult;
-   XLogCtlWrite    Write;
-   char           *pages;
-   XLogRecPtr     *xlblocks;   /* 1st byte ptr-s + BLCKSZ */
-   uint32          XLogCacheByte;
-   uint32          XLogCacheBlck;
+   XLogCtlInsert Insert;
+   XLgwrRqst   LgwrRqst;
+   XLgwrResult LgwrResult;
+   XLogCtlWrite Write;
+   char       *pages;
+   XLogRecPtr *xlblocks;       /* 1st byte ptr-s + BLCKSZ */
+   uint32      XLogCacheByte;
+   uint32      XLogCacheBlck;
 #ifdef HAS_TEST_AND_SET
-   slock_t         insert_lck;
-   slock_t         info_lck;
-   slock_t         lgwr_lck;
+   slock_t     insert_lck;
+   slock_t     info_lck;
+   slock_t     lgwr_lck;
 #endif
 } XLogCtlData;
 
-static XLogCtlData        *XLogCtl = NULL;
+static XLogCtlData *XLogCtl = NULL;
 
 typedef enum DBState
 {
@@ -114,69 +114,69 @@ typedef enum DBState
 
 typedef struct ControlFileData
 {
-   uint32          logId;          /* current log file id */
-   uint32          logSeg;         /* current log file segment (1-based) */
-   XLogRecPtr      checkPoint;     /* last check point record ptr */
-   time_t          time;           /* time stamp of last modification */
-   DBState         state;          /* */
+   uint32      logId;          /* current log file id */
+   uint32      logSeg;         /* current log file segment (1-based) */
+   XLogRecPtr  checkPoint;     /* last check point record ptr */
+   time_t      time;           /* time stamp of last modification */
+   DBState     state;          /* */
 
    /*
-    * this data is used to make sure that configuration of this DB
-    * is compatible with the current backend
+    * this data is used to make sure that configuration of this DB is
+    * compatible with the current backend
     */
-   uint32          blcksz;         /* block size for this DB */
-   uint32          relseg_size;    /* blocks per segment of large relation */
-   uint32          catalog_version_no; /* internal version number */
+   uint32      blcksz;         /* block size for this DB */
+   uint32      relseg_size;    /* blocks per segment of large relation */
+   uint32      catalog_version_no;     /* internal version number */
 
    /*
-    * MORE DATA FOLLOWS AT THE END OF THIS STRUCTURE
-    * - locations of data dirs 
+    * MORE DATA FOLLOWS AT THE END OF THIS STRUCTURE - locations of data
+    * dirs
     */
 } ControlFileData;
 
-static ControlFileData    *ControlFile = NULL;
+static ControlFileData *ControlFile = NULL;
 
 typedef struct CheckPoint
 {
-   XLogRecPtr      redo;       /* next RecPtr available when we */
-                               /* began to create CheckPoint */
-                               /* (i.e. REDO start point) */
-   XLogRecPtr      undo;       /* first record of oldest in-progress */
-                               /* transaction when we started */
-                               /* (i.e. UNDO end point) */
-   TransactionId   nextXid;
-   Oid             nextOid;
+   XLogRecPtr  redo;           /* next RecPtr available when we */
+   /* began to create CheckPoint */
+   /* (i.e. REDO start point) */
+   XLogRecPtr  undo;           /* first record of oldest in-progress */
+   /* transaction when we started */
+   /* (i.e. UNDO end point) */
+   TransactionId nextXid;
+   Oid         nextOid;
 } CheckPoint;
 
-/* 
- * We break each log file in 16Mb segments 
+/*
+ * We break each log file in 16Mb segments
  */
 #define XLogSegSize        (16*1024*1024)
-#define    XLogLastSeg     (0xffffffff / XLogSegSize)
-#define    XLogFileSize    (XLogLastSeg * XLogSegSize)
+#define XLogLastSeg        (0xffffffff / XLogSegSize)
+#define XLogFileSize   (XLogLastSeg * XLogSegSize)
 
-#define    XLogFileName(path, log, seg)    \
+#define XLogFileName(path, log, seg)   \
            snprintf(path, MAXPGPATH, "%s%c%08X%08X",   \
                     XLogDir, SEP_CHAR, log, seg)
 
-#define    PrevBufIdx(curridx)     \
+#define PrevBufIdx(curridx)        \
        ((curridx == 0) ? XLogCtl->XLogCacheBlck : (curridx - 1))
 
-#define    NextBufIdx(curridx)     \
+#define NextBufIdx(curridx)        \
        ((curridx == XLogCtl->XLogCacheBlck) ? 0 : (curridx + 1))
 
-#define    XLByteLT(left, right)       \
+#define XLByteLT(left, right)      \
            (right.xlogid > left.xlogid || \
            (right.xlogid == left.xlogid && right.xrecoff > left.xrecoff))
 
-#define    XLByteLE(left, right)       \
+#define XLByteLE(left, right)      \
            (right.xlogid > left.xlogid || \
            (right.xlogid == left.xlogid && right.xrecoff >=  left.xrecoff))
 
-#define    XLByteEQ(left, right)       \
+#define XLByteEQ(left, right)      \
            (right.xlogid == left.xlogid && right.xrecoff ==  left.xrecoff)
 
-#define    InitXLBuffer(curridx)   (\
+#define InitXLBuffer(curridx)  (\
                XLogCtl->xlblocks[curridx].xrecoff = \
                (XLogCtl->xlblocks[Insert->curridx].xrecoff == XLogFileSize) ? \
                BLCKSZ : (XLogCtl->xlblocks[Insert->curridx].xrecoff + BLCKSZ), \
@@ -192,46 +192,46 @@ typedef struct CheckPoint
                Insert->currpage->xlp_info = 0 \
                )
 
-#define    XRecOffIsValid(xrecoff) \
+#define XRecOffIsValid(xrecoff) \
        (xrecoff % BLCKSZ >= SizeOfXLogPHD && \
        (BLCKSZ - xrecoff % BLCKSZ) >= SizeOfXLogRecord)
 
-static void                GetFreeXLBuffer(void);
-static void                XLogWrite(char *buffer);
-static int             XLogFileInit(uint32 log, uint32 seg);
-static int             XLogFileOpen(uint32 log, uint32 seg, bool econt);
-static XLogRecord     *ReadRecord(XLogRecPtr *RecPtr, char *buffer);
-static char               *str_time(time_t tnow);
-
-static XLgwrResult     LgwrResult = {{0, 0}, {0, 0}};
-static XLgwrRqst       LgwrRqst = {{0, 0}, {0, 0}};
-
-static int             logFile = -1;
-static uint32          logId = 0;
-static uint32          logSeg = 0;
-static uint32          logOff = 0;
-
-static XLogRecPtr      ReadRecPtr;
-static XLogRecPtr      EndRecPtr;
-static int             readFile = -1;
-static uint32          readId = 0;
-static uint32          readSeg = 0;
-static uint32          readOff = 0;
-static char                readBuf[BLCKSZ];
-static XLogRecord     *nextRecord = NULL;
+static void GetFreeXLBuffer(void);
+static void XLogWrite(char *buffer);
+static int XLogFileInit(uint32 log, uint32 seg);
+static int XLogFileOpen(uint32 log, uint32 seg, bool econt);
+static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, char *buffer);
+static char *str_time(time_t tnow);
+
+static XLgwrResult LgwrResult = {{0, 0}, {0, 0}};
+static XLgwrRqst LgwrRqst = {{0, 0}, {0, 0}};
+
+static int logFile = -1;
+static uint32 logId = 0;
+static uint32 logSeg = 0;
+static uint32 logOff = 0;
+
+static XLogRecPtr ReadRecPtr;
+static XLogRecPtr EndRecPtr;
+static int readFile = -1;
+static uint32 readId = 0;
+static uint32 readSeg = 0;
+static uint32 readOff = 0;
+static char readBuf[BLCKSZ];
+static XLogRecord *nextRecord = NULL;
 
 XLogRecPtr
 XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
 {
-   XLogCtlInsert      *Insert = &XLogCtl->Insert;
-   XLogRecord         *record;
-   XLogSubRecord      *subrecord;
-   XLogRecPtr          RecPtr;
-   uint32              len = hdrlen + buflen,
-                       freespace,
-                       wlen;
-   uint16              curridx;
-   bool                updrqst = false;
+   XLogCtlInsert *Insert = &XLogCtl->Insert;
+   XLogRecord *record;
+   XLogSubRecord *subrecord;
+   XLogRecPtr  RecPtr;
+   uint32      len = hdrlen + buflen,
+               freespace,
+               wlen;
+   uint16      curridx;
+   bool        updrqst = false;
 
    if (len == 0 || len > MAXLOGRECSZ)
        elog(STOP, "XLogInsert: invalid record len %u", len);
@@ -242,7 +242,7 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
        bool        do_lgwr = true;
        unsigned    i = 0;
 
-       for ( ; ; )
+       for (;;)
        {
            /* try to read LgwrResult while waiting for insert lock */